Merge pull request #35 from ZYQ-FEIYUE/main

Serial port to rectify odd and even check problems
This commit is contained in:
WeAct Studio
2022-12-25 21:54:46 +08:00
committed by GitHub
6 changed files with 38 additions and 52 deletions

View File

@@ -34,31 +34,32 @@ typedef struct
static const SERIAL_ConfigGrp_t SERIAL_ConfigGrp[] = static const SERIAL_ConfigGrp_t SERIAL_ConfigGrp[] =
{ {
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_1_BIT}, // SERIAL_7E1
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_2_BIT}, // SERIAL_7E2
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_1_BIT}, // SERIAL_7O1
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_2_BIT}, // SERIAL_7O2
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_0_5_BIT}, // SERIAL_7E0_5
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_1_5_BIT}, // SERIAL_7E1_5
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_0_5_BIT}, // SERIAL_7O0_5
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_1_5_BIT}, // SERIAL_7O1_5
{USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_1_BIT}, // SERIAL_8N1 {USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_1_BIT}, // SERIAL_8N1
{USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_2_BIT}, // SERIAL_8N2 {USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_2_BIT}, // SERIAL_8N2
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_1_BIT}, // SERIAL_8E1 {USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_1_BIT}, // SERIAL_8E1
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_2_BIT}, // SERIAL_8E2 {USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_2_BIT}, // SERIAL_8E2
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_1_BIT}, // SERIAL_8O1 {USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_1_BIT}, // SERIAL_8O1
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_2_BIT}, // SERIAL_8O2 {USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_2_BIT}, // SERIAL_8O2
{USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_0_5_BIT}, // SERIAL_8N0_5 {USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_0_5_BIT}, // SERIAL_8N0_5
{USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_1_5_BIT}, // SERIAL_8N1_5 {USART_DATA_8BITS, USART_PARITY_NONE, USART_STOP_1_5_BIT}, // SERIAL_8N1_5
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_0_5_BIT}, // SERIAL_8E0_5 {USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_0_5_BIT}, // SERIAL_8E0_5
{USART_DATA_8BITS, USART_PARITY_EVEN, USART_STOP_1_5_BIT}, // SERIAL_8E1_5 {USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_1_5_BIT}, // SERIAL_8E1_5
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_0_5_BIT}, // SERIAL_8O0_5 {USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_0_5_BIT}, // SERIAL_8O0_5
{USART_DATA_8BITS, USART_PARITY_ODD, USART_STOP_1_5_BIT}, // SERIAL_8O1_5 {USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_1_5_BIT}, // SERIAL_8O1_5
{USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_1_BIT}, // SERIAL_9N1 {USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_1_BIT}, // SERIAL_9N1
{USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_2_BIT}, // SERIAL_9N2 {USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_2_BIT}, // SERIAL_9N2
{USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_1_BIT}, // SERIAL_9E1
{USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_2_BIT}, // SERIAL_9E2
{USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_1_BIT}, // SERIAL_9O1
{USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_2_BIT}, // SERIAL_9O2
{USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_0_5_BIT}, // SERIAL_9N0_5 {USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_0_5_BIT}, // SERIAL_9N0_5
{USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_1_5_BIT}, // SERIAL_9N1_5 {USART_DATA_9BITS, USART_PARITY_NONE, USART_STOP_1_5_BIT}, // SERIAL_9N1_5
{USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_0_5_BIT}, // SERIAL_9E0_5
{USART_DATA_9BITS, USART_PARITY_EVEN, USART_STOP_1_5_BIT}, // SERIAL_9E1_5
{USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_0_5_BIT}, // SERIAL_9O0_5
{USART_DATA_9BITS, USART_PARITY_ODD, USART_STOP_1_5_BIT}, // SERIAL_9O1_5
}; };
/** /**
* @brief 串口对象构造函数 * @brief 串口对象构造函数

View File

@@ -29,6 +29,15 @@
typedef enum typedef enum
{ {
SERIAL_7E1,
SERIAL_7E2,
SERIAL_7O1,
SERIAL_7O2,
SERIAL_7E0_5,
SERIAL_7E1_5,
SERIAL_7O0_5,
SERIAL_7O1_5,
SERIAL_8N1, SERIAL_8N1,
SERIAL_8N2, SERIAL_8N2,
SERIAL_8E1, SERIAL_8E1,
@@ -44,16 +53,8 @@ typedef enum
SERIAL_9N1, SERIAL_9N1,
SERIAL_9N2, SERIAL_9N2,
SERIAL_9E1,
SERIAL_9E2,
SERIAL_9O1,
SERIAL_9O2,
SERIAL_9N0_5, SERIAL_9N0_5,
SERIAL_9N1_5, SERIAL_9N1_5,
SERIAL_9E0_5,
SERIAL_9E1_5,
SERIAL_9O0_5,
SERIAL_9O1_5,
} SERIAL_Config_t; } SERIAL_Config_t;
class HardwareSerial : public Stream class HardwareSerial : public Stream
@@ -134,14 +135,4 @@ extern HardwareSerial Serial4;
extern HardwareSerial Serial5; extern HardwareSerial Serial5;
#endif #endif
#if SERIAL_6_ENABLE
extern HardwareSerial Serial6;
#endif
#if SERIAL_7_ENABLE
extern HardwareSerial Serial7;
#endif
#if SERIAL_8_ENABLE
extern HardwareSerial Serial8;
#endif
#endif #endif

View File

@@ -294,22 +294,16 @@ extern "C" {
return len; return len;
} }
} }
#ifdef SUPPORTS_PRINTF
int Print::printf (const char *__restrict __format, ...) int Print::printf (const char *__restrict __format, ...)
{ {
// char printf_buff[PRINT_PRINTF_BUFFER_LENGTH]; char printf_buff[PRINT_PRINTF_BUFFER_LENGTH];
// va_list args;
// va_start(args, __format);
// int ret_status = vsnprintf(printf_buff, sizeof(printf_buff), __format, args);
// va_end(args);
// print(printf_buff);
// return ret_status;
FILE *__restrict __stream;
int ret_status = 0;
va_list args; va_list args;
va_start(args, __format); va_start(args, __format);
ret_status = vfprintf(__stream, __format, args); int ret_status = vsnprintf(printf_buff, sizeof(printf_buff), __format, args);
va_end(args); va_end(args);
print(printf_buff);
return ret_status; return ret_status;
} }
#endif

View File

@@ -100,9 +100,9 @@ public:
size_t println(double, int = 2); size_t println(double, int = 2);
size_t println(const Printable&); size_t println(const Printable&);
size_t println(void); size_t println(void);
#ifdef SUPPORTS_PRINTF
int printf(const char * format, ...); int printf(const char * format, ...);
#endif
virtual void flush() { /* Empty implementation for backward compatibility */ } virtual void flush() { /* Empty implementation for backward compatibility */ }
}; };

View File

@@ -12,7 +12,7 @@
{ {
"name": "AT32F403ACGU7 Core Board", "name": "AT32F403ACGU7 Core Board",
"architecture": "at32f403a", "architecture": "at32f403a",
"version": "0.0.7", "version": "0.0.8",
"category": "Contributed", "category": "Contributed",
"url": "https://github.com/WeActStudio/ArduinoCore-AT32F4/archive/refs/heads/main.zip", "url": "https://github.com/WeActStudio/ArduinoCore-AT32F4/archive/refs/heads/main.zip",
"archiveFileName": "ArduinoCore-AT32F4-main.zip", "archiveFileName": "ArduinoCore-AT32F4-main.zip",

View File

@@ -1,6 +1,6 @@
##==============================================## ##==============================================##
name=WeActStudio AT32F403A Boards name=WeActStudio AT32F403A Boards
version=0.0.7 version=0.0.8
##==============================================## ##==============================================##
####AT32 compile variables ####AT32 compile variables