1234567891011121314151617181920212223242526272829303132333435363738 |
- #ifndef __MYUART_H
- #define __MYUART_H
- #include <stdio.h>
- #include <stdint.h>
- #include <stdbool.h>
- #include <string.h>
- typedef void (*UART_CALLBACK)(uint8_t *buf, uint16_t count);
- #define USART_REC_LEN 1024 //
- typedef enum
- {
- US_UART1,
- US_UART3,
- }uartSrc_te;
- typedef struct
- {
- bool isValid;
- uint8_t packet[USART_REC_LEN];
- uint16_t len;
- }uartPacket_ts;
- extern uint8_t printf_uartX;
- void myUart1_init(uint32_t baudrate, UART_CALLBACK cb);
- void myUart1_sendByte(uint8_t src);
- void myUart1_sendArray(uint8_t *src, uint16_t srclen);
- void myUart3_init(uint32_t baudrate, UART_CALLBACK cb);
- void myUart3_sendByte(uint8_t src);
- void myUart3_sendArray(uint8_t *src, uint16_t srclen);
- #define myPrintf1(args...) do{printf_uartX = US_UART1; printf(args);}while(0)
- #define myPrintf3(args...) do{printf_uartX = US_UART3; printf(args);printf_uartX = US_UART1; printf(args);}while(0)
- #define consoles(args...) do{if(CONSOLE_FLAG==0)break;printf_uartX = US_UART2; printf(args);}while(0)
- #endif
|