-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds support for RP2040 based boards such as the Pico and the Pico W. I have tested this on a Pico W.
- Loading branch information
1 parent
c780331
commit d9e0410
Showing
9 changed files
with
143 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -26,9 +26,9 @@ jobs: | |
|
||
# define each specific configuration | ||
include: | ||
|
||
# if the current configuration contains the parameter "config-name" and it is equal to "esp8266-v2", | ||
# add the following parameters to this configuration. If board-type is never matched, | ||
# add the following parameters to this configuration. If board-type is never matched, | ||
# a new singular configuration is created | ||
- config-name: esp8266-v2 | ||
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json | ||
|
@@ -65,6 +65,12 @@ jobs: | |
arduino-boards-fqbn: arduino:samd:nano_33_iot | ||
sketches-exclude: 3_dimmable_light_5_light, 5_dimmable_manager_n_lights | ||
|
||
- config-name: rpi-pico | ||
platform-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json | ||
arduino-platform: pico:[email protected] | ||
arduino-boards-fqbn: pico:rp2040:rpipico | ||
sketches-exclude: 3_dimmable_light_5_light, 5_dimmable_manager_n_lights | ||
|
||
# Do not cancel all jobs / architectures if one job fails | ||
fail-fast: false | ||
|
||
|
This file contains 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 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 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 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 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 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,53 @@ | ||
/*************************************************************************** | ||
* This file is part of Dimmable Light for Arduino, a library to * | ||
* control dimmers. * | ||
* * | ||
* Copyright (C) 2018-2022 Fabiano Riccardi * | ||
* * | ||
* Dimmable Light for Arduino is free software; you can redistribute * | ||
* it and/or modify it under the terms of the GNU Lesser General Public * | ||
* License as published by the Free Software Foundation; either * | ||
* version 2.1 of the License, or (at your option) any later version. * | ||
* * | ||
* This library is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | ||
* Lesser General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, see <http://www.gnu.org/licenses/> * | ||
***************************************************************************/ | ||
|
||
#ifdef ARDUINO_ARCH_RP2040 | ||
|
||
#include "hw_timer_rp2040.h" | ||
#include <Arduino.h> | ||
|
||
static void (*timer_callback)() = nullptr; | ||
static alarm_id_t alarm_id; | ||
static alarm_pool_t *alarm_pool; | ||
|
||
void timerBegin() { | ||
alarm_pool = alarm_pool_get_default(); | ||
} | ||
|
||
void timerSetCallback(void (*callback)()) { | ||
timer_callback = callback; | ||
} | ||
|
||
void timerStart(uint16_t t) { | ||
if (t <= 1) { return; } | ||
|
||
if (alarm_id) { cancel_alarm(alarm_id); } | ||
|
||
alarm_id = alarm_pool_add_alarm_in_us( | ||
alarm_pool, t, | ||
[](alarm_id_t id, void *user_data) -> int64_t { | ||
timer_callback(); | ||
alarm_id = 0; | ||
return 0; // Do not reschedule alarm | ||
}, | ||
NULL, true); | ||
} | ||
|
||
#endif // END ARDUINO_ARCH_RP2040 |
This file contains 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,47 @@ | ||
/*************************************************************************** | ||
* This file is part of Dimmable Light for Arduino, a library to * | ||
* control dimmers. * | ||
* * | ||
* Copyright (C) 2018-2022 Fabiano Riccardi * | ||
* * | ||
* Dimmable Light for Arduino is free software; you can redistribute * | ||
* it and/or modify it under the terms of the GNU Lesser General Public * | ||
* License as published by the Free Software Foundation; either * | ||
* version 2.1 of the License, or (at your option) any later version. * | ||
* * | ||
* This library is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | ||
* Lesser General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, see <http://www.gnu.org/licenses/> * | ||
***************************************************************************/ | ||
|
||
#ifdef ARDUINO_ARCH_RP2040 | ||
|
||
#ifndef HW_RP2040_H | ||
#define HW_RP2040_H | ||
|
||
#include <stdint.h> | ||
|
||
/** | ||
* Initialize the timer. | ||
*/ | ||
void timerBegin(); | ||
|
||
/** | ||
* Set callback function on timer triggers | ||
*/ | ||
void timerSetCallback(void (*callback)()); | ||
|
||
/** | ||
* Start the timer to trigger after the specified number of ticks. | ||
* | ||
* NOTE: 0 or 1 values are not accepted | ||
*/ | ||
void timerStart(uint16_t tick); | ||
|
||
#endif // HW_TIMER_SAMD_H | ||
|
||
#endif // ARDUINO_ARCH_SAMD |
This file contains 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