Skip to content

Added support for Adafruit QtPy M0 board. #17

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
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ Set input clock divider and Turbo Mode (which uses a 96MHz instead of a 48Mhz in

```pwm.setClockDivider([1-255], [true, false]);```

**Initialise timer x, with prescaler, with steps (resolution), with fast aka single-slope PWM (or not -> double-slope PWM):**
**Initialize timer x, with prescaler, with steps (resolution), with fast aka single-slope PWM (or not -> double-slope PWM):**

```pwm.timer([0, 1, 2], [1, 2, 4, 8, 16, 64, 256, 1024], [2-MaxSteps], [true, false]);```

* For the Arduino Nano 33 IoT, you need to initialise timer 1 for pins 4 and 7, timer 0 for pins 5, 6, 8, and 12, and timer 2 for pins 11 and 13;
* For the Arduino Zero (untested), Adafruit Feather M0 (untested), and Adafruit Itsy Bitsy M0 you need to initialise timer 0 for pins 3, 4, 10 and 12, timer 1 for pins 8 and 9, and timer 2 for pins 11 and 13;
* For the Arduino MKR series (untested), you need to initialise timer 1 for pins 2 and 3, timer 0 for pins 4, 5, 6 and 7, and timer 2 for pins 8 and 9;
* For the Adafruit Trinket M0, you need to initialise timer 0 for pins 0 and 2, and timer 1 for pins 3 and 4.
* For the Arduino Nano 33 IoT, you need to initialize timer 1 for pins 4 and 7, timer 0 for pins 5, 6, 8, and 12, and timer 2 for pins 11 and 13;
* For the Arduino Zero (untested), Adafruit Feather M0 (untested), and Adafruit Itsy Bitsy M0 you need to initialize timer 0 for pins 3, 4, 10 and 12, timer 1 for pins 8 and 9, and timer 2 for pins 11 and 13;
* For the Arduino MKR series (untested), you need to initialize timer 1 for pins 2 and 3, timer 0 for pins 4, 5, 6 and 7, and timer 2 for pins 8 and 9;
* For the Adafruit Trinket M0, you need to initialize timer 0 for pins 0 and 2, and timer 1 for pins 3 and 4.
* For the Adafruit QtPy M0, you need to initialize timer 0 for pins 2, 3, 8, and 10. Timer 1 for pins 6, 7, and 9. Timer 2 for pins 4 and 5. **Note** that pins 7 & 9 share a capture and compare buffer (CCB1) so you can't get different PWM duty cycles from them at the same time.

MaxSteps is 0xFFFFFF for (24-bits) timers 0 and 1, and 0xFFFF for (16 bits) timer 2.

Expand Down
15 changes: 15 additions & 0 deletions src/SAMD21turboPWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ static const PinLookup pinTable[] = {
{ 4, PORTA, 6, 1, &REG_TCC1_CCB0, PORT_PMUX_PMUXE_E}
//Table end

#elif defined (ADAFRUIT_QTPY_M0)
//Table begin
{-1, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0},
{ 2, PORTA, 4, 0, &REG_TCC0_CCB0, PORT_PMUX_PMUXE_E},
{ 3, PORTA, 5, 0, &REG_TCC0_CCB1, PORT_PMUX_PMUXO_E},
{ 4, PORTA, 16, 2, &REG_TCC2_CCB0, PORT_PMUX_PMUXE_E},
{ 5, PORTA, 17, 2, &REG_TCC2_CCB1, PORT_PMUX_PMUXO_E},
{ 6, PORTA, 6, 1, &REG_TCC1_CCB0, PORT_PMUX_PMUXE_E},
{ 7, PORTA, 7, 1, &REG_TCC1_CCB1, PORT_PMUX_PMUXO_E},
{ 8, PORTA, 11, 0, &REG_TCC0_CCB3, PORT_PMUX_PMUXO_F}, // alt timer
{ 9, PORTA, 9, 1, &REG_TCC1_CCB1, PORT_PMUX_PMUXO_F}, // alt timer
{10, PORTA, 10, 0, &REG_TCC0_CCB2, PORT_PMUX_PMUXE_F} // alt timer
//Table end

#else
#error Board not supported by Turbo PWM Library
#endif
Expand Down