1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #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 <stdint.h>
- /************************************************************************************************
- * 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
|