mirror of
https://github.com/WeActStudio/ArduinoCore-AT32F4.git
synced 2026-05-21 09:22:01 +00:00
Serial port to rectify odd and even check problems
This commit is contained in:
@@ -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 串口对象构造函数
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,58 @@
|
|||||||
/*
|
// base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
|
||||||
Blink
|
// enable or disable GxEPD2_GFX base class
|
||||||
|
#define ENABLE_GxEPD2_GFX 0
|
||||||
|
|
||||||
Turns an LED on for one second, then off for one second, repeatedly.
|
#include <GxEPD2_BW.h>
|
||||||
|
#include <GxEPD2_3C.h>
|
||||||
|
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||||
|
|
||||||
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
|
// ESP32-C3 SS=7,SCL(SCK)=4,SDA(MOSI)=6,BUSY=3,RST=2,DC=1
|
||||||
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
|
GxEPD2_BW<GxEPD2_213_B74, GxEPD2_213_B74::HEIGHT> display(GxEPD2_213_B74(/*CS=5*/ SS, /*DC=*/ 1, /*RST=*/ 2, /*BUSY=*/ 3)); // GDEM0213B74 122x250, SSD1680
|
||||||
the correct LED pin independent of which board is used.
|
//GxEPD2_3C<GxEPD2_213_Z98c, GxEPD2_213_Z98c::HEIGHT> display(GxEPD2_213_Z98c(/*CS=5*/ SS, /*DC=*/ 1, /*RST=*/ 2, /*BUSY=*/ 3)); // GDEY0213Z98 122x250, SSD1680
|
||||||
If you want to know what pin the on-board LED is connected to on your Arduino
|
|
||||||
model, check the Technical Specs of your board at:
|
|
||||||
https://www.arduino.cc/en/Main/Products
|
|
||||||
|
|
||||||
modified 8 May 2014
|
void setup()
|
||||||
by Scott Fitzgerald
|
{
|
||||||
modified 2 Sep 2016
|
pinMode(8, OUTPUT);
|
||||||
by Arturo Guadalupi
|
digitalWrite(8, HIGH);
|
||||||
modified 8 Sep 2016
|
|
||||||
by Colby Newman
|
|
||||||
|
|
||||||
This example code is in the public domain.
|
display.init(115200,true,50,false);
|
||||||
|
helloWorld();
|
||||||
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
|
display.hibernate();
|
||||||
*/
|
}
|
||||||
|
|
||||||
// the setup function runs once when you press reset or power the board
|
const char HelloWorld[] = "Hello World!";
|
||||||
void setup() {
|
const char HelloWeACtStudio[] = "Hello WeAct Studio!";
|
||||||
// initialize digital pin LED_BUILTIN as an output.
|
|
||||||
pinMode(PC13, OUTPUT);
|
void helloWorld()
|
||||||
|
{
|
||||||
|
display.setRotation(1);
|
||||||
|
display.setFont(&FreeMonoBold9pt7b);
|
||||||
|
display.setTextColor(GxEPD_BLACK);
|
||||||
|
int16_t tbx, tby; uint16_t tbw, tbh;
|
||||||
|
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||||
|
// center the bounding box by transposition of the origin:
|
||||||
|
uint16_t x = ((display.width() - tbw) / 2) - tbx;
|
||||||
|
uint16_t y = ((display.height() - tbh) / 2) - tby;
|
||||||
|
display.setFullWindow();
|
||||||
|
display.firstPage();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
display.fillScreen(GxEPD_WHITE);
|
||||||
|
display.setCursor(x, y-tbh);
|
||||||
|
display.print(HelloWorld);
|
||||||
|
display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
|
||||||
|
display.getTextBounds(HelloWeACtStudio, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||||
|
x = ((display.width() - tbw) / 2) - tbx;
|
||||||
|
display.setCursor(x, y+2*tbh);
|
||||||
|
display.print(HelloWeACtStudio);
|
||||||
|
}
|
||||||
|
while (display.nextPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// the loop function runs over and over again forever
|
|
||||||
void loop() {
|
void loop() {
|
||||||
digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)
|
// put your main code here, to run repeatedly:
|
||||||
delay(1000); // wait for a second
|
digitalWrite(8, HIGH);
|
||||||
digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
|
delay(1000);
|
||||||
delay(1000); // wait for a second
|
digitalWrite(8, LOW);
|
||||||
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user