Skip to content

Commit 17bf2af

Browse files
authored
Merge pull request adafruit#1607 from pewpew-game/pewpew10.x-4.x
Add support for PewPew 10.x boards
2 parents 1ba7610 + 263134d commit 17bf2af

File tree

19 files changed

+711
-4
lines changed

19 files changed

+711
-4
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,6 @@
9292
[submodule "tools/Tecate-bitmap-fonts"]
9393
path = tools/Tecate-bitmap-fonts
9494
url = https://github.com/Tecate/bitmap-fonts.git
95+
[submodule "frozen/pew-pewpew-standalone-10.x"]
96+
path = frozen/pew-pewpew-standalone-10.x
97+
url = https://github.com/pewpew-game/pew-pewpew-standalone-10.x.git

frozen/pew-pewpew-standalone-10.x

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
bool board_requests_safe_mode(void) {
33+
return false;
34+
}
35+
36+
void reset_board(void) {
37+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#define MICROPY_HW_BOARD_NAME "PewPew 10.2"
2+
#define MICROPY_HW_MCU_NAME "samd21e18"
3+
4+
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25)
5+
#define MICROPY_PORT_B (0)
6+
#define MICROPY_PORT_C (0)
7+
8+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
9+
10+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
11+
12+
13+
#define IGNORE_PIN_PB00 1
14+
#define IGNORE_PIN_PB01 1
15+
#define IGNORE_PIN_PB02 1
16+
#define IGNORE_PIN_PB03 1
17+
#define IGNORE_PIN_PB04 1
18+
#define IGNORE_PIN_PB05 1
19+
#define IGNORE_PIN_PB06 1
20+
#define IGNORE_PIN_PB07 1
21+
#define IGNORE_PIN_PB08 1
22+
#define IGNORE_PIN_PB09 1
23+
#define IGNORE_PIN_PB10 1
24+
#define IGNORE_PIN_PB11 1
25+
#define IGNORE_PIN_PB12 1
26+
#define IGNORE_PIN_PB13 1
27+
#define IGNORE_PIN_PB14 1
28+
#define IGNORE_PIN_PB15 1
29+
#define IGNORE_PIN_PB16 1
30+
#define IGNORE_PIN_PB17 1
31+
#define IGNORE_PIN_PB22 1
32+
#define IGNORE_PIN_PB23 1
33+
#define IGNORE_PIN_PB30 1
34+
#define IGNORE_PIN_PB31 1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
LD_FILE = boards/samd21x18-bootloader.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x801D
4+
USB_PRODUCT = "PewPew 10.2"
5+
USB_MANUFACTURER = "Radomir Dopieralski"
6+
7+
INTERNAL_FLASH_FILESYSTEM = 1
8+
LONGINT_IMPL = NONE
9+
10+
CHIP_VARIANT = SAMD21E18A
11+
CHIP_FAMILY = samd21
12+
13+
FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x
14+
15+
CIRCUITPY_PEW = 1
16+
CIRCUITPY_ANALOGIO = 1
17+
CIRCUITPY_MATH = 1
18+
CIRCUITPY_NEOPIXEL_WRITE = 1
19+
CIRCUITPY_RTC = 0
20+
CIRCUITPY_SAMD = 0
21+
CIRCUITPY_USB_MIDI = 0
22+
CIRCUITPY_SMALL_BUILD = 1
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
#include "supervisor/shared/board_busses.h"
4+
5+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
6+
{ MP_ROM_QSTR(MP_QSTR__R1), MP_ROM_PTR(&pin_PA05) },
7+
{ MP_ROM_QSTR(MP_QSTR__R2), MP_ROM_PTR(&pin_PA11) },
8+
{ MP_ROM_QSTR(MP_QSTR__R3), MP_ROM_PTR(&pin_PA28) },
9+
{ MP_ROM_QSTR(MP_QSTR__R4), MP_ROM_PTR(&pin_PA09) },
10+
{ MP_ROM_QSTR(MP_QSTR__R5), MP_ROM_PTR(&pin_PA16) },
11+
{ MP_ROM_QSTR(MP_QSTR__R6), MP_ROM_PTR(&pin_PA27) },
12+
{ MP_ROM_QSTR(MP_QSTR__R7), MP_ROM_PTR(&pin_PA17) },
13+
{ MP_ROM_QSTR(MP_QSTR__R8), MP_ROM_PTR(&pin_PA22) },
14+
15+
{ MP_ROM_QSTR(MP_QSTR__C8), MP_ROM_PTR(&pin_PA10) },
16+
{ MP_ROM_QSTR(MP_QSTR__C7), MP_ROM_PTR(&pin_PA18) },
17+
{ MP_ROM_QSTR(MP_QSTR__C6), MP_ROM_PTR(&pin_PA19) },
18+
{ MP_ROM_QSTR(MP_QSTR__C5), MP_ROM_PTR(&pin_PA06) },
19+
{ MP_ROM_QSTR(MP_QSTR__C4), MP_ROM_PTR(&pin_PA23) },
20+
{ MP_ROM_QSTR(MP_QSTR__C3), MP_ROM_PTR(&pin_PA07) },
21+
{ MP_ROM_QSTR(MP_QSTR__C2), MP_ROM_PTR(&pin_PA14) },
22+
{ MP_ROM_QSTR(MP_QSTR__C1), MP_ROM_PTR(&pin_PA15) },
23+
24+
{ MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA30) },
25+
{ MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_PA31) },
26+
{ MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PA00) },
27+
{ MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PA01) },
28+
{ MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PA02) },
29+
{ MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PA03) },
30+
{ MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA04) },
31+
32+
{ MP_ROM_QSTR(MP_QSTR__BUTTONS), MP_ROM_PTR(&pin_PA08) },
33+
34+
};
35+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/supervisor/port.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@
6868

6969
#include "tusb.h"
7070

71-
#ifdef CIRCUITPY_GAMEPAD_TICKS
71+
#if CIRCUITPY_GAMEPAD
7272
#include "shared-module/gamepad/__init__.h"
7373
#endif
74+
#include "shared-module/_pew/PewPew.h"
7475

7576
extern volatile bool mp_msc_enabled;
7677

@@ -222,9 +223,12 @@ void reset_port(void) {
222223

223224
reset_gclks();
224225

225-
#ifdef CIRCUITPY_GAMEPAD_TICKS
226+
#if CIRCUITPY_GAMEPAD
226227
gamepad_reset();
227228
#endif
229+
#if CIRCUITPY_PEW
230+
pew_reset();
231+
#endif
228232

229233
reset_event_system();
230234

ports/atmel-samd/timer_handler.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "timer_handler.h"
3131

3232
#include "common-hal/pulseio/PulseOut.h"
33+
#include "shared-module/_pew/PewPew.h"
3334

3435
static uint8_t tc_handler[TC_INST_NUM];
3536

@@ -44,8 +45,17 @@ void shared_timer_handler(bool is_tc, uint8_t index) {
4445
// Make sure to add the handler #define to timer_handler.h
4546
if (is_tc) {
4647
uint8_t handler = tc_handler[index];
47-
if (handler == TC_HANDLER_PULSEOUT) {
48-
pulseout_interrupt_handler(index);
48+
switch(handler) {
49+
case TC_HANDLER_PULSEOUT:
50+
pulseout_interrupt_handler(index);
51+
break;
52+
case TC_HANDLER_PEW:
53+
#if CIRCUITPY_PEW
54+
pewpew_interrupt_handler(index);
55+
#endif
56+
break;
57+
default:
58+
break;
4959
}
5060
}
5161
}

ports/atmel-samd/timer_handler.h

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

2929
#define TC_HANDLER_NO_INTERRUPT 0x0
3030
#define TC_HANDLER_PULSEOUT 0x1
31+
#define TC_HANDLER_PEW 0x2
3132

3233
void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler);
3334
void shared_timer_handler(bool is_tc, uint8_t index);

py/circuitpy_defns.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ endif
198198
ifeq ($(CIRCUITPY_USTACK),1)
199199
SRC_PATTERNS += ustack/%
200200
endif
201+
ifeq ($(CIRCUITPY_PEW),1)
202+
SRC_PATTERNS += _pew/%
203+
endif
201204

202205
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
203206
SRC_COMMON_HAL = \
@@ -318,6 +321,8 @@ $(filter $(SRC_PATTERNS), \
318321
terminalio/__init__.c \
319322
uheap/__init__.c \
320323
ustack/__init__.c \
324+
_pew/__init__.c \
325+
_pew/PewPew.c \
321326
)
322327

323328
ifeq ($(INTERNAL_LIBM),1)

0 commit comments

Comments
 (0)