-
Notifications
You must be signed in to change notification settings - Fork 59
cores: arduino: Bump to 0.53.1 #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
soburi
wants to merge
44
commits into
zephyrproject-rtos:next
Choose a base branch
from
soburi:bump_to_arduino_repo
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
555fe90
digitalPins: take into account boards without gpios
facchinm 16cf84d
main.cpp: support loading via llext
facchinm f95580c
Implement SerialUSB
facchinm 3e52834
Fixes for proper core compatibility
facchinm 390b391
temp_bugfix: make serialEventRun symbol appear if CDC is not defined
facchinm a1f06b4
Serial: fix long write()
facchinm 54e5bb0
Some Serial object fixes...
KurtE 49cda44
SerialX.flush() - now wait until TC Complete
KurtE 7484a35
core: prerequisites for ArduinoBLE
facchinm 91bbddb
core: add time related macros
facchinm c4497d5
analogWrite: implement DAC pins
facchinm 34a1681
new: add rewrites for c++17
facchinm c66a25d
Implement analogReadResolution
KurtE 67e9467
zephyrSerial.h - reduce compiler warnings
KurtE 07f37a3
USB: fix corner case when cdc_acm is in dt and CONFIG_CDC is disabled
facchinm ad1510f
enable static threads
mjs513 d83b997
Nano 33 BLE - enable the SPI1 sensors
KurtE ba941ee
Add call to initVariant in main move ble sense to variant.cpp
KurtE ca3d01f
TEMP: get rid of serialEvent
facchinm 4f28336
wip: linked build
facchinm 0ccfd9c
usb: start supporting USB_DEVICE_STACK_NEXT
facchinm 29fb2b9
SerialUSB: create SerialUSB object only if CONFIG_USB_CDC_ACM=y
facchinm cfedec3
cores/arduino: warning squash
pillo79 eccb689
If sketch is not connected to serial - dump serial output
KurtE a6636b4
Fix micros() for nano without breaking giga
KurtE 4cb21f8
serial: add missing include
facchinm d13d49a
SerialUSB: fix missing overload after #123
facchinm e9556b5
Arduino.h: fix DIGITAL_PIN_EXISTS macro to avoid comment expansion is…
pillo79 1cb92ea
linker: forcefully remove exceptions and pack sections
facchinm 1474d8a
loader: impl: add some libc/::std functions
facchinm 63e52b8
cores/arduino/abi: squash warning
pillo79 c2c5e5a
ZephyrCommon: allow boards without any ADC channel configured
facchinm 17916e1
make internal arduino_adc array static
facchinm 1139d7e
core: serial: fix availableForWrite()
silabs-bozont b1291bf
core: restore core-as-zephyr-module functionality
facchinm 206c7e0
misc: Format repo using clang-format.
iabdalkader 768cd06
unoq: implement analogReference
facchinm d1f2a24
core: add macro to find pins by node
sebromero 6fae725
cores: Remove redundant k_thread_start() calls for static threads.
iabdalkader c1dcf6c
nano_matter: add initial support for the Arduino Nano Matter
silabs-bozont 168bb07
static_build: fix bss initialization
facchinm dd24f6f
usb: refactor USBD_NEXT and implement 1200bps touch
facchinm ce8b0f4
core: implement weak loop hook
facchinm 8f375db
portentac33: add sleep to avoid dfu protocol error
pennam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright (c) 2024 Arduino SA | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <zephyrSerial.h> | ||
|
|
||
| #if defined(CONFIG_USB_DEVICE_STACK_NEXT) | ||
| #include <zephyr/usb/usbd.h> | ||
| extern "C" struct usbd_context *usbd_init_device(usbd_msg_cb_t msg_cb); | ||
| #endif | ||
|
|
||
| namespace arduino { | ||
|
|
||
| class SerialUSB_ : public ZephyrSerial { | ||
|
|
||
| public: | ||
| SerialUSB_(const struct device *dev) : ZephyrSerial(dev) { | ||
| } | ||
|
|
||
| void begin(unsigned long baudrate, uint16_t config); | ||
|
|
||
| void begin(unsigned long baudrate) { | ||
| begin(baudrate, SERIAL_8N1); | ||
| } | ||
|
|
||
| operator bool() override; | ||
| size_t write(const uint8_t *buffer, size_t size) override; | ||
|
|
||
| size_t write(const uint8_t data) override { | ||
| return write(&data, 1); | ||
| } | ||
|
|
||
| void flush() override; | ||
|
|
||
| protected: | ||
| uint32_t dtr = 0; | ||
| uint32_t baudrate; | ||
| static void baudChangeHandler(const struct device *dev, uint32_t rate); | ||
|
|
||
| private: | ||
| bool started = false; | ||
|
|
||
| #if defined(CONFIG_USB_DEVICE_STACK_NEXT) | ||
| struct usbd_context *_usbd; | ||
| int enable_usb_device_next(); | ||
| static void usbd_next_cb(struct usbd_context *const ctx, const struct usbd_msg *msg); | ||
| static int usb_disable(); | ||
| #endif | ||
| }; | ||
| } // namespace arduino | ||
|
|
||
| #if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && \ | ||
| (CONFIG_USB_CDC_ACM || CONFIG_USBD_CDC_ACM_CLASS)) | ||
| extern arduino::SerialUSB_ Serial; | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /* | ||
| * Copyright (c) 2024 Arduino SA | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <zephyr/devicetree.h> | ||
| #include <zephyr/drivers/uart.h> | ||
| #include <zephyr/drivers/uart/cdc_acm.h> | ||
| #include <zephyr/usb/usb_device.h> | ||
| #include <SerialUSB.h> | ||
|
|
||
| #if ((DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm)) && \ | ||
| (CONFIG_USB_CDC_ACM || CONFIG_USBD_CDC_ACM_CLASS)) | ||
| const struct device *const usb_dev = | ||
| DEVICE_DT_GET(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), cdc_acm, 0)); | ||
|
|
||
| void __attribute__((weak)) _on_1200_bps() { | ||
| NVIC_SystemReset(); | ||
| } | ||
|
|
||
| void arduino::SerialUSB_::baudChangeHandler(const struct device *dev, uint32_t rate) { | ||
| (void)dev; // unused | ||
| if (rate == 1200) { | ||
| usb_disable(); | ||
| _on_1200_bps(); | ||
| } | ||
| } | ||
|
|
||
| #if defined(CONFIG_USB_DEVICE_STACK_NEXT) | ||
| int arduino::SerialUSB_::usb_disable() { | ||
| // To avoid Cannot perform port reset: 1200-bps touch: setting DTR to OFF: protocol error | ||
| k_sleep(K_MSEC(100)); | ||
| return usbd_disable(Serial._usbd); | ||
| } | ||
|
|
||
| void arduino::SerialUSB_::usbd_next_cb(struct usbd_context *const ctx, const struct usbd_msg *msg) { | ||
| if (usbd_can_detect_vbus(ctx)) { | ||
| if (msg->type == USBD_MSG_VBUS_READY) { | ||
| usbd_enable(ctx); | ||
| } | ||
|
|
||
| if (msg->type == USBD_MSG_VBUS_REMOVED) { | ||
| usbd_disable(ctx); | ||
| } | ||
| } | ||
|
|
||
| if (msg->type == USBD_MSG_CDC_ACM_LINE_CODING) { | ||
| uint32_t baudrate; | ||
| uart_line_ctrl_get(Serial.uart, UART_LINE_CTRL_BAUD_RATE, &baudrate); | ||
| Serial.baudChangeHandler(nullptr, baudrate); | ||
| } | ||
| } | ||
|
|
||
| int arduino::SerialUSB_::enable_usb_device_next(void) { | ||
| int err; | ||
|
|
||
| _usbd = usbd_init_device(arduino::SerialUSB_::usbd_next_cb); | ||
| if (_usbd == NULL) { | ||
| return -ENODEV; | ||
| } | ||
|
|
||
| if (!usbd_can_detect_vbus(_usbd)) { | ||
| err = usbd_enable(_usbd); | ||
| if (err) { | ||
| return err; | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
| #endif /* defined(CONFIG_USB_DEVICE_STACK_NEXT) */ | ||
|
|
||
| void arduino::SerialUSB_::begin(unsigned long baudrate, uint16_t config) { | ||
| if (!started) { | ||
| #ifndef CONFIG_USB_DEVICE_STACK_NEXT | ||
| usb_enable(NULL); | ||
| #ifndef CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT | ||
| #warning "Can't read CDC baud change, please enable CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT" | ||
| #else | ||
| cdc_acm_dte_rate_callback_set(usb_dev, SerialUSB_::baudChangeHandler); | ||
| #endif | ||
| #else | ||
| enable_usb_device_next(); | ||
| #endif | ||
| ZephyrSerial::begin(baudrate, config); | ||
| started = true; | ||
| } | ||
| } | ||
|
|
||
| arduino::SerialUSB_::operator bool() { | ||
| uart_line_ctrl_get(uart, UART_LINE_CTRL_DTR, &dtr); | ||
| return dtr; | ||
| } | ||
|
|
||
| size_t arduino::SerialUSB_::write(const uint8_t *buffer, size_t size) { | ||
| if (!Serial) { | ||
| return 0; | ||
| } | ||
| return arduino::ZephyrSerial::write(buffer, size); | ||
| } | ||
|
|
||
| void arduino::SerialUSB_::flush() { | ||
| if (!Serial) { | ||
| return; | ||
| } | ||
| arduino::ZephyrSerial::flush(); | ||
| } | ||
soburi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| arduino::SerialUSB_ Serial(usb_dev); | ||
| #endif | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.