hal_uart.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef __UART_H
  2. #define __UART_H
  3. #include "hal_systick.h"
  4. #include "stdio.h"
  5. #pragma pack(0)
  6. typedef struct
  7. {
  8. USART_TypeDef *usart_periph;
  9. uint8_t *tx_buf;
  10. uint16_t tx_buf_size;
  11. uint16_t tx_rd;
  12. uint16_t tx_wr;
  13. uint16_t tx_err;
  14. uint8_t *rx_buf;
  15. uint16_t rx_buf_size;
  16. uint16_t rx_rd;
  17. uint16_t rx_wr;
  18. uint16_t rx_err;
  19. void (*config)(void);
  20. void (*deconfig)(void);
  21. } usart_context_t;
  22. #pragma pack()
  23. void usart_config_init(usart_context_t *p_usart_content, uint32_t band_rate);
  24. void usart_config_deinit(usart_context_t *p_usart_content);
  25. void usart_send_it(usart_context_t *p_usart_content, const void *_send_buf, const uint16_t send_count);
  26. void usart_wait_send_finished(usart_context_t *p_usart_content);
  27. int32_t usart_read_until_char(usart_context_t *p_usart_content, char c);
  28. int32_t usart_read_until_mem(usart_context_t *p_usart_content, char mem, int len);
  29. int32_t usart_read_ble_format(usart_context_t *p_usart_content);
  30. int32_t usart_read_update(usart_context_t *p_usart_content, int rlen, char *data);
  31. int32_t usart_read_drop(usart_context_t *p_usart_content);
  32. void usart_it(usart_context_t *p_usart_content);
  33. int usart_receive_read(usart_context_t *p_usart_context, void *_receive_buf, const int receive_count);
  34. void usart_printf(usart_context_t *p_usart_context, char *args, ...);
  35. void u_tm_log(char *args, ...);
  36. void u_log(char *arg, ...);
  37. extern usart_context_t usart1_context;
  38. #endif