Skip to content

Commit b608bc9

Browse files
authored
Merge pull request #958 from Paciente8159/samd21-pwm-fixes
Fixed SAMD21 PWM configs
2 parents a2102dc + 33f6b13 commit b608bc9

5 files changed

Lines changed: 296 additions & 750 deletions

File tree

boards/zeroUSB_AU.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "flash_with_bootloader.ld"
5+
},
6+
"core": "arduino",
7+
"cpu": "cortex-m0plus",
8+
"extra_flags": "-DARDUINO_SAMD_ZERO -D__SAMD21G18AU__",
9+
"f_cpu": "48000000L",
10+
"hwids": [
11+
[
12+
"0x2341",
13+
"0x804D"
14+
],
15+
[
16+
"0x2341",
17+
"0x004D"
18+
],
19+
[
20+
"0x2341",
21+
"0x824D"
22+
]
23+
],
24+
"mcu": "samd21g18au",
25+
"usb_product": "Arduino Zero",
26+
"variant": "arduino_zero"
27+
},
28+
"debug": {
29+
"jlink_device": "ATSAMD21G18",
30+
"onboard_tools": [
31+
"cmsis-dap"
32+
],
33+
"openocd_chipname": "at91samd21g18",
34+
"openocd_target": "at91samdXX",
35+
"svd_path": "ATSAMD21G18A.svd"
36+
},
37+
"frameworks": [
38+
"arduino"
39+
],
40+
"name": "Arduino Zero (USB Native Port)",
41+
"upload": {
42+
"disable_flushing": true,
43+
"maximum_ram_size": 32768,
44+
"maximum_size": 262144,
45+
"native_usb": true,
46+
"offset_address": "0x2000",
47+
"protocol": "sam-ba",
48+
"protocols": [
49+
"sam-ba",
50+
"blackmagic",
51+
"jlink",
52+
"atmel-ice",
53+
"cmsis-dap"
54+
],
55+
"require_upload_port": true,
56+
"use_1200bps_touch": true,
57+
"wait_for_upload_port": true
58+
},
59+
"url": "https://www.arduino.cc/en/Main/ArduinoBoardZero",
60+
"vendor": "Arduino"
61+
}

docs/mcumap_gen.xlsx

-2.98 KB
Binary file not shown.

uCNC/src/hal/boards/samd21/samd21.ini

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
[common_samd21]
66
platform = atmelsam
7-
board = zeroUSB
87
build_flags = ${env.build_flags} -std=gnu99 -Wall -fdata-sections -ffunction-sections -fno-exceptions -Wl,--gc-sections -nostdlib -fno-exceptions
98
lib_deps =
109
${env.lib_deps}
1110
https://github.com/Paciente8159/uCNC-tinyusb.git#v0.15.4
1211
platform_packages = platformio/tool-openocd
13-
build_type = debug
12+
; build_type = debug
1413
debug_build_flags = -Og -g3 -ggdb3 -gdwarf-2
1514
debug_tool = custom
1615
debug_server =
@@ -30,12 +29,16 @@ debug_init_cmds =
3029

3130
[env:SAMD21-Wemos-M0]
3231
extends = common_samd21
32+
board = zeroUSB_AU
3333
build_flags = ${common_samd21.build_flags} -D BOARDMAP=\"src/hal/boards/samd21/boardmap_mzero.h\"
34+
board_build.mcu = samd21g18au
35+
; upload_protocol = cmsis-dap
3436
board_build.offset = 0x2000
3537
board_upload.offset_address = 0x00002000
3638

3739
[env:SAMD21-Arduino-Zero]
3840
extends = common_samd21
41+
board = zeroUSB
3942
build_flags = ${common_samd21.build_flags} -D BOARDMAP=\"src/hal/boards/samd21/boardmap_zero.h\"
4043
board_build.offset = 0x4000
4144
board_upload.offset_address = 0x00004000

uCNC/src/hal/mcus/samd21/mcu_samd21.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ void MCU_ITP_ISR(void)
188188
#if (ITP_TIMER < 3)
189189
if (ITP_REG->INTFLAG.bit.MC0)
190190
{
191-
ITP_REG->INTFLAG.bit.MC0 = 1;
191+
ITP_REG->INTFLAG.reg = TCC_INTFLAG_MC0;
192192
#else
193193
if (ITP_REG->COUNT16.INTFLAG.bit.MC0)
194194
{
195-
ITP_REG->COUNT16.INTFLAG.bit.MC0 = 1;
195+
ITP_REG->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0;
196196
#endif
197197
if (!resetstep)
198198
{
@@ -216,7 +216,7 @@ void mcu_com_isr()
216216

217217
if (COM_UART->USART.INTFLAG.bit.RXC && COM_UART->USART.INTENSET.bit.RXC)
218218
{
219-
COM_UART->USART.INTFLAG.bit.RXC = 1;
219+
COM_UART->USART.INTFLAG.reg = SERCOM_USART_INTFLAG_RXC;
220220
uint8_t c = (0xff & COM_INREG);
221221
#if !defined(DETACH_UART_FROM_MAIN_PROTOCOL)
222222
if (mcu_com_rx_cb(c))
@@ -256,7 +256,7 @@ void mcu_com2_isr()
256256
{
257257
if (COM2_UART->USART.INTFLAG.bit.RXC && COM2_UART->USART.INTENSET.bit.RXC)
258258
{
259-
COM2_UART->USART.INTFLAG.bit.RXC = 1;
259+
COM2_UART->USART.INTFLAG.reg = SERCOM_USART_INTFLAG_RXC;
260260
uint8_t c = (0xff & COM2_INREG);
261261
#if !defined(DETACH_UART2_FROM_MAIN_PROTOCOL)
262262
if (mcu_com_rx_cb(c))
@@ -510,11 +510,11 @@ void MCU_SERVO_ISR(void)
510510
#if (SERVO_TIMER < 3)
511511
if (SERVO_REG->INTFLAG.bit.MC0)
512512
{
513-
SERVO_REG->INTFLAG.bit.MC0 = 1;
513+
SERVO_REG->INTFLAG.reg = TCC_INTFLAG_MC0;
514514
#else
515515
if (SERVO_REG->COUNT16.INTFLAG.bit.MC0)
516516
{
517-
SERVO_REG->COUNT16.INTFLAG.bit.MC0 = 1;
517+
SERVO_REG->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0;
518518
#endif
519519
mcu_clear_servos();
520520
NVIC_DisableIRQ(SERVO_IRQ);
@@ -2106,15 +2106,15 @@ void MCU_ONESHOT_ISR(void)
21062106
;
21072107
if (ONESHOT_REG->INTFLAG.bit.MC0)
21082108
{
2109-
ONESHOT_REG->INTFLAG.bit.MC0 = 1;
2109+
ONESHOT_REG->INTFLAG.reg = TCC_INTFLAG_MC0;
21102110
#else
21112111
ONESHOT_REG->COUNT16.INTENSET.bit.MC0 = 0;
21122112
ONESHOT_REG->COUNT16.CTRLA.bit.ENABLE = 0;
21132113
while (ONESHOT_REG->COUNT16.STATUS.bit.SYNCBUSY)
21142114
;
21152115
if (ONESHOT_REG->COUNT16.INTFLAG.bit.MC0)
21162116
{
2117-
ONESHOT_REG->COUNT16.INTFLAG.bit.MC0 = 1;
2117+
ONESHOT_REG->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0;
21182118
#endif
21192119
}
21202120

0 commit comments

Comments
 (0)