Skip to content

Commit 3b1109c

Browse files
authored
Merge pull request #50 from tannewt/microcontroller
Introduce shared APIs: nativeio, microcontroller and board modules. These are the only hardware API on the atmel-samd port.
2 parents ceeac47 + ccbb5e8 commit 3b1109c

File tree

139 files changed

+5898
-2819
lines changed

Some content is hidden

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

139 files changed

+5898
-2819
lines changed

atmel-samd/Makefile

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ INC += -I.
3131
INC += -I..
3232
INC += -I../lib/mp-readline
3333
INC += -I../lib/timeutils
34-
INC += -Icommon-hal/modules/
3534
INC += -Iasf_conf/
3635
INC += -Iasf/common/boards/
3736
INC += -Iasf/common/services/sleepmgr/
@@ -79,7 +78,23 @@ CFLAGS_CORTEX_M0 = \
7978
-msoft-float \
8079
-mfloat-abi=soft \
8180
-fsingle-precision-constant \
81+
-fno-strict-aliasing \
8282
-Wdouble-promotion \
83+
-Wno-endif-labels \
84+
-Wstrict-prototypes \
85+
-Werror-implicit-function-declaration \
86+
-Wpointer-arith \
87+
-Wfloat-equal \
88+
-Wundef \
89+
-Wshadow \
90+
-Wwrite-strings \
91+
-Wsign-compare \
92+
-Wmissing-format-attribute \
93+
-Wno-deprecated-declarations \
94+
-Wpacked \
95+
-Wnested-externs \
96+
-Wunreachable-code \
97+
-Wcast-align \
8398
-D__SAMD21G18A__ \
8499
-DUSB_DEVICE_PRODUCT_ID=$(USB_PID) \
85100
-DUSB_DEVICE_VENDOR_ID=$(USB_VID) \
@@ -92,9 +107,15 @@ CFLAGS_CORTEX_M0 = \
92107
-DEXTINT_CALLBACK_MODE=true \
93108
-DUDD_ENABLE \
94109
-DUSART_CALLBACK_MODE=true \
110+
-DSPI_CALLBACK_MODE=false \
111+
-DI2C_MASTER_CALLBACK_MODE=false \
112+
-DDAC_CALLBACK_MODE=false \
113+
-DTCC_ASYNC=false \
114+
-DADC_CALLBACK_MODE=false \
95115
-DTC_ASYNC=true \
96-
-DUSB_DEVICE_LPM_SUPPORT
97-
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
116+
-DUSB_DEVICE_LPM_SUPPORT \
117+
--param max-inline-insns-single=500
118+
CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
98119

99120
#Debugging/Optimization
100121
# TODO(tannewt): Figure out what NDEBUG does. Adding it to the debug build
@@ -154,17 +175,10 @@ SRC_C = \
154175
builtin_open.c \
155176
fatfs_port.c \
156177
main.c \
157-
modmachine.c \
158-
modmachine_adc.c \
159-
modmachine_dac.c \
160-
modmachine_pin.c \
161-
modmachine_pwm.c \
162-
modneopixel_write.c \
163178
moduos.c \
164-
modutime.c \
165179
mphalport.c \
166-
pin_named_pins.c \
167-
samdneopixel.c \
180+
samd21_pins.c \
181+
neopixel_status.c \
168182
tick.c \
169183
$(FLASH_IMPL) \
170184
asf/common/services/sleepmgr/samd/sleepmgr.c \
@@ -178,7 +192,6 @@ SRC_C = \
178192
asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c \
179193
asf/sam0/utils/cmsis/samd21/source/system_samd21.c \
180194
asf/sam0/utils/syscalls/gcc/syscalls.c \
181-
boards/samd21_pins.c \
182195
boards/$(BOARD)/init.c \
183196
boards/$(BOARD)/pins.c \
184197
lib/fatfs/ff.c \
@@ -194,12 +207,19 @@ STM_SRC_C = $(addprefix stmhal/,\
194207
input.c \
195208
)
196209

197-
# TODO(tannewt): Use this sed line to extract the RST docs from these sources:
198-
# sed': sed -n 's+^//|++p' ../api/machine.c
199-
#
200-
# RST lines are prefixed with //|
201210
SRC_BINDINGS = \
202-
modules/machine.c
211+
board/__init__.c \
212+
microcontroller/__init__.c \
213+
microcontroller/Pin.c \
214+
nativeio/__init__.c \
215+
nativeio/AnalogIn.c \
216+
nativeio/AnalogOut.c \
217+
nativeio/DigitalInOut.c \
218+
nativeio/I2C.c \
219+
nativeio/PWMOut.c \
220+
nativeio/SPI.c \
221+
neopixel_write/__init__.c \
222+
time/__init__.c
203223

204224
SRC_BINDINGS_EXPANDED = $(addprefix shared-bindings/, $(SRC_BINDINGS)) \
205225
$(addprefix common-hal/, $(SRC_BINDINGS))

atmel-samd/autoreset.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
extern volatile bool reset_next_character;
3333

34-
void autoreset_tick();
34+
void autoreset_tick(void);
3535

36-
void autoreset_start();
37-
void autoreset_stop();
38-
void autoreset_enable();
39-
void autoreset_disable();
36+
void autoreset_start(void);
37+
void autoreset_stop(void);
38+
void autoreset_enable(void);
39+
void autoreset_disable(void);
4040

4141
#endif // __MICROPY_INCLUDED_ATMEL_SAMD_AUTORESET_H__

atmel-samd/boards/arduino_zero/conf_usb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);
8787

8888
//! Interface callback definition
8989
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
90-
extern bool mp_msc_enable();
90+
extern bool mp_msc_enable(void);
9191
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
92-
extern void mp_msc_disable();
92+
extern void mp_msc_disable(void);
9393

9494
//! Enable id string of interface to add an extra USB string
9595
#define UDI_MSC_STRING_ID 5

atmel-samd/boards/arduino_zero/mpconfigboard.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#define MICROPY_HW_LED_TX PIN_PA27
88
#define MICROPY_HW_LED_RX PIN_PB03
99

10-
#define MICROPY_HW_NEOPIXEL PIN_PB22
10+
#define MICROPY_HW_NEOPIXEL &pin_PB22
1111

1212
#define AUTORESET_DELAY_MS 500
13+
14+
#define FLASH_INCLUDE "internal_flash.h"

atmel-samd/boards/arduino_zero/pins.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#include "boards/samd21_pins.h"
1+
#include "shared-bindings/board/__init__.h"
22

3-
STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
3+
#include "samd21_pins.h"
4+
5+
STATIC const mp_map_elem_t board_global_dict_table[] = {
46
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), (mp_obj_t)&pin_PA02 },
57
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), (mp_obj_t)&pin_PB08 },
68
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), (mp_obj_t)&pin_PB09 },
@@ -27,4 +29,4 @@ STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
2729
{ MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), (mp_obj_t)&pin_PB10 },
2830
{ MP_OBJ_NEW_QSTR(MP_QSTR_MISO), (mp_obj_t)&pin_PA12 },
2931
};
30-
MP_DEFINE_CONST_DICT(pin_board_pins_locals_dict, pin_board_pins_locals_dict_table);
32+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

atmel-samd/boards/feather_m0_adalogger/conf_usb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);
8787

8888
//! Interface callback definition
8989
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
90-
extern bool mp_msc_enable();
90+
extern bool mp_msc_enable(void);
9191
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
92-
extern void mp_msc_disable();
92+
extern void mp_msc_disable(void);
9393

9494
//! Enable id string of interface to add an extra USB string
9595
#define UDI_MSC_STRING_ID 5

atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
#define MICROPY_HW_MCU_NAME "samd21g18"
88

99
#define AUTORESET_DELAY_MS 500
10+
11+
#define FLASH_INCLUDE "internal_flash.h"

atmel-samd/boards/feather_m0_adalogger/pins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "boards/samd21_pins.h"
1+
#include "samd21_pins.h"
22

3-
STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
3+
STATIC const mp_map_elem_t board_global_dict_table[] = {
44
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), (mp_obj_t)&pin_PA02 },
55
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), (mp_obj_t)&pin_PB08 },
66
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), (mp_obj_t)&pin_PB09 },
@@ -23,4 +23,4 @@ STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
2323
{ MP_OBJ_NEW_QSTR(MP_QSTR_D12), (mp_obj_t)&pin_PA19 },
2424
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), (mp_obj_t)&pin_PA17 },
2525
};
26-
MP_DEFINE_CONST_DICT(pin_board_pins_locals_dict, pin_board_pins_locals_dict_table);
26+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

atmel-samd/boards/feather_m0_basic/conf_usb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);
8787

8888
//! Interface callback definition
8989
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
90-
extern bool mp_msc_enable();
90+
extern bool mp_msc_enable(void);
9191
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
92-
extern void mp_msc_disable();
92+
extern void mp_msc_disable(void);
9393

9494
//! Enable id string of interface to add an extra USB string
9595
#define UDI_MSC_STRING_ID 5

atmel-samd/boards/feather_m0_basic/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
#define MICROPY_HW_MCU_NAME "samd21g18"
88

99
#define AUTORESET_DELAY_MS 500
10+
11+
#define FLASH_INCLUDE "internal_flash.h"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy