#ifndef __MAIN_H_ #define __MAIN_H_ #include "stm32f10x_conf.h" #include #include #include #include #include #include "sys.h" //功能配置 #if defined (STM32F10X_VET6_DEF) #define SYSLed_def (1) #define key16_def (0) #define Solen_def (1) #define LCD_def (1) #define Pull_up_down_def (0) #define DS1302_def (1) #define TEA5767_def (0) #define DHT11_def (1) #define WIFI_Uart1_def (1) #define xy5200_Uart2_def (1) #define SPI1_DMA_SD_def (1) #define UART1_SD_def (0) #define SPI2_DMA_SD_def (0) //wifi注册ID\服务器ID\目标ID #define SERVER_ID 0x00 #define REGMY_ID 0x03 #define AIM_ID 0x02 #elif defined (STM32F10X_C8T6_DEF) #define SYSLed_def (0) #define key16_def (0) #define Solen_def (1) #define LCD_def (1) #define Pull_up_down_def (0) #define DS1302_def (0) #define TEA5767_def (0) #define DHT11_def (1) #define WIFI_Uart1_def (1) #define xy5200_Uart2_def (0) #define SPI1_DMA_SD_def (1) #define UART1_SD_def (0) #define SPI2_DMA_SD_def (0) //wifi注册ID\服务器ID\目标ID #define SERVER_ID 0x00 #define REGMY_ID 0x04 #define AIM_ID 0x02 #endif /*SYSLed_def*/ #define LED_RCC_CONFIG (RCC_APB2Periph_GPIOC) #define LED_PORT_CONFIG (GPIOC) #define LED_PIN_CONFIG (GPIO_Pin_7) //GPIO_Pin_6已经 用作wifi信号led #define LED_PC7_LOW() (GPIO_ResetBits(LED_PORT_CONFIG, LED_PIN_CONFIG)) #define LED_PC7_HIGH() (GPIO_SetBits(LED_PORT_CONFIG, LED_PIN_CONFIG)) /*key16_def*/ #define KEY16_RCC_CONFIG (RCC_APB2Periph_GPIOA) #define KEY16_PORT_CONFIG (GPIOA) #define KEY16_OUTPIN_CONFIG (GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3) #define KEY16_INPIN_CONFIG (GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7) /*Solen_def*/ //E8 E9 ->B2 #if defined (STM32F10X_VET6_DEF) #define SOLEN_RCC_CONFIG (RCC_APB2Periph_GPIOE) #define SOLEN_PORT_CONFIG (GPIOE) #define SOLEN_PIN_CONFIG (GPIO_Pin_8|GPIO_Pin_9) #define SOLEN_PE8_LOW() (GPIO_ResetBits(SOLEN_PORT_CONFIG, GPIO_Pin_8)) #define SOLEN_PE8_HIGH() (GPIO_SetBits(SOLEN_PORT_CONFIG, GPIO_Pin_8)) #define SOLEN_PE9_LOW() (GPIO_ResetBits(SOLEN_PORT_CONFIG, GPIO_Pin_9)) #define SOLEN_PE9_HIGH() (GPIO_SetBits(SOLEN_PORT_CONFIG, GPIO_Pin_9)) #elif defined (STM32F10X_C8T6_DEF) #define SOLEN_RCC_CONFIG (RCC_APB2Periph_GPIOB) #define SOLEN_PORT_CONFIG (GPIOB) #define SOLEN_PIN_CONFIG (GPIO_Pin_2) #define SOLEN_PE8_LOW() (GPIO_ResetBits(SOLEN_PORT_CONFIG, SOLEN_PIN_CONFIG)) #define SOLEN_PE8_HIGH() (GPIO_SetBits(SOLEN_PORT_CONFIG, SOLEN_PIN_CONFIG)) #define SOLEN_PE9_LOW() //(GPIO_ResetBits(SOLEN_PORT_CONFIG, GPIO_Pin_9)) #define SOLEN_PE9_HIGH() //(GPIO_SetBits(SOLEN_PORT_CONFIG, GPIO_Pin_9)) #endif /*LCD_def*/ #if defined (STM32F10X_VET6_DEF) #define LCD_N5110_RCC (RCC_APB2Periph_GPIOE) #define LCD_N5110_PORT (GPIOE) #define LCD_N5110_PIN (GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5) #define BACKLIGHT (PEout(0)) #define LCD_RST (PEout(1)) #define LCD_CE (PEout(2)) #define LCD_DC (PEout(3)) #define SDIN (PEout(4)) #define SCLK (PEout(5)) #elif defined (STM32F10X_C8T6_DEF) #define LCD_N5110_RCC (RCC_APB2Periph_GPIOB) #define LCD_N5110_PORT (GPIOB) #define LCD_N5110_PIN (GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15) #define BACKLIGHT (PBout(10)) #define LCD_RST (PBout(11)) #define LCD_CE (PBout(12)) #define LCD_DC (PBout(13)) #define SDIN (PBout(14)) #define SCLK (PBout(15)) #endif /*Pull_up_down_def*/ #define PULL_RCC_CONFIG (RCC_APB2Periph_GPIOE) #define PULL_PORT_CONFIG (GPIOE) #define PULL_PIN_CONFIG (GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11) #define PULL_UP_PIN (GPIO_Pin_8 | GPIO_Pin_10) #define PULL_DOWN_PIN (GPIO_Pin_9 | GPIO_Pin_11) /*DS1302_def*/ #define DS1302_IORCC (RCC_APB2Periph_GPIOB) //DS18B20对应IO的时钟 #define DS1302_PORT (GPIOB) #define DS1302_SCK_PIN (GPIO_Pin_2) //定义DS18B20对应的IO口 #define DS1302_IO_PIN (GPIO_Pin_1) #define DS1302_CE_PIN (GPIO_Pin_0) /*TEA5767_def*/ #define TEA5767_RCC_CONFIG (RCC_APB2Periph_GPIOD) #define TEA5767_PORT_CONFIG (GPIOD) #define TEA5767_PIN_CONFIG (GPIO_Pin_12 | GPIO_Pin_13) #define TEA5767_SCL (PDout(13)) #define TEA5767_SDA (PDout(12)) #define TEA5767_SDA_VALUE (TEA5767ReadSDA()) /*DHT11_def*/ //C4->B0 #if defined (STM32F10X_VET6_DEF) #define DHT11_IORCC (RCC_APB2Periph_GPIOC) //DHT11对应IO的时钟 #define DHT11_PORT (GPIOC) #define DHT11_DATA_PIN (GPIO_Pin_4) //定义DHT11对应的IO口 #define DHT11_Out (PCout(4)) #define DHT11_In (PCin(4)) #elif defined (STM32F10X_C8T6_DEF) #define DHT11_IORCC (RCC_APB2Periph_GPIOB) //DHT11对应IO的时钟 #define DHT11_PORT (GPIOB) #define DHT11_DATA_PIN (GPIO_Pin_0) //定义DHT11对应的IO口 #define DHT11_Out (PBout(0)) #define DHT11_In (PBin(0)) #endif /*WIFI_Uart1_def*/ //UART1 #define Wifi_SEL_UART (1) #if(Wifi_SEL_UART == 1) /****** RCC 配置******/ /* APB2: USART1 ** APB1: USART2\3\4\5 */ #define Wifi_RCC_GPIO_CONFIG() (RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE)) #define Wifi_RCC_UART_CONFIG() (RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE)) //波特率 #define Wifi_UART_BAUD (115200) /****** GPIO 配置******/ //UART端口号 #define Wifi_GPIO (GPIOA) #define Wifi_Tx (GPIO_Pin_9) #define Wifi_Rx (GPIO_Pin_10) //串口号 #define Wifi_UART (USART1) /****** UART优先级******/ #define Wifi_NVIC_Group (NVIC_PriorityGroup_0) #define Wifi_NVIC_Interrupt (USART1_IRQn) //uart1中断号 #define Wifi_NVIC_Pre (0) #define Wifi_NVIC_Sub (1) #endif //复位脚 PB10 #define Reset_IORCC (RCC_APB2Periph_GPIOB) //Reset对应IO的时钟 #define Reset_PORT (GPIOB) #define Reset_Pin (GPIO_Pin_4) //信号脚 PB15 //C6->C13 #if defined (STM32F10X_VET6_DEF) #define WifiLed_IORCC (RCC_APB2Periph_GPIOC) //Reset对应IO的时钟 #define WifiLed_PORT (GPIOC) #define WifiLed_Pin (GPIO_Pin_6) #define WifiLedOn (GPIO_SetBits(WifiLed_PORT, WifiLed_Pin)) #define WifiLedOff (GPIO_ResetBits(WifiLed_PORT, WifiLed_Pin)) #elif defined (STM32F10X_C8T6_DEF) #define WifiLed_IORCC (RCC_APB2Periph_GPIOC) //Reset对应IO的时钟 #define WifiLed_PORT (GPIOC) #define WifiLed_Pin (GPIO_Pin_13) #define WifiLedOn (GPIO_SetBits(WifiLed_PORT, WifiLed_Pin)) #define WifiLedOff (GPIO_ResetBits(WifiLed_PORT, WifiLed_Pin)) #endif /*YX5200*/ //UART2 #define YX5200_SEL_UART (2) #if(YX5200_SEL_UART == 2) /****** RCC 配置******/ /* APB2: USART1 ** APB1: USART2\3\4\5 */ #define YX5200_RCC_GPIO_CONFIG() (RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO,ENABLE)) #define YX5200_RCC_UART_CONFIG() (RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE)) #define YX5200_RCC_Remap_CONFIG() (GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE)) //波特率 #define YX5200_UART_BAUD (9600) /****** GPIO 配置******/ //UART端口号 #define YX5200_GPIO (GPIOD) #define YX5200_Tx (GPIO_Pin_5) #define YX5200_Rx (GPIO_Pin_6) //串口号 #define YX5200_UART (USART2) /****** UART优先级******/ #define YX5200_NVIC_Group (NVIC_PriorityGroup_0) #define YX5200_NVIC_Interrupt (USART2_IRQn) //uart1中断号 #define YX5200_NVIC_Pre (0) #define YX5200_NVIC_Sub (2) #endif #define LCD_Backlight_AutoOff_Time_DEF (12000/100) //12s,在100ms扫描函数里 //配置函数 extern bool DS1302ReadIO ( void ); extern bool TEA5767ReadSDA ( void ); #endif