Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94f7ac2

Browse files
committed
[Generic Serial] Add SerialUSB
If USB CDC is enabled then the generic "Serial" used will be SerialUSBelse this is the HardwareSerial if one is defined.If Serial is defined before (build_opt.h, variant.h)then this is the one used.ISO for generic "serialEvent".Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent9a234ee commit94f7ac2

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

‎cores/arduino/USBSerial.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern __IO uint32_t UserRxBufPtrIn;
3737
extern __IOuint32_t UserRxBufPtrOut;
3838

3939
USBSerial SerialUSB;
40+
voidserialEventUSB() __attribute__((weak));
4041

4142
voidUSBSerial::begin(uint32_t/* baud_count*/) {
4243
// uart config is ignored in USB-CDC

‎cores/arduino/WSerial.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ void serialEventRun(void)
3535
#if defined(HAVE_HWSERIALLP1)
3636
if (serialEventLP1 && SerialLP1.available())serialEventLP1();
3737
#endif
38+
#if defined(HAVE_SERIALUSB)
39+
if (serialEventUSB && SerialUSB.available())serialEventUSB();
40+
#endif
3841
}
3942

‎cores/arduino/WSerial.h‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,25 @@
33

44
#include"variant.h"
55
#include"HardwareSerial.h"
6+
#include"USBSerial.h"
67

7-
#if defined(HAL_UART_MODULE_ENABLED)
8+
#if defined (USBCON)&& defined(USBD_USE_CDC)
9+
#ifndefDISABLE_GENERIC_SERIALUSB
10+
#defineENABLE_SERIALUSB
11+
#if !defined(Serial)
12+
#defineSerial SerialUSB
13+
#defineserialEvent serialEventUSB
14+
#endif
15+
#endif
16+
17+
#if defined(ENABLE_SERIALUSB)
18+
#defineHAVE_SERIALUSB
19+
#endif
20+
21+
externvoidserialEventUSB(void) __attribute__((weak));
22+
#endif/* USBCON && USBD_USE_CDC */
823

24+
#if defined(HAL_UART_MODULE_ENABLED)
925
#if !defined(HWSERIAL_NONE)&& defined(SERIAL_UART_INSTANCE)
1026
#ifSERIAL_UART_INSTANCE==0
1127
#defineENABLE_HWSERIALLP1
@@ -147,8 +163,8 @@ extern void serialEvent8(void) __attribute__((weak));
147163
externvoidserialEvent9(void) __attribute__((weak));
148164
externvoidserialEvent10(void) __attribute__((weak));
149165
externvoidserialEventLP1(void) __attribute__((weak));
150-
151166
#endif/* HAL_UART_MODULE_ENABLED */
167+
152168
externvoidserialEventRun(void) __attribute__((weak));
153169

154-
#endif// WIRING_SERIAL_H
170+
#endif/* WIRING_SERIAL_H */

‎cores/arduino/wiring.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
#ifdef__cplusplus
4444
#include"Tone.h"
45-
#include"USBSerial.h"
4645
#include"WCharacter.h"
4746
#include"WSerial.h"
4847
#include"WMath.h"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp