Skip to content

Commit 972b038

Browse files
committed
Merge branch 'master' into circuitpython-nickzoic-716-pulseio-esp8266
2 parents 6af1fba + b2d98ed commit 972b038

File tree

42 files changed

+826
-79
lines changed

Some content is hidden

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

42 files changed

+826
-79
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
- TRAVIS_BOARD=feather_m0_rfm69
1313
- TRAVIS_BOARD=feather_m0_rfm9x
1414
- TRAVIS_BOARD=feather_m0_express
15+
- TRAVIS_BOARD=feather_m0_express_crickit
1516
- TRAVIS_BOARD=feather_m4_express
1617
- TRAVIS_BOARD=itsybitsy_m0_express
1718
- TRAVIS_BOARD=itsybitsy_m4_express

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Differences from `MicroPython <https://github.com/micropython/micropython>`__
104104
CircuitPython:
105105

106106
- includes a ports for MicroChip SAMD21 (Commonly known as M0 in Adafruit
107-
product names and SAMD51 (M4).
107+
product names) and SAMD51 (M4).
108108
- supports only SAMD21, SAMD51, and ESP8266 ports. An nRF port is under
109109
development.
110110
- tracks MicroPython's releases (not master).

main.c

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -233,40 +233,7 @@ bool start_mp(safe_mode_t safe_mode) {
233233
}
234234
}
235235

236-
int __attribute__((used)) main(void) {
237-
// initialise the cpu and peripherals
238-
safe_mode_t safe_mode = port_init();
239-
240-
rgb_led_status_init();
241-
242-
// Stack limit should be less than real stack size, so we have a chance
243-
// to recover from limit hit. (Limit is measured in bytes.)
244-
mp_stack_ctrl_init();
245-
mp_stack_set_limit((char*)&_estack - (char*)&_ebss - 1024);
246-
247-
#if MICROPY_MAX_STACK_USAGE
248-
// _ezero (same as _ebss) is an int, so start 4 bytes above it.
249-
mp_stack_set_bottom(&_ezero + 1);
250-
mp_stack_fill_with_sentinel();
251-
#endif
252-
253-
// Create a new filesystem only if we're not in a safe mode.
254-
// A power brownout here could make it appear as if there's
255-
// no SPI flash filesystem, and we might erase the existing one.
256-
filesystem_init(safe_mode == NO_SAFE_MODE, false);
257-
258-
// Reset everything and prep MicroPython to run boot.py.
259-
reset_port();
260-
reset_board();
261-
reset_mp();
262-
263-
// Turn on autoreload by default but before boot.py in case it wants to change it.
264-
autoreload_enable();
265-
266-
// By default our internal flash is readonly to local python code and
267-
// writable over USB. Set it here so that boot.py can change it.
268-
filesystem_writable_by_python(false);
269-
236+
void run_boot_py(safe_mode_t safe_mode) {
270237
// If not in safe mode, run boot before initing USB and capture output in a
271238
// file.
272239
if (filesystem_present() && safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL) {
@@ -338,6 +305,43 @@ int __attribute__((used)) main(void) {
338305
reset_port();
339306
reset_mp();
340307
}
308+
}
309+
310+
int __attribute__((used)) main(void) {
311+
// initialise the cpu and peripherals
312+
safe_mode_t safe_mode = port_init();
313+
314+
rgb_led_status_init();
315+
316+
// Stack limit should be less than real stack size, so we have a chance
317+
// to recover from limit hit. (Limit is measured in bytes.)
318+
mp_stack_set_top((char*)&_estack);
319+
mp_stack_set_limit((char*)&_estack - (char*)&_ebss - 1024);
320+
321+
#if MICROPY_MAX_STACK_USAGE
322+
// _ezero (same as _ebss) is an int, so start 4 bytes above it.
323+
mp_stack_set_bottom(&_ezero + 1);
324+
mp_stack_fill_with_sentinel();
325+
#endif
326+
327+
// Create a new filesystem only if we're not in a safe mode.
328+
// A power brownout here could make it appear as if there's
329+
// no SPI flash filesystem, and we might erase the existing one.
330+
filesystem_init(safe_mode == NO_SAFE_MODE, false);
331+
332+
// Reset everything and prep MicroPython to run boot.py.
333+
reset_port();
334+
reset_board();
335+
reset_mp();
336+
337+
// Turn on autoreload by default but before boot.py in case it wants to change it.
338+
autoreload_enable();
339+
340+
// By default our internal flash is readonly to local python code and
341+
// writable over USB. Set it here so that boot.py can change it.
342+
filesystem_writable_by_python(false);
343+
344+
run_boot_py(safe_mode);
341345

342346
// Start serial and HID after giving boot.py a chance to tweak behavior.
343347
serial_init();

ports/atmel-samd/background.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@
2626
#include "background.h"
2727

2828
#include "audio_dma.h"
29+
#include "tick.h"
2930
#include "usb.h"
3031
#include "usb_mass_storage.h"
3132

33+
volatile uint64_t last_finished_tick = 0;
34+
3235
void run_background_tasks(void) {
3336
audio_dma_background();
3437
usb_msc_background();
3538
usb_cdc_background();
39+
last_finished_tick = ticks_ms;
40+
}
41+
42+
bool background_tasks_ok(void) {
43+
return ticks_ms - last_finished_tick < 1000;
3644
}

ports/atmel-samd/background.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H
2828
#define MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H
2929

30+
#include <stdbool.h>
31+
3032
void run_background_tasks(void);
33+
bool background_tasks_ok(void);
3134

3235
#endif // MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H

ports/atmel-samd/bindings/samd/Clock.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,7 @@
4747
STATIC void samd_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
4848
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
4949

50-
mp_printf(print, "%q.%q.%s(", MP_QSTR_samd, MP_QSTR_clock, self->name);
51-
if (clock_get_enabled(self->type, self->index)) {
52-
mp_printf(print, "frequency=%u", clock_get_frequency(self->type, self->index));
53-
uint32_t calibration = clock_get_calibration(self->type, self->index);
54-
if (calibration) {
55-
mp_printf(print, ", calibration=%u", calibration);
56-
}
57-
}
58-
mp_printf(print, ")");
50+
mp_printf(print, "%q.%q.%q", MP_QSTR_samd, MP_QSTR_clock, self->name);
5951
}
6052

6153
//| .. attribute:: enabled

ports/atmel-samd/bindings/samd/Clock.h

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

3232
typedef struct {
3333
mp_obj_base_t base;
34-
const char *name;
34+
qstr name;
3535
uint8_t type;
3636
uint8_t index;
3737
} samd_clock_obj_t;
3838

3939
#define CLOCK(_name, _type, _index) \
4040
const samd_clock_obj_t clock_ ## _name = { \
4141
{ &samd_clock_type }, \
42-
.name = #_name, \
42+
.name = MP_QSTR_ ## _name, \
4343
.type = _type, \
4444
.index = _index, \
4545
}
4646

4747
#define CLOCK_SOURCE(_name) \
4848
const samd_clock_obj_t clock_ ## _name = { \
4949
{ &samd_clock_type }, \
50-
.name = #_name, \
50+
.name = MP_QSTR_ ## _name, \
5151
.type = 0, \
5252
.index = GCLK_SOURCE_ ## _name, \
5353
}
5454

5555
#define CLOCK_GCLK(_name) \
5656
const samd_clock_obj_t clock_ ## _name = { \
5757
{ &samd_clock_type }, \
58-
.name = #_name, \
58+
.name = MP_QSTR_ ## _name, \
5959
.type = 1, \
6060
.index = _name ## _GCLK_ID, \
6161
}
6262

6363
#define CLOCK_GCLK_(_name, _extra) \
6464
const samd_clock_obj_t clock_ ## _name ## _ ## _extra = { \
6565
{ &samd_clock_type }, \
66-
.name = #_name "_" #_extra, \
66+
.name = MP_QSTR_ ## _name ## _ ## _extra, \
6767
.type = 1, \
6868
.index = _name ## _GCLK_ID_ ## _extra, \
6969
}

ports/atmel-samd/boards/arduino_zero/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424

2525
#define DEFAULT_UART_BUS_RX (&pin_PA11)
2626
#define DEFAULT_UART_BUS_TX (&pin_PA10)
27+
28+
// USB is always used internally so skip the pin objects for it.
29+
#define IGNORE_PIN_PA24 1
30+
#define IGNORE_PIN_PA25 1

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@
6868

6969
#define DEFAULT_UART_BUS_RX (&pin_PB09)
7070
#define DEFAULT_UART_BUS_TX (&pin_PB08)
71+
72+
// USB is always used internally so skip the pin objects for it.
73+
#define IGNORE_PIN_PA24 1
74+
#define IGNORE_PIN_PA25 1

ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@
7171

7272
#define DEFAULT_UART_BUS_RX (&pin_PB09)
7373
#define DEFAULT_UART_BUS_TX (&pin_PB08)
74+
75+
// USB is always used internally so skip the pin objects for it.
76+
#define IGNORE_PIN_PA24 1
77+
#define IGNORE_PIN_PA25 1

0 commit comments

Comments
 (0)