Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ports/raspberrypi/boards/pimoroni_badger2040/badger-shared.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef PIMORONI_BADGER2040_SHARED
#define PIMORONI_BADGER2040_SHARED

#include "shared-bindings/digitalio/DigitalInOut.h"

digitalio_digitalinout_obj_t enable_pin_obj;
Comment thread
dhalbert marked this conversation as resolved.
Outdated

#endif // PIMORONI_BADGER2040_SHARED
12 changes: 12 additions & 0 deletions ports/raspberrypi/boards/pimoroni_badger2040/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-module/displayio/__init__.h"
#include "supervisor/shared/board.h"
#include "badger-shared.h"

#define DELAY 0x80

Expand Down Expand Up @@ -258,10 +259,20 @@ const uint8_t display_stop_sequence[] = {
};

void board_init(void) {
// Drive the EN_3V3 pin high so the board stays awake on battery power
enable_pin_obj.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&enable_pin_obj, &pin_GPIO10);
common_hal_digitalio_digitalinout_switch_to_output(&enable_pin_obj, true, DRIVE_MODE_PUSH_PULL);

// Never reset
common_hal_digitalio_digitalinout_never_reset(&enable_pin_obj);

// Set up the SPI object used to control the display
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
common_hal_busio_spi_construct(spi, &pin_GPIO18, &pin_GPIO19, &pin_GPIO16, false);
common_hal_busio_spi_never_reset(spi);

// Set up the DisplayIO pin object
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
bus->base.type = &displayio_fourwire_type;
common_hal_displayio_fourwire_construct(bus,
Expand All @@ -273,6 +284,7 @@ void board_init(void) {
0, // Polarity
0); // Phase

// Set up the DisplayIO epaper object
displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display;
display->base.type = &displayio_epaperdisplay_type;
common_hal_displayio_epaperdisplay_construct(
Expand Down
6 changes: 4 additions & 2 deletions ports/raspberrypi/boards/pimoroni_badger2040/pins.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "shared-bindings/board/__init__.h"

#include "shared-module/displayio/__init__.h"
#include "badger-shared.h"

STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
Expand All @@ -15,7 +16,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) },

{ MP_ROM_QSTR(MP_QSTR_3V3_EN), MP_ROM_PTR(&pin_GPIO10) },
// { MP_ROM_QSTR(MP_QSTR_EN_3V3), MP_ROM_PTR(&pin_GPIO10) },

{ MP_ROM_QSTR(MP_QSTR_SW_DOWN), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_SW_A), MP_ROM_PTR(&pin_GPIO12) },
Expand All @@ -36,13 +37,14 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_USER_LED), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_INKY_BUSY), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_VREF_POWER), MP_ROM_PTR(&pin_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_1V2_REF), MP_ROM_PTR(&pin_GPIO28) },
{ MP_ROM_QSTR(MP_QSTR_REF_1V2), MP_ROM_PTR(&pin_GPIO28) },
{ MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO29) },

{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },

{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)},
{ MP_ROM_QSTR(MP_QSTR_ENABLE), MP_ROM_PTR(&enable_pin_obj)},
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);