Skip to content

Commit 8f26d18

Browse files
committed
Blinking the LED works. Clocks should be set up correctly.
Everything works fine without USB being plugged in but faults (I think) when USB is plugged in. This is switched away from the USB code from the bootloader onto the USB code thats generated by Atmel Studio using the high level classes from ASF.
1 parent a5f6cb3 commit 8f26d18

File tree

343 files changed

+179350
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+179350
-50
lines changed

atmel-samd/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build-*/

atmel-samd/Makefile

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
include ../py/mkenv.mk
1+
# Select the board to build for: if not given on the command line,
2+
# then default to PYBV10.
3+
BOARD ?= feather_m0_ble
4+
ifeq ($(wildcard boards/$(BOARD)/.),)
5+
$(error Invalid BOARD specified)
6+
endif
27

3-
CROSS = 0
8+
9+
# If the build directory is not given, make it reflect the board name.
10+
BUILD ?= build-$(BOARD)
11+
12+
include ../py/mkenv.mk
13+
-include mpconfigport.mk
14+
include boards/$(BOARD)/mpconfigboard.mk
415

516
# qstr definitions (must come before including py.mk)
17+
# TODO(tannewt): Support friendly pin names like the stmhal implementations do.
18+
# Add $(BUILD)/pins_qstr.h $(BUILD)/modstm_qstr.h
619
QSTR_DEFS = qstrdefsport.h
720

21+
CROSS = 0
22+
823
# include py core make definitions
924
include ../py/py.mk
1025

@@ -14,13 +29,44 @@ endif
1429

1530
BOSSAC := /Users/tannewt/ArduinoCore-samd/tools/bossac_osx
1631

32+
33+
HAL_DIR=hal/$(MCU_SERIES)
34+
1735
INC += -I.
1836
INC += -I..
1937
INC += -I../lib/mp-readline
38+
INC += -Iasf/common/boards/
39+
INC += -Iasf/common/services/sleepmgr/
40+
INC += -Iasf/common/services/usb/
41+
INC += -Iasf/common/services/usb/class/cdc/
42+
INC += -Iasf/common/services/usb/class/cdc/device/
43+
INC += -Iasf/common/services/usb/udc/
44+
INC += -Iasf/common/utils
45+
INC += -Iasf/common2/services/delay/
46+
INC += $(addprefix -Iasf/sam0/,\
47+
drivers/extint/ \
48+
drivers/port \
49+
drivers/system \
50+
drivers/system/clock \
51+
drivers/system/clock/clock_samd21_r21_da \
52+
drivers/system/interrupt \
53+
drivers/system/interrupt/system_interrupt_samd21 \
54+
drivers/system/pinmux \
55+
drivers/system/power/power_sam_d_r \
56+
drivers/system/reset/reset_sam_d_r \
57+
drivers/usb/ \
58+
utils \
59+
utils/cmsis/samd21/include \
60+
utils/cmsis/samd21/source \
61+
utils/header_files \
62+
utils/preprocessor \
63+
)
64+
INC += -Iasf/thirdparty/CMSIS/Include
65+
INC += -Iboards/$(BOARD)/
2066
INC += -I$(BUILD)
2167

2268
ifeq ($(CROSS), 1)
23-
CFLAGS_CORTEX_M0 = -mthumb -mabi=aapcs-linux -mcpu=cortex-m0plus -fsingle-precision-constant -Wdouble-promotion -D__SAMD21G18A__
69+
CFLAGS_CORTEX_M0 = -mthumb -mabi=aapcs-linux -mcpu=cortex-m0plus -fsingle-precision-constant -Wdouble-promotion -D__SAMD21G18A__ -DUSB_DEVICE_PRODUCT_ID=0x024D -DUSB_DEVICE_VENDOR_ID=0x4123 -DBOARD=USER_BOARD -ffunction-sections -fdata-sections -fshort-enums -D ARM_MATH_CM0PLUS=true -DSYSTICK_MODE -DEXTINT_CALLBACK_MODE=true -DUDD_ENABLE -DUSART_CALLBACK_MODE=true -DUSB_DEVICE_LPM_SUPPORT
2470
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
2571
else
2672
CFLAGS = -m32 $(INC) -Wall -Werror -ansi -std=gnu99 $(COPT)
@@ -36,16 +82,34 @@ endif
3682
LIBS =
3783
ifeq ($(CROSS), 1)
3884
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
39-
LDFLAGS = -Lasf/thirdparty/CMSIS/Lib/GCC/ -L $(dir $(LIBGCC_FILE_NAME)) -nostdlib -T samd21.ld -Map=$@.map --cref
85+
LDFLAGS = -Lasf/thirdparty/CMSIS/Lib/GCC/ -L $(dir $(LIBGCC_FILE_NAME)) -nostdlib -T $(LD_FILE) -Map=$@.map --cref --gc-sections
4086
LIBS += -larm_cortexM0l_math -lgcc
4187
else
4288
LD = gcc
4389
LDFLAGS = -m32 -Wl,-Map=$@.map,--cref
4490
endif
4591

92+
93+
SRC_ASF = $(addprefix asf/sam0/,\
94+
drivers/port/port.c \
95+
drivers/system/clock/clock_samd21_r21_da/clock.c \
96+
drivers/system/clock/clock_samd21_r21_da/gclk.c \
97+
drivers/system/pinmux/pinmux.c \
98+
drivers/system/system.c \
99+
drivers/usb/stack_interface/usb_device_udd.c \
100+
drivers/usb/stack_interface/usb_dual.c \
101+
drivers/usb/usb_sam_d_r/usb.c \
102+
)
103+
46104
SRC_C = \
47105
main.c \
48-
uart_core.c \
106+
mphalport.c \
107+
asf/common/services/sleepmgr/samd/sleepmgr.c \
108+
asf/common/services/usb/class/cdc/device/udi_cdc.c \
109+
asf/common/services/usb/class/cdc/device/udi_cdc_desc.c \
110+
asf/common/services/usb/udc/udc.c \
111+
asf/common/utils/interrupt/interrupt_sam_nvic.c \
112+
asf/common2/services/delay/sam0/systick_counter.c \
49113
lib/utils/stdout_helpers.c \
50114
lib/utils/printf.c \
51115
lib/utils/pyexec.c \
@@ -54,6 +118,7 @@ SRC_C = \
54118
$(BUILD)/_frozen_mpy.c \
55119

56120
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
121+
OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o))
57122

58123
ifeq ($(CROSS), 1)
59124
all: $(BUILD)/firmware.bin

0 commit comments

Comments
 (0)