myUart.h 1017 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef __MYUART_H
  2. #define __MYUART_H
  3. #include <stdio.h>
  4. #include <stdint.h>
  5. #include <stdbool.h>
  6. #include <string.h>
  7. typedef void (*UART_CALLBACK)(uint8_t *buf, uint16_t count);
  8. #define USART_REC_LEN 1024 //
  9. typedef enum
  10. {
  11. US_UART1,
  12. US_UART3,
  13. }uartSrc_te;
  14. typedef struct
  15. {
  16. bool isValid;
  17. uint8_t packet[USART_REC_LEN];
  18. uint16_t len;
  19. }uartPacket_ts;
  20. extern uint8_t printf_uartX;
  21. void myUart1_init(uint32_t baudrate, UART_CALLBACK cb);
  22. void myUart1_sendByte(uint8_t src);
  23. void myUart1_sendArray(uint8_t *src, uint16_t srclen);
  24. void myUart3_init(uint32_t baudrate, UART_CALLBACK cb);
  25. void myUart3_sendByte(uint8_t src);
  26. void myUart3_sendArray(uint8_t *src, uint16_t srclen);
  27. #define myPrintf1(args...) do{printf_uartX = US_UART1; printf(args);}while(0)
  28. #define myPrintf3(args...) do{printf_uartX = US_UART3; printf(args);printf_uartX = US_UART1; printf(args);}while(0)
  29. #define consoles(args...) do{if(CONSOLE_FLAG==0)break;printf_uartX = US_UART2; printf(args);}while(0)
  30. #endif