|
#ifndef __sys_H
#define __sys_H
#include "stm32f0xx.h"
//------------------------------------------------------
typedef struct _16_Bits_Struct
{
uint16_t bit0 : 1;//占一個(gè)bit
uint16_t bit1 : 1;
uint16_t bit2 : 1;
uint16_t bit3 : 1;
uint16_t bit4 : 1;
uint16_t bit5 : 1;
uint16_t bit6 : 1;
uint16_t bit7 : 1;
uint16_t bit8 : 1;
uint16_t bit9 : 1;
uint16_t bit10 : 1;
uint16_t bit11 : 1;
uint16_t bit12 : 1;
uint16_t bit13 : 1;
uint16_t bit14 : 1;
uint16_t bit15 : 1;
} Bits_16_TypeDef;
//結(jié)構(gòu)體和端口結(jié)合,輸出
#define BITS_PORT_B_OUT ((Bits_16_TypeDef *)(&(GPIOB->ODR))) //結(jié)構(gòu)體結(jié)合到GPIOB->ODR
#define LED_5V (BITS_PORT_B_OUT->bit6) //LED接在GPIOB->ODR->bit6
#define OLED_SCL (BITS_PORT_B_OUT->bit1)
#define OLED_SDA (BITS_PORT_B_OUT->bit10)
#define OLED_RST (BITS_PORT_B_OUT->bit12)
#define OLED_DC (BITS_PORT_B_OUT->bit14)
#define BITS_PORT_A_OUT ((Bits_16_TypeDef *)(&(GPIOA->ODR))) //結(jié)構(gòu)體結(jié)合到GPIOA->ODR
#define OLED_nCS (BITS_PORT_A_OUT->bit8) //OLED_nCS接在GPIOC->ODR->bit13
#define BITS_PORT_C_OUT ((Bits_16_TypeDef *)(&(GPIOC->ODR))) //結(jié)構(gòu)體結(jié)合到GPIOC->ODR
#define LED_3V (BITS_PORT_C_OUT->bit13) //LED接在GPIOC->ODR->bit13
//結(jié)構(gòu)體和端口結(jié)合,輸入
#define BITS_PORT_B_IN ((Bits_16_TypeDef *)(&(GPIOB->IDR))) //結(jié)構(gòu)體結(jié)合到GPIOB->IDR
#define IN_B_5 (BITS_PORT_B_IN->bit5) //輸入端口接在GPIOB->IDR->bit5
#endif
|
|