#ifndef __UART_INTERFACE_H #define __UART_INTERFACE_H #ifdef __cplusplus extern "C" { #endif #ifdef __UART_INTERFACE_H_GLOBAL #define __UART_INTERFACE_H_EXTERN #else #define __UART_INTERFACE_H_EXTERN extern #endif /************************************************************************************************ * Version * ************************************************************************************************/ /************************************************************************************************ * How to use * ************************************************************************************************/ /************************************************************************************************ * Enable config * ************************************************************************************************/ /************************************************************************************************ * Includes * ************************************************************************************************/ #include /************************************************************************************************ * Defines * ************************************************************************************************/ #define RX_TX_BUF_LEN (50) #define UART_SEND_IT_DISABLE() CLEAR_BIT(USART1->SR, USART_SR_RXNE) #define UART_RECV_IT_ENABLE() SET_BIT(USART1->CR1, USART_CR1_TXEIE) /************************************************************************************************ * Typedefs * ************************************************************************************************/ typedef struct { uint8_t rx[RX_TX_BUF_LEN]; uint8_t tx[RX_TX_BUF_LEN]; uint8_t rx_len; uint8_t tx_len; uint8_t rx_count_u8; uint8_t tx_count_u8; uint8_t device_type; uint8_t rx_finished_flg; uint8_t disconnect_flg; uint8_t rx_over_time; uint8_t rx_over_time_count; uint16_t disconnect_count; } uart_type; /************************************************************************************************ * Interfaces * ************************************************************************************************/ extern uart_type uart_msg; void uart_rx_ticks(void); void uart_start_send(uart_type *p_msg); #ifdef __cplusplus }; #endif #endif // __UART_INTERFACE_H