wifi_gpio_conf.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include "wifi_gpio_conf.h"
  2. #include "wifi9113.h"
  3. /*******************wifi UART通讯配置*********************/
  4. void Configuration_WIFI_Usart1 ( void )
  5. {
  6. #if (WIFI_Uart1_def || UART1_SD_def)
  7. GPIO_InitTypeDef GPIO_InitStructure;
  8. USART_InitTypeDef USART_InitStructure;
  9. //使能USART1/GPIO 时钟可配置
  10. Wifi_RCC_GPIO_CONFIG();
  11. Wifi_RCC_UART_CONFIG();
  12. /*
  13. * USART1_TX -> PA9 , USART1_RX -> PA10
  14. */
  15. GPIO_InitStructure.GPIO_Pin = Wifi_Tx;
  16. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  17. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  18. GPIO_Init ( Wifi_GPIO, &GPIO_InitStructure );
  19. GPIO_InitStructure.GPIO_Pin = Wifi_Rx;
  20. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  21. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  22. GPIO_Init ( Wifi_GPIO, &GPIO_InitStructure );
  23. USART_InitStructure.USART_BaudRate = Wifi_UART_BAUD;
  24. USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  25. USART_InitStructure.USART_StopBits = USART_StopBits_1;
  26. USART_InitStructure.USART_Parity = USART_Parity_No;
  27. USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  28. USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  29. USART_Init ( Wifi_UART, &USART_InitStructure );
  30. USART_ITConfig ( Wifi_UART, USART_IT_RXNE, ENABLE );
  31. USART_ITConfig ( Wifi_UART, USART_IT_TXE, DISABLE );
  32. USART_Cmd ( Wifi_UART, ENABLE );
  33. #endif
  34. }
  35. //系统中断管理
  36. void NVIC_Configuration_WIFI_USART1 ( void )
  37. {
  38. #if WIFI_Uart1_def
  39. NVIC_InitTypeDef NVIC_InitStructure;
  40. /* Configure the NVIC Preemption Priority Bits */
  41. NVIC_PriorityGroupConfig ( Wifi_NVIC_Group );
  42. /* Enable the USARTy Interrupt */
  43. NVIC_InitStructure.NVIC_IRQChannel = Wifi_NVIC_Interrupt;
  44. NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = Wifi_NVIC_Pre;
  45. NVIC_InitStructure.NVIC_IRQChannelSubPriority = Wifi_NVIC_Sub;
  46. NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  47. NVIC_Init ( &NVIC_InitStructure );
  48. #endif
  49. }
  50. /*******************wifi硬复位配置*********************/
  51. void Configuration_ResetWifi ( void )
  52. {
  53. #if WIFI_Uart1_def
  54. GPIO_InitTypeDef GPIO_InitStructure;
  55. RCC_APB2PeriphClockCmd ( Reset_IORCC, ENABLE );
  56. GPIO_InitStructure.GPIO_Pin = Reset_Pin;
  57. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  58. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  59. GPIO_Init ( Reset_PORT, &GPIO_InitStructure );
  60. #endif
  61. }
  62. void WifiHardReset ( void )
  63. {
  64. #if WIFI_Uart1_def
  65. GPIO_ResetBits ( Reset_PORT, Reset_Pin );
  66. GPIO_SetBits ( Reset_PORT, Reset_Pin );
  67. WifiProcessStep = WIFI_STEP_CHECK;
  68. WifiTimeReset = 0;
  69. #endif
  70. }
  71. void WifiSoftReset ( void )
  72. {
  73. strcpy ( bAtSentBuff, CONNECT_RESET );
  74. AtSent ( bAtSentBuff, strlen ( bAtSentBuff ) );
  75. }
  76. /*******************wifi信号灯*********************/
  77. void Configuration_WifiLed ( void )
  78. {
  79. #if WIFI_Uart1_def
  80. GPIO_InitTypeDef GPIO_InitStructure;
  81. RCC_APB2PeriphClockCmd ( WifiLed_IORCC, ENABLE );
  82. GPIO_InitStructure.GPIO_Pin = WifiLed_Pin;
  83. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  84. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  85. GPIO_Init ( WifiLed_PORT, &GPIO_InitStructure );
  86. #endif
  87. }