main.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef __MAIN_H_
  2. #define __MAIN_H_
  3. #include "stm32f0xx_conf.h"
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <stdbool.h>
  7. #include <string.h>
  8. #include <math.h>
  9. #include "sys.h"
  10. //功能配置
  11. #if defined (STM32F030)
  12. #define SYSLed_def (0)
  13. #define key4_def (0)
  14. #define LCD_def (1)
  15. #define HC_SR04_def (1)
  16. #define WIFI_Uart1_def (1)
  17. #define Pull_up_down_def (0)
  18. //wifi注册ID\服务器ID\目标ID
  19. #define SERVER_ID 0x00
  20. #define REGMY_ID 0x03
  21. #define AIM_ID 0x02
  22. #endif
  23. /*SYSLed_def*/
  24. #define LED_RCC_CONFIG (RCC_AHBPeriph_GPIOA)
  25. #define LED_PORT_CONFIG (GPIOA)
  26. #define LED_PIN_CONFIG (GPIO_Pin_4)
  27. /*key4_def*/
  28. #define KEY4_RCC_CONFIG (RCC_AHBPeriph_GPIOB)
  29. #define KEY4_PORT_CONFIG (GPIOB)
  30. #define KEY4_INPIN_CONFIG (GPIO_Pin_1)
  31. /*HC_SR04_def*/
  32. #define SR04_RCC_CONFIG (RCC_AHBPeriph_GPIOA)
  33. #define SR04_PORT_CONFIG (GPIOA)
  34. #define SR04_OUTPIN_CONFIG (GPIO_Pin_5|GPIO_Pin_7)
  35. #define SR04_INPIN_CONFIG (GPIO_Pin_6)
  36. #define SR04_INPIN_Pre (1)
  37. /*LCD_def*/
  38. #if defined (STM32F030)
  39. #define LCD_QC12864B_RCC (RCC_AHBPeriph_GPIOA)
  40. #define LCD_QC12864B_PORT (GPIOA)
  41. #define LCD_QC12864B_PIN (GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4)
  42. #endif
  43. /*WIFI_Uart1_def*/
  44. //UART1
  45. #define Wifi_SEL_UART (1)
  46. #if(Wifi_SEL_UART == 1)
  47. /****** RCC 配置******/
  48. //波特率
  49. #define Wifi_UART_BAUD (115200)
  50. /****** GPIO 配置******/
  51. //UART端口号
  52. #define Wifi_GPIO (GPIOA)
  53. #define Wifi_Tx (GPIO_Pin_9)
  54. #define Wifi_Rx (GPIO_Pin_10)
  55. //串口号
  56. #define Wifi_UART (USART1)
  57. /****** UART优先级******/
  58. #define Wifi_NVIC_Group (NVIC_PriorityGroup_0)
  59. #define Wifi_NVIC_Interrupt (USART1_IRQn) //uart1中断号
  60. #define Wifi_NVIC_Pre (3)
  61. #endif
  62. //复位脚 PB10
  63. #define Reset_IORCC (RCC_APB2Periph_GPIOB) //Reset对应IO的时钟
  64. #define Reset_PORT (GPIOB)
  65. #define Reset_Pin (GPIO_Pin_4)
  66. #define bit u8
  67. #define INT8U u8
  68. #define INT16U u16
  69. typedef struct aa
  70. {
  71. INT8U a: 1 ;
  72. INT8U b: 1 ;
  73. INT8U c: 1 ;
  74. INT8U d: 1 ;
  75. INT8U e: 1 ;
  76. INT8U f: 1 ;
  77. INT8U g: 1 ;
  78. INT8U h: 1 ;
  79. } cc ;
  80. extern cc Status0 , Status1 , Status2, Status3;
  81. #define System_Flag_2Ms Status2.a
  82. #define System_Flag_10Ms Status2.b
  83. #define System_Flag_100Ms Status2.c
  84. #define System_Flag_200Ms Status2.d
  85. #define System_Flag_500Ms Status2.e
  86. #define System_Flag_1s Status2.f
  87. #define System_Flag_8s Status2.g
  88. #define System_Flag_20s Status2.h
  89. #endif