forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
adding xteink x4 board #10873
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
Merged
Merged
adding xteink x4 board #10873
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,130 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2021 microDev | ||
| // SPDX-FileCopyrightText: Copyright (c) 2021 skieast/Bruce Segal | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "supervisor/board.h" | ||
|
|
||
| #include "mpconfigboard.h" | ||
| #include "shared-bindings/busio/SPI.h" | ||
| #include "shared-bindings/fourwire/FourWire.h" | ||
| #include "shared-bindings/microcontroller/Pin.h" | ||
| #include "shared-module/displayio/__init__.h" | ||
| #include "supervisor/shared/board.h" | ||
|
|
||
| #define DELAY 0x80 | ||
|
|
||
| // SSD1677 controller driving a GDEQ0426T82 4.26" 800x480 E-Ink display. | ||
|
|
||
| const uint8_t ssd1677_display_start_sequence[] = { | ||
| // Software Reset | ||
| 0x12, DELAY, 0x00, 0x14, | ||
|
|
||
| // Temperature Sensor Control (use internal sensor) | ||
| 0x18, 0x00, 0x01, 0x80, | ||
|
|
||
| // Booster Soft Start | ||
| 0x0C, 0x00, 0x05, 0xAE, 0xC7, 0xC3, 0xC0, 0x40, | ||
|
|
||
| // Driver Output Control: 480 gates, GD=0, SM=1, TB=0 = 0x02 | ||
| 0x01, 0x00, 0x03, 0xDF, 0x01, 0x02, | ||
|
|
||
| // Data Entry Mode: X increment, Y decrement = 0x01 | ||
| 0x11, 0x00, 0x01, 0x01, | ||
|
|
||
| // Border Waveform Control | ||
| 0x3C, 0x00, 0x01, 0x01, | ||
|
|
||
| // Set RAM X Address Start/End: 0 to 799 | ||
| 0x44, 0x00, 0x04, 0x00, 0x00, 0x1F, 0x03, | ||
|
|
||
| // Set RAM Y Address Start/End: 479 down to 0 | ||
| 0x45, 0x00, 0x04, 0xDF, 0x01, 0x00, 0x00, | ||
|
|
||
| // Set RAM X Counter to 0 | ||
| 0x4E, 0x00, 0x02, 0x00, 0x00, | ||
|
|
||
| // Set RAM Y Counter to 479 | ||
| 0x4F, 0x00, 0x02, 0xDF, 0x01, | ||
|
|
||
| // Auto Write BW RAM (clear to white) | ||
| 0x46, DELAY, 0x01, 0xF7, 0xFF, | ||
|
|
||
| // Display Update Control 1: bypass RED | ||
| 0x21, 0x00, 0x02, 0x40, 0x00, | ||
|
|
||
| // Display Update Control 2: full refresh with OTP LUT | ||
| 0x22, 0x00, 0x01, 0xF7, | ||
| }; | ||
|
|
||
| const uint8_t ssd1677_display_stop_sequence[] = { | ||
| 0x22, 0x00, 0x01, 0x83, | ||
| 0x20, 0x00, 0x00, | ||
| 0x10, 0x00, 0x01, 0x01, | ||
| }; | ||
|
|
||
| const uint8_t ssd1677_display_refresh_sequence[] = { | ||
| 0x20, 0x00, 0x00, | ||
| }; | ||
|
|
||
| void board_init(void) { | ||
| fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; | ||
| busio_spi_obj_t *spi = &bus->inline_bus; | ||
| common_hal_busio_spi_construct(spi, &pin_GPIO8, &pin_GPIO10, NULL, false); | ||
| common_hal_busio_spi_never_reset(spi); | ||
|
|
||
| bus->base.type = &fourwire_fourwire_type; | ||
| common_hal_fourwire_fourwire_construct(bus, | ||
| spi, | ||
| MP_OBJ_FROM_PTR(&pin_GPIO4), | ||
| MP_OBJ_FROM_PTR(&pin_GPIO21), | ||
| MP_OBJ_FROM_PTR(&pin_GPIO5), | ||
| 40000000, | ||
| 0, | ||
| 0); | ||
|
|
||
| epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; | ||
| display->base.type = &epaperdisplay_epaperdisplay_type; | ||
|
|
||
| epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS; | ||
| args.bus = bus; | ||
| args.start_sequence = ssd1677_display_start_sequence; | ||
| args.start_sequence_len = sizeof(ssd1677_display_start_sequence); | ||
| args.stop_sequence = ssd1677_display_stop_sequence; | ||
| args.stop_sequence_len = sizeof(ssd1677_display_stop_sequence); | ||
| args.width = 800; | ||
| args.height = 480; | ||
| args.ram_width = 800; | ||
| args.ram_height = 480; | ||
| args.rotation = 0; | ||
| args.write_black_ram_command = 0x24; | ||
| args.black_bits_inverted = false; | ||
| args.refresh_sequence = ssd1677_display_refresh_sequence; | ||
| args.refresh_sequence_len = sizeof(ssd1677_display_refresh_sequence); | ||
| args.refresh_time = 1.6; | ||
| args.busy_pin = &pin_GPIO6; | ||
| args.busy_state = true; | ||
| args.seconds_per_frame = 5.0; | ||
| args.grayscale = false; | ||
| args.two_byte_sequence_length = true; | ||
| args.address_little_endian = true; | ||
| common_hal_epaperdisplay_epaperdisplay_construct(display, &args); | ||
| } | ||
|
|
||
| bool espressif_board_reset_pin_number(gpio_num_t pin_number) { | ||
| return false; | ||
| } | ||
|
|
||
| void board_deinit(void) { | ||
| epaperdisplay_epaperdisplay_obj_t *display = &displays[0].epaper_display; | ||
| if (display->base.type == &epaperdisplay_epaperdisplay_type) { | ||
| while (common_hal_epaperdisplay_epaperdisplay_get_busy(display)) { | ||
| RUN_BACKGROUND_TASKS; | ||
| } | ||
| } | ||
| common_hal_displayio_release_displays(); | ||
| } | ||
|
|
||
| // Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. |
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,18 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2021 microDev | ||
| // SPDX-FileCopyrightText: Copyright (c) 2021 skieast/Bruce Segal | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #pragma once | ||
|
|
||
| // Board setup | ||
| #define MICROPY_HW_BOARD_NAME "Xteink X4" | ||
| #define MICROPY_HW_MCU_NAME "ESP32-C3" | ||
|
|
||
| #define CIRCUITPY_BOARD_SPI (1) | ||
| #define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO8, .mosi = &pin_GPIO10, .miso = &pin_GPIO7}} | ||
|
|
||
| // For entering safe mode | ||
| #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO3) |
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 @@ | ||
| CIRCUITPY_CREATOR_ID = 0x0000303A | ||
| CIRCUITPY_CREATION_ID = 0x00001001 | ||
|
|
||
| IDF_TARGET = esp32c3 | ||
|
|
||
| CIRCUITPY_ESP_FLASH_MODE = dio | ||
| CIRCUITPY_ESP_FLASH_FREQ = 40m | ||
| CIRCUITPY_ESP_FLASH_SIZE = 16MB | ||
|
|
||
| CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 | ||
|
|
||
| CIRCUITPY_PARALLELDISPLAYBUS = 0 | ||
| CIRCUITPY_RGBMATRIX = 0 | ||
| CIRCUITPY_AUDIOBUSIO = 0 | ||
| CIRCUITPY_AUDIOCORE = 0 | ||
| CIRCUITPY_AUDIOMIXER = 0 | ||
| CIRCUITPY_AUDIOMP3 = 0 | ||
| CIRCUITPY_CAMERA = 0 | ||
| CIRCUITPY_CANIO = 0 | ||
| CIRCUITPY_DOTCLOCKFRAMEBUFFER = 0 | ||
| CIRCUITPY_KEYPAD = 0 | ||
| CIRCUITPY_ROTARYIO = 0 | ||
| CIRCUITPY_USB_HID = 0 | ||
| CIRCUITPY_USB_MIDI = 0 | ||
| CIRCUITPY_ULAB = 0 | ||
| CIRCUITPY_PULSEIO = 0 | ||
| CIRCUITPY_PWMIO = 0 | ||
| CIRCUITPY_RAINBOWIO = 0 | ||
| CIRCUITPY_SYNTHIO = 0 | ||
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,52 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2021 microDev | ||
| // SPDX-FileCopyrightText: Copyright (c) 2021 skieast/Bruce Segal | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "shared-bindings/board/__init__.h" | ||
|
|
||
| #include "shared-module/displayio/__init__.h" | ||
|
|
||
| static const mp_rom_map_elem_t board_module_globals_table[] = { | ||
| CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO3) }, | ||
| { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO3) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO0) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO1) }, | ||
| { MP_ROM_QSTR(MP_QSTR_BUTTON_ADC_1), MP_ROM_PTR(&pin_GPIO1) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO2) }, | ||
| { MP_ROM_QSTR(MP_QSTR_BUTTON_ADC_2), MP_ROM_PTR(&pin_GPIO2) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_GPIO20) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO10) }, | ||
| { MP_ROM_QSTR(MP_QSTR_EPD_MOSI), MP_ROM_PTR(&pin_GPIO10) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO8) }, | ||
| { MP_ROM_QSTR(MP_QSTR_EPD_SCK), MP_ROM_PTR(&pin_GPIO8) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO7) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO7) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO12) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_EPD_BUSY), MP_ROM_PTR(&pin_GPIO6) }, | ||
| { MP_ROM_QSTR(MP_QSTR_EPD_RESET), MP_ROM_PTR(&pin_GPIO5) }, | ||
| { MP_ROM_QSTR(MP_QSTR_EPD_DC), MP_ROM_PTR(&pin_GPIO4) }, | ||
| { MP_ROM_QSTR(MP_QSTR_EPD_CS), MP_ROM_PTR(&pin_GPIO21) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)}, | ||
|
|
||
| }; | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # | ||
| # Espressif IoT Development Framework Configuration | ||
| # | ||
| # | ||
| # Component config | ||
| # | ||
| # | ||
| # LWIP | ||
| # | ||
| # end of LWIP | ||
|
|
||
| # end of Component config | ||
|
|
||
| # end of Espressif IoT Development Framework Configuration |
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.
Uh oh!
There was an error while loading. Please reload this page.