forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
initial board definition for inky frame 7.3 #7996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c49b00c
Initial bringup for inky frame 7.3
dearmash fc42dcc
Merge branch 'adafruit:main' into main
dearmash 8ad97cf
Merge branch 'adafruit:main' into main
dearmash 0513fb0
Update startup sequence to match Adafruit_CircuitPython_ACeP7In
dearmash f75340f
Merge branch 'adafruit:main' into main
dearmash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
205 changes: 205 additions & 0 deletions
205
ports/raspberrypi/boards/pimoroni_inky_frame_7_3/board.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
/* | ||
* This file is part of the MicroPython project, http://micropython.org/ | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2021 Scott Shawcroft for Adafruit Industries | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#include "supervisor/board.h" | ||
|
||
#include "mpconfigboard.h" | ||
#include "shared-bindings/board/__init__.h" | ||
#include "shared-bindings/busio/SPI.h" | ||
#include "shared-bindings/displayio/FourWire.h" | ||
#include "shared-bindings/microcontroller/Pin.h" | ||
#include "shared-bindings/time/__init__.h" | ||
#include "shared-module/displayio/__init__.h" | ||
#include "supervisor/shared/board.h" | ||
|
||
#define DELAY 0x80 | ||
|
||
// This is a 7.3" ACeP EInk. | ||
|
||
digitalio_digitalinout_obj_t enable_pin_obj; | ||
|
||
digitalio_digitalinout_obj_t sr_clock; | ||
digitalio_digitalinout_obj_t sr_data; | ||
digitalio_digitalinout_obj_t sr_latch; | ||
|
||
enum reg { | ||
PSR = 0x00, | ||
PWR = 0x01, | ||
POF = 0x02, | ||
PFS = 0x03, | ||
PON = 0x04, | ||
BTST1 = 0x05, | ||
BTST2 = 0x06, | ||
DSLP = 0x07, | ||
BTST3 = 0x08, | ||
DTM1 = 0x10, | ||
DSP = 0x11, | ||
DRF = 0x12, | ||
IPC = 0x13, | ||
PLL = 0x30, | ||
TSC = 0x40, | ||
TSE = 0x41, | ||
TSW = 0x42, | ||
TSR = 0x43, | ||
CDI = 0x50, | ||
LPD = 0x51, | ||
TCON = 0x60, | ||
TRES = 0x61, | ||
DAM = 0x65, | ||
REV = 0x70, | ||
FLG = 0x71, | ||
AMV = 0x80, | ||
VV = 0x81, | ||
VDCS = 0x82, | ||
T_VDCS = 0x84, | ||
AGID = 0x86, | ||
CMDH = 0xAA, | ||
CCSET =0xE0, | ||
PWS = 0xE3, | ||
TSSET = 0xE6 // E5 or E6 | ||
}; | ||
|
||
const uint8_t display_start_sequence[] = { | ||
CMDH, 6, 0x49, 0x55, 0x20, 0x08, 0x09, 0x18, | ||
PWR, 6, 0x3F, 0x00, 0x32, 0x2A, 0x0E, 0x2A, | ||
PSR, 2, 0x5F, 0x69, | ||
PFS, 4, 0x00, 0x54, 0x00, 0x44, | ||
BTST1, 4, 0x40, 0x1F, 0x1F, 0x2C, | ||
BTST2, 4, 0x6F, 0x1F, 0x16, 0x25, | ||
BTST3, 4, 0x6F, 0x1F, 0x1F, 0x22, | ||
IPC, 2, 0x00, 0x04, | ||
PLL, 1, 0x02, | ||
TSE, 1, 0x00, | ||
CDI, 1, 0x3F, | ||
TCON, 2, 0x02, 0x00, | ||
TRES, 4, 0x03, 0x20, 0x01, 0xE0, | ||
VDCS, 1, 0x1E, | ||
T_VDCS, 1, 0x00, | ||
AGID, 1, 0x00, | ||
PWS, 1, 0x2F, | ||
CCSET, 1, 0x00, | ||
TSSET, 1, 0x00, | ||
PON, DELAY, 0xc8, | ||
}; | ||
|
||
const uint8_t display_stop_sequence[] = { | ||
POF, 0, | ||
}; | ||
|
||
const uint8_t refresh_sequence[] = { | ||
DRF, 1, 0x00, | ||
}; | ||
|
||
bool displayio_epaperdisplay_query_busy(displayio_epaperdisplay_obj_t *self) { | ||
common_hal_digitalio_digitalinout_set_value(&sr_latch, false); | ||
common_hal_time_delay_ms(1); | ||
common_hal_digitalio_digitalinout_set_value(&sr_latch, true); | ||
common_hal_time_delay_ms(1); | ||
|
||
uint8_t result = 0; | ||
uint8_t bits = 8; | ||
while(bits--) { | ||
result <<= 1; | ||
result |= common_hal_digitalio_digitalinout_get_value(&sr_data); | ||
|
||
common_hal_digitalio_digitalinout_set_value(&sr_clock, false); | ||
common_hal_time_delay_ms(1); | ||
common_hal_digitalio_digitalinout_set_value(&sr_clock, true); | ||
common_hal_time_delay_ms(1); | ||
} | ||
|
||
// mp_printf(MICROPY_DEBUG_PRINTER, "busy check: %d", result); | ||
return result & 0x40; | ||
} | ||
|
||
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_GPIO2); | ||
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); | ||
|
||
common_hal_digitalio_digitalinout_construct(&sr_clock, &pin_GPIO8); | ||
common_hal_digitalio_digitalinout_switch_to_output(&sr_clock, false, DRIVE_MODE_PUSH_PULL); | ||
|
||
common_hal_digitalio_digitalinout_construct(&sr_data, &pin_GPIO10); | ||
common_hal_digitalio_digitalinout_switch_to_input(&sr_data, PULL_NONE); | ||
|
||
common_hal_digitalio_digitalinout_construct(&sr_latch, &pin_GPIO9); | ||
common_hal_digitalio_digitalinout_switch_to_output(&sr_latch, true, DRIVE_MODE_PUSH_PULL); | ||
|
||
displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; | ||
busio_spi_obj_t *spi = common_hal_board_create_spi(0); | ||
|
||
bus->base.type = &displayio_fourwire_type; | ||
common_hal_displayio_fourwire_construct(bus, | ||
spi, | ||
&pin_GPIO28, // EPD_DC Command or data | ||
&pin_GPIO17, // EPD_CS Chip select | ||
&pin_GPIO27, // EPD_RST Reset | ||
1000000, // Baudrate | ||
0, // Polarity | ||
0); // Phase | ||
|
||
displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; | ||
display->base.type = &displayio_epaperdisplay_type; | ||
common_hal_displayio_epaperdisplay_construct( | ||
display, | ||
bus, | ||
display_start_sequence, sizeof(display_start_sequence), | ||
1.0, // start up time | ||
display_stop_sequence, sizeof(display_stop_sequence), | ||
800, // width | ||
480, // height | ||
800, // ram_width | ||
480, // ram_height | ||
0, // colstart | ||
0, // rowstart | ||
180, // rotation | ||
NO_COMMAND, // set_column_window_command | ||
NO_COMMAND, // set_row_window_command | ||
NO_COMMAND, // set_current_column_command | ||
NO_COMMAND, // set_current_row_command | ||
0x10, // write_black_ram_command | ||
false, // black_bits_inverted | ||
NO_COMMAND, // write_color_ram_command | ||
false, // color_bits_inverted | ||
0x000000, // highlight_color | ||
refresh_sequence, sizeof(refresh_sequence), | ||
80.0, // refresh_time | ||
NULL, // busy_pin | ||
false, // busy_state | ||
80.0, // seconds_per_frame | ||
false, // always_toggle_chip_select | ||
false, // grayscale | ||
true, // acep | ||
false, // two_byte_sequence_length | ||
false); // address_little_endian | ||
} | ||
|
||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. |
8 changes: 8 additions & 0 deletions
8
ports/raspberrypi/boards/pimoroni_inky_frame_7_3/inky-shared.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef PIMORONI_INKY_SHARED | ||
#define PIMORONI_INKY_SHARED | ||
|
||
#include "shared-bindings/digitalio/DigitalInOut.h" | ||
|
||
extern digitalio_digitalinout_obj_t enable_pin_obj; | ||
|
||
#endif // PIMORONI_INKY_SHARED |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
firmware_size = 1532k; |
17 changes: 17 additions & 0 deletions
17
ports/raspberrypi/boards/pimoroni_inky_frame_7_3/mpconfigboard.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#define MICROPY_HW_BOARD_NAME "Pimoroni Inky Frame 7.3" | ||
#define MICROPY_HW_MCU_NAME "rp2040" | ||
|
||
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_PULL (1) | ||
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_DRIVE_MODE (1) | ||
|
||
#define MICROPY_HW_LED_STATUS (&pin_GPIO6) | ||
|
||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) | ||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO5) | ||
|
||
#define DEFAULT_UART_BUS_TX (&pin_GPIO0) | ||
#define DEFAULT_UART_BUS_RX (&pin_GPIO1) | ||
|
||
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18) | ||
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19) | ||
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO16) |
29 changes: 29 additions & 0 deletions
29
ports/raspberrypi/boards/pimoroni_inky_frame_7_3/mpconfigboard.mk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
USB_VID = 0x2E8A | ||
USB_PID = 0x1018 | ||
USB_PRODUCT = "Inky Frame 7.3" | ||
USB_MANUFACTURER = "Pimoroni" | ||
|
||
CHIP_VARIANT = RP2040 | ||
CHIP_FAMILY = rp2 | ||
|
||
EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" | ||
|
||
CIRCUITPY__EVE = 1 | ||
|
||
CIRCUITPY_CYW43 = 1 | ||
CIRCUITPY_SSL = 1 | ||
CIRCUITPY_SSL_MBEDTLS = 1 | ||
CIRCUITPY_HASHLIB = 1 | ||
CIRCUITPY_WEB_WORKFLOW = 1 | ||
CIRCUITPY_MDNS = 1 | ||
CIRCUITPY_SOCKETPOOL = 1 | ||
CIRCUITPY_WIFI = 1 | ||
|
||
CFLAGS += -DCYW43_PIN_WL_HOST_WAKE=24 -DCYW43_PIN_WL_REG_ON=23 -DCYW43_WL_GPIO_COUNT=3 -DCYW43_WL_GPIO_LED_PIN=0 | ||
# Must be accompanied by a linker script change | ||
CFLAGS += -DCIRCUITPY_FIRMWARE_SIZE='(1536 * 1024)' | ||
|
||
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-pcf85063a | ||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register | ||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD | ||
|
1 change: 1 addition & 0 deletions
1
ports/raspberrypi/boards/pimoroni_inky_frame_7_3/pico-sdk-configboard.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Put board-specific pico-sdk definitions here. This file must exist. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include "shared-bindings/board/__init__.h" | ||
|
||
#include "supervisor/board.h" | ||
#include "shared-module/displayio/__init__.h" | ||
#include "py/objtuple.h" | ||
#include "py/qstr.h" | ||
|
||
#include "inky-shared.h" | ||
|
||
// for use with keypad.ShiftRegisterKeys: map keycode (bit-number) | ||
// to logical names board.KEYCODES.SW_A etc. | ||
// N.B.: labels and bit-numbers in the schematic are reversed, i.e. | ||
// SW_A on D0 has bit-number 7 | ||
|
||
STATIC const qstr board_keycodes_fields[] = { | ||
MP_QSTR_SW_A, | ||
MP_QSTR_SW_B, | ||
MP_QSTR_SW_C, | ||
MP_QSTR_SW_D, | ||
MP_QSTR_SW_E, | ||
MP_QSTR_RTC_ALARM, | ||
MP_QSTR_EXT_TRIGGER, | ||
MP_QSTR_INKY_BUS | ||
}; | ||
|
||
STATIC MP_DEFINE_ATTRTUPLE( | ||
board_keycodes_obj, | ||
board_keycodes_fields, | ||
8, | ||
MP_ROM_INT(7), | ||
MP_ROM_INT(6), | ||
MP_ROM_INT(5), | ||
MP_ROM_INT(4), | ||
MP_ROM_INT(3), | ||
MP_ROM_INT(2), | ||
MP_ROM_INT(1), | ||
MP_ROM_INT(0) | ||
); | ||
|
||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = { | ||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, | ||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, | ||
{ MP_ROM_QSTR(MP_QSTR_HOLD_SYS_EN), MP_ROM_PTR(&pin_GPIO2) }, | ||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_GPIO3) }, | ||
|
||
{ 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_LED_ACT), MP_ROM_PTR(&pin_GPIO6) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO6) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_CONN), MP_ROM_PTR(&pin_GPIO7) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SWITCH_CLK), MP_ROM_PTR(&pin_GPIO8) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SWITCH_LATCH), MP_ROM_PTR(&pin_GPIO9) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SWITCH_OUT), MP_ROM_PTR(&pin_GPIO10) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_A), MP_ROM_PTR(&pin_GPIO11) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_GPIO12) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_C), MP_ROM_PTR(&pin_GPIO13) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_D), MP_ROM_PTR(&pin_GPIO14) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_E), MP_ROM_PTR(&pin_GPIO15) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO16) }, | ||
{ MP_ROM_QSTR(MP_QSTR_INKY_CS), MP_ROM_PTR(&pin_GPIO17) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SCLK), MP_ROM_PTR(&pin_GPIO18) }, | ||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO19) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_DAT1), MP_ROM_PTR(&pin_GPIO20) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_DAT2), MP_ROM_PTR(&pin_GPIO21) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO22) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_INKY_RES), MP_ROM_PTR(&pin_GPIO27) }, | ||
{ MP_ROM_QSTR(MP_QSTR_INKY_DC), MP_ROM_PTR(&pin_GPIO28) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_PICO_LED), MP_ROM_PTR(&pin_CYW0) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_CYW1) }, | ||
{ MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_CYW2) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_STEMMA_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_DIO), MP_ROM_PTR(&enable_pin_obj)}, // GP2 | ||
{ MP_ROM_QSTR(MP_QSTR_KEYCODES), MP_ROM_PTR(&board_keycodes_obj)}, | ||
}; | ||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not convinced these should be in this order