You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.2 KiB

3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
  1. #if 0
  2. #include "uart0.h"
  3. void uart0_init(void) {
  4. /**
  5. * @brief 0115200
  6. * Fpclk
  7. *
  8. */
  9. GPIO_InitSettingType InitSet;
  10. InitSet.Dir = GPIO_Direction_Output;
  11. InitSet.DS = GPIO_DS_Output_Strong;
  12. InitSet.Func = GPIO_Reuse_Func2;
  13. InitSet.ODE = GPIO_ODE_Output_Disable;
  14. InitSet.PDE = GPIO_PDE_Input_Disable;
  15. InitSet.PUE = GPIO_PUE_Input_Enable;
  16. InitSet.Signal = GPIO_Pin_Signal_Digital;
  17. GPIO_Init(UART0_TXD0_PIN, &InitSet);
  18. InitSet.Dir = GPIO_Direction_Input;
  19. InitSet.DS = GPIO_DS_Output_Strong;
  20. InitSet.Func = GPIO_Reuse_Func2;
  21. InitSet.ODE = GPIO_ODE_Output_Disable;
  22. InitSet.PDE = GPIO_PDE_Input_Disable;
  23. InitSet.PUE = GPIO_PUE_Input_Disable;
  24. InitSet.Signal = GPIO_Pin_Signal_Digital;
  25. GPIO_Init(UART0_RXD0_PIN, &InitSet);
  26. UART_InitStruType UART_InitStruct;
  27. UART_InitStruct.UART_BaudRate = 115200; //波特率
  28. UART_InitStruct.UART_ClockSet = UART_Clock_1; //时钟选择不分频
  29. UART_InitStruct.UART_RxMode = UART_DataMode_8; // 8数据位无奇偶校验位
  30. //标准极性端口数据和传输数据相同
  31. UART_InitStruct.UART_RxPolar = UART_Polar_Normal;
  32. UART_InitStruct.UART_StopBits = UART_StopBits_1; //一个停止位
  33. UART_InitStruct.UART_TxMode = UART_DataMode_8; // 8数据位无奇偶校验位
  34. UART_InitStruct.UART_TxPolar = UART_Polar_Normal; //标准usart极性
  35. UART_Init(UART0, &UART_InitStruct);
  36. UART_ITConfig(UART0, UART_IT_RB, Enable); /* UART0接收中断使能 */
  37. /* UART0发送缓冲区空中断模式: 全空中断 */
  38. UART_TBIMConfig(UART0, UART_TBIM_Byte);
  39. UART_ClearITPendingBit(UART0, UART_FLAG_TB);
  40. UART_ClearITPendingBit(UART0, UART_FLAG_RB);
  41. UART_ClearITPendingBit(UART0, UART_FLAG_FE);
  42. NVIC_Init(NVIC_UART0_IRQn, NVIC_Priority_1, Enable); //使能串口0中断
  43. UART0_TxEnable();
  44. UART0_RxEnable();
  45. }
  46. void fun(void) {}
  47. void Uart0SendBuff(uint8_t *buff) {
  48. while (*buff != '\0') {
  49. // UART_SendByte(UART0, *buff);
  50. while (UART_GetFlagStatus(UART0, UART_FLAG_TC) == RESET)
  51. ;
  52. UART_ClearITPendingBit(UART0, UART_FLAG_TC);
  53. buff++;
  54. }
  55. }
  56. #endif