12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #ifndef __UART_H
- #define __UART_H
- #include "hal_systick.h"
- #include "stdio.h"
- #pragma pack(0)
- typedef struct
- {
- USART_TypeDef *usart_periph;
- uint8_t *tx_buf;
- uint16_t tx_buf_size;
- uint16_t tx_rd;
- uint16_t tx_wr;
- uint16_t tx_err;
- uint8_t *rx_buf;
- uint16_t rx_buf_size;
- uint16_t rx_rd;
- uint16_t rx_wr;
- uint16_t rx_err;
- void (*config)(void);
- void (*deconfig)(void);
- } usart_context_t;
- #pragma pack()
- void usart_config_init(usart_context_t *p_usart_content, uint32_t band_rate);
- void usart_config_deinit(usart_context_t *p_usart_content);
- void usart_send_it(usart_context_t *p_usart_content, const void *_send_buf, const uint16_t send_count);
- void usart_wait_send_finished(usart_context_t *p_usart_content);
- int32_t usart_read_until_char(usart_context_t *p_usart_content, char c);
- int32_t usart_read_until_mem(usart_context_t *p_usart_content, char *mem, int len);
- int32_t usart_read_ble_format(usart_context_t *p_usart_content);
- int32_t usart_read_update(usart_context_t *p_usart_content, int rlen, char *data);
- int32_t usart_read_drop(usart_context_t *p_usart_content);
- void usart_it(usart_context_t *p_usart_content);
- int usart_receive_read(usart_context_t *p_usart_context, void *_receive_buf, const int receive_count);
- void usart_printf(usart_context_t *p_usart_context, char *args, ...);
- void u_tm_log(char *args, ...);
- void u_log(char *arg, ...);
- extern usart_context_t usart1_context;
- extern usart_context_t usart2_context;
- extern usart_context_t usart3_context;
- #endif
|