Set enable pin to high during boot

This commit is contained in:
ZodiusInfuser 2022-03-28 15:56:02 +01:00
parent af2862ead9
commit c2fb44b36c
3 changed files with 24 additions and 2 deletions

View File

@ -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;
#endif // PIMORONI_BADGER2040_SHARED

View File

@ -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
@ -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,
@ -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(

View File

@ -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
@ -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) },
@ -36,7 +37,7 @@ 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) },
@ -44,5 +45,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ 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);