Skip to content

Commit a152ac1

Browse files
committed
Merge remote-tracking branch 'adafruit/master' into pybadge_revd
2 parents 34c8c66 + f115ec2 commit a152ac1

File tree

16 files changed

+250
-11
lines changed

16 files changed

+250
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ git:
2222
# just try to make the builds "about equal in run time"
2323
env:
2424
- TRAVIS_TESTS="unix docs translations website" TRAVIS_BOARDS="circuitplayground_express mini_sam_m4 grandcentral_m4_express pca10056 pca10059 feather_nrf52840_express makerdiary_nrf52840_mdk makerdiary_nrf52840_mdk_usb_dongle particle_boron particle_argon particle_xenon sparkfun_nrf52840_mini" TRAVIS_SDK=arm:nrf
25-
- TRAVIS_BOARDS="metro_m0_express metro_m4_express metro_m4_airlift_lite pirkey_m0 trellis_m4_express trinket_m0 sparkfun_lumidrive sparkfun_redboard_turbo" TRAVIS_SDK=arm
25+
- TRAVIS_BOARDS="metro_m0_express metro_m4_express metro_m4_airlift_lite pirkey_m0 trellis_m4_express trinket_m0 sparkfun_lumidrive sparkfun_redboard_turbo bast_pro_mini_m0" TRAVIS_SDK=arm
2626
- TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow sam32 uchip" TRAVIS_SDK=arm
2727
- TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300 arduino_mkrzero pewpew10" TRAVIS_SDK=arm
2828
- TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick pyportal sparkfun_samd21_mini sparkfun_samd21_dev pybadge" TRAVIS_SDK=arm

main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "lib/mp-readline/readline.h"
4444
#include "lib/utils/pyexec.h"
4545

46+
#include "background.h"
4647
#include "mpconfigboard.h"
4748
#include "shared-module/displayio/__init__.h"
4849
#include "supervisor/cpu.h"
@@ -89,6 +90,8 @@ void start_mp(supervisor_allocation* heap) {
8990
reset_status_led();
9091
autoreload_stop();
9192

93+
background_tasks_reset();
94+
9295
// Stack limit should be less than real stack size, so we have a chance
9396
// to recover from limit hit. (Limit is measured in bytes.)
9497
mp_stack_ctrl_init();

ports/atmel-samd/background.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,20 @@ volatile uint64_t last_finished_tick = 0;
4242

4343
bool stack_ok_so_far = true;
4444

45+
static bool running_background_tasks = false;
46+
47+
void background_tasks_reset(void) {
48+
running_background_tasks = false;
49+
}
50+
4551
void run_background_tasks(void) {
52+
// Don't call ourselves recursively.
53+
if (running_background_tasks) {
54+
return;
55+
}
4656
assert_heap_ok();
57+
running_background_tasks = true;
58+
4759
#if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51)
4860
audio_dma_background();
4961
#endif
@@ -56,6 +68,7 @@ void run_background_tasks(void) {
5668
#endif
5769
filesystem_background();
5870
usb_background();
71+
running_background_tasks = false;
5972
assert_heap_ok();
6073

6174
last_finished_tick = ticks_ms;

ports/atmel-samd/background.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <stdbool.h>
3131

32+
void background_tasks_reset(void);
3233
void run_background_tasks(void);
3334
void run_background_vm_tasks(void);
3435
bool background_tasks_ok(void);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "boards/board.h"
28+
29+
void board_init(void)
30+
{
31+
}
32+
33+
bool board_requests_safe_mode(void) {
34+
return false;
35+
}
36+
37+
void reset_board(void) {
38+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#define MICROPY_HW_BOARD_NAME "Electronic Cats Bast Pro Mini M0"
2+
#define MICROPY_HW_MCU_NAME "samd21e18"
3+
4+
#define MICROPY_PORT_A (0)
5+
#define MICROPY_PORT_B (0)
6+
#define MICROPY_PORT_C (0)
7+
8+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
9+
10+
#define DEFAULT_I2C_BUS_SCL (&pin_PA08)
11+
#define DEFAULT_I2C_BUS_SDA (&pin_PA09)
12+
13+
#define DEFAULT_SPI_BUS_SCK (&pin_PA17)
14+
#define DEFAULT_SPI_BUS_MOSI (&pin_PA16)
15+
#define DEFAULT_SPI_BUS_MISO (&pin_PA19)
16+
17+
#define DEFAULT_UART_BUS_RX (&pin_PA01)
18+
#define DEFAULT_UART_BUS_TX (&pin_PA00)
19+
20+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
21+
22+
#define IGNORE_PIN_PA03 1
23+
#define IGNORE_PIN_PA12 1
24+
#define IGNORE_PIN_PA13 1
25+
#define IGNORE_PIN_PA20 1
26+
#define IGNORE_PIN_PA21 1
27+
// USB is always used.
28+
#define IGNORE_PIN_PA24 1
29+
#define IGNORE_PIN_PA25 1
30+
#define IGNORE_PIN_PA30 1
31+
#define IGNORE_PIN_PA31 1
32+
#define IGNORE_PIN_PB01 1
33+
#define IGNORE_PIN_PB02 1
34+
#define IGNORE_PIN_PB03 1
35+
#define IGNORE_PIN_PB04 1
36+
#define IGNORE_PIN_PB05 1
37+
#define IGNORE_PIN_PB06 1
38+
#define IGNORE_PIN_PB07 1
39+
#define IGNORE_PIN_PB08 1
40+
#define IGNORE_PIN_PB09 1
41+
#define IGNORE_PIN_PB10 1
42+
#define IGNORE_PIN_PB11 1
43+
#define IGNORE_PIN_PB12 1
44+
#define IGNORE_PIN_PB13 1
45+
#define IGNORE_PIN_PB14 1
46+
#define IGNORE_PIN_PB15 1
47+
#define IGNORE_PIN_PB16 1
48+
#define IGNORE_PIN_PB17 1
49+
#define IGNORE_PIN_PB22 1
50+
#define IGNORE_PIN_PB23 1
51+
#define IGNORE_PIN_PB30 1
52+
#define IGNORE_PIN_PB31 1
53+
#define IGNORE_PIN_PB00 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
LD_FILE = boards/samd21x18-bootloader.ld
2+
USB_VID = 0xBAB3
3+
USB_PID = 0x1209
4+
USB_PRODUCT = "Bast Pro Mini M0"
5+
USB_MANUFACTURER = "Electronic Cats"
6+
7+
INTERNAL_FLASH_FILESYSTEM = 1
8+
LONGINT_IMPL = NONE
9+
CIRCUITPY_SMALL_BUILD = 1
10+
11+
CHIP_VARIANT = SAMD21E18A
12+
CHIP_FAMILY = samd21
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
4+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
5+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) },
6+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA05) },
7+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA10) },
8+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) },
9+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA09) },
10+
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA00) },
11+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA01) },
12+
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA01) },
13+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA00) },
14+
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA14) },
15+
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA23) },
16+
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA22) },
17+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) },
18+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA27) },
19+
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA28) },
20+
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) },
21+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) },
22+
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) },
23+
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) },
24+
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
25+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
26+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA11) },
27+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) },
28+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) },
29+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) },
30+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA16) },
31+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) },
32+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
33+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
34+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
35+
};
36+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@
3636
// USB is always used internally so skip the pin objects for it.
3737
#define IGNORE_PIN_PA24 1
3838
#define IGNORE_PIN_PA25 1
39+
40+
// Not connected
41+
#define IGNORE_PIN_PA13 1
42+
#define IGNORE_PIN_PA28 1

ports/atmel-samd/boards/pybadge/pins.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,59 @@
44
#include "shared-module/displayio/__init__.h"
55

66
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
7+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
8+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
79
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB08) },
810
{ MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB09) },
911
{ MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) },
1012
{ MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA06) },
13+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB01) },
14+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB04) },
15+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PB03) },
16+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PB02) },
1117

18+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB17) },
19+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB16) },
20+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB03) },
21+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB02) },
22+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA14) },
1223
{ MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA16) },
1324
{ MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA18) },
25+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB14) },
26+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA15) },
1427
{ MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA19) },
1528
{ MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA20) },
1629
{ MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA21) },
1730
{ MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) },
1831
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) },
1932

20-
{ MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) },
33+
// UART
34+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17) },
35+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16) },
2136

22-
{ MP_OBJ_NEW_QSTR(MP_QSTR_AVCC), MP_ROM_PTR(&pin_PA03) },
23-
{ MP_OBJ_NEW_QSTR(MP_QSTR_LEFT_DAC), MP_ROM_PTR(&pin_PA02) },
24-
{ MP_OBJ_NEW_QSTR(MP_QSTR_RIGHT_DAC), MP_ROM_PTR(&pin_PA05) },
37+
// I2C
38+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA12) },
39+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA13) },
2540

41+
// SPI
2642
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) },
43+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB22) },
44+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB23) },
45+
46+
// Special named pins
47+
{ MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) },
48+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_PB04) },
49+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_PB14) },
50+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_PA02) },
51+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_PA27) },
52+
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON_LATCH), MP_ROM_PTR(&pin_PB00) },
53+
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON_OUT), MP_ROM_PTR(&pin_PB30) },
54+
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON_CLOCK), MP_ROM_PTR(&pin_PB31) },
2755

56+
// TFT control pins
2857
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_LITE), MP_ROM_PTR(&pin_PA00) },
29-
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_PA12) },
30-
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_PA13) },
58+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_PB15) },
59+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_PB13) },
3160
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_RST), MP_ROM_PTR(&pin_PA01) },
3261
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_PB07) },
3362
{ MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_PB05) },

0 commit comments

Comments
 (0)