Skip to content

Commit 98a92ef

Browse files
authored
Merge pull request #8600 from supcik/oxocards
Add Oxocards ports
2 parents 8ff0682 + e8e1a1d commit 98a92ef

File tree

20 files changed

+867
-0
lines changed

20 files changed

+867
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 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 "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
#include "shared-bindings/microcontroller/Pin.h"
30+
#include "shared-module/displayio/__init__.h"
31+
#include "shared-module/displayio/mipi_constants.h"
32+
33+
#define DELAY 0x80
34+
35+
// display init sequence
36+
uint8_t display_init_sequence[] = {
37+
0x01, DELAY, 0x96, // _SWRESET and Delay 150ms
38+
0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms
39+
0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD (65K of RGB, 16 bits/pixel) and Delay 10ms
40+
0x36, 0x01, 0x00, // _MADCTL
41+
0x2A, 0x04, 0x00, 0x00, 0x00, 0xF0, // _CASET (0..240)
42+
0x2B, 0x04, 0x00, 0x00, 0x00, 0xF0, // _RASET (0..240)
43+
0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms
44+
0x13, DELAY, 0x0A, // _NORON and Delay 10ms
45+
0x29, DELAY, 0xFF, // _DISPON and Delay 500ms
46+
};
47+
48+
static void display_init(void) {
49+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
50+
busio_spi_obj_t *spi = &bus->inline_bus;
51+
52+
common_hal_busio_spi_construct(
53+
spi,
54+
&pin_GPIO14, // CLK
55+
&pin_GPIO13, // MOSI
56+
&pin_GPIO12, // MISO
57+
false); // Not half-duplex
58+
59+
common_hal_busio_spi_never_reset(spi);
60+
61+
bus->base.type = &fourwire_fourwire_type;
62+
63+
common_hal_fourwire_fourwire_construct(
64+
bus,
65+
spi,
66+
&pin_GPIO27, // DC
67+
&pin_GPIO15, // CS
68+
&pin_GPIO4, // RST
69+
24000000, // baudrate
70+
0, // polarity
71+
0 // phase
72+
);
73+
74+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
75+
display->base.type = &busdisplay_busdisplay_type;
76+
77+
common_hal_busdisplay_busdisplay_construct(
78+
display,
79+
bus,
80+
240, // width (after rotation)
81+
240, // height (after rotation)
82+
0, // column start
83+
80, // row start
84+
0, // rotation
85+
16, // color depth
86+
false, // grayscale
87+
false, // pixels in a byte share a row. Only valid for depths < 8
88+
1, // bytes per cell. Only valid for depths < 8
89+
false, // reverse_pixels_in_byte. Only valid for depths < 8
90+
true, // reverse_pixels_in_word
91+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
92+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
93+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
94+
display_init_sequence,
95+
sizeof(display_init_sequence),
96+
&pin_GPIO19, // backlight pin
97+
NO_BRIGHTNESS_COMMAND,
98+
1.0f, // brightness
99+
false, // single_byte_bounds
100+
false, // data_as_commands
101+
true, // auto_refresh
102+
60, // native_frames_per_second
103+
true, // backlight_on_high
104+
false, // SH1107_addressing
105+
50000 // backlight pwm frequency
106+
);
107+
}
108+
109+
void board_init(void) {
110+
// Display
111+
display_init();
112+
}
113+
114+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2022 Dan Halbert 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+
// Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "Oxocard Artwork"
30+
#define MICROPY_HW_MCU_NAME "ESP32"
31+
32+
#define MICROPY_HW_LED_STATUS (&pin_GPIO2)
33+
34+
// clang-format off
35+
#define CIRCUITPY_BOARD_I2C (1)
36+
#define CIRCUITPY_BOARD_I2C_PIN { \
37+
{ .scl = &pin_GPIO22, .sda = &pin_GPIO21 }}
38+
// clang-format on
39+
40+
// clang-format off
41+
#define CIRCUITPY_BOARD_SPI (2)
42+
#define CIRCUITPY_BOARD_SPI_PIN { \
43+
{ .clock = &pin_GPIO14, .mosi = &pin_GPIO13, .miso = &pin_GPIO12 }, \
44+
{ .clock = &pin_GPIO7, .mosi = &pin_GPIO5, .miso = &pin_GPIO8 }}
45+
// clang-format on
46+
47+
// UART pins attached to the USB-serial converter chip
48+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
49+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CIRCUITPY_CREATOR_ID = 0x4F583097
2+
CIRCUITPY_CREATION_ID = 0x3A030001
3+
4+
IDF_TARGET = esp32
5+
6+
CIRCUITPY_ESP_FLASH_SIZE = 8MB
7+
CIRCUITPY_ESP_FLASH_MODE = qio
8+
CIRCUITPY_ESP_FLASH_FREQ = 80m
9+
10+
CIRCUITPY_ESP_PSRAM_SIZE = 2MB
11+
CIRCUITPY_ESP_PSRAM_MODE = qio
12+
CIRCUITPY_ESP_PSRAM_FREQ = 80m
13+
14+
CIRCUITPY_ESPCAMERA = 0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "shared-bindings/board/__init__.h"
2+
#include "shared-module/displayio/__init__.h"
3+
4+
CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1)
5+
6+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
7+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
8+
9+
{ MP_ROM_QSTR(MP_QSTR_BTN5), MP_ROM_PTR(&pin_GPIO0) },
10+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
11+
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) },
12+
13+
{ MP_ROM_QSTR(MP_QSTR_AUDIO_N), MP_ROM_PTR(&pin_GPIO26) },
14+
{ MP_ROM_QSTR(MP_QSTR_AUDIO_P), MP_ROM_PTR(&pin_GPIO25) },
15+
{ MP_ROM_QSTR(MP_QSTR_AUDIO_SD), MP_ROM_PTR(&pin_GPIO20) },
16+
17+
{ MP_ROM_QSTR(MP_QSTR_LCD_LED), MP_ROM_PTR(&pin_GPIO19) },
18+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO27) },
19+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO15) },
20+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO4) },
21+
22+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) },
23+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO5) },
24+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO7) },
25+
26+
{ MP_ROM_QSTR(MP_QSTR_BTN4), MP_ROM_PTR(&pin_GPIO39) },
27+
{ MP_ROM_QSTR(MP_QSTR_BTN3), MP_ROM_PTR(&pin_GPIO38) },
28+
{ MP_ROM_QSTR(MP_QSTR_BTN2), MP_ROM_PTR(&pin_GPIO37) },
29+
{ MP_ROM_QSTR(MP_QSTR_BTN1), MP_ROM_PTR(&pin_GPIO36) },
30+
31+
{ MP_ROM_QSTR(MP_QSTR_ACC_INT1), MP_ROM_PTR(&pin_GPIO34) },
32+
{ MP_ROM_QSTR(MP_QSTR_ACC_INT2), MP_ROM_PTR(&pin_GPIO35) },
33+
34+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
35+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
36+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
37+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
38+
};
39+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/espressif/boards/oxocard_artwork/sdkconfig

Whitespace-only changes.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 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 "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
#include "shared-bindings/microcontroller/Pin.h"
30+
#include "shared-module/displayio/__init__.h"
31+
#include "shared-module/displayio/mipi_constants.h"
32+
33+
#define DELAY 0x80
34+
35+
// display init sequence
36+
uint8_t display_init_sequence[] = {
37+
0x01, DELAY, 0x96, // _SWRESET and Delay 150ms
38+
0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms
39+
0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD (65K of RGB, 16 bits/pixel) and Delay 10ms
40+
0x36, 0x01, 0x00, // _MADCTL
41+
0x2A, 0x04, 0x00, 0x00, 0x00, 0xF0, // _CASET (0..240)
42+
0x2B, 0x04, 0x00, 0x00, 0x00, 0xF0, // _RASET (0..240)
43+
0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms
44+
0x13, DELAY, 0x0A, // _NORON and Delay 10ms
45+
0x36, 0x01, 0x60, // _MADCTL (MX=1, MY=1)
46+
0x29, DELAY, 0xFF, // _DISPON and Delay 500ms
47+
};
48+
49+
static void display_init(void) {
50+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
51+
busio_spi_obj_t *spi = &bus->inline_bus;
52+
53+
common_hal_busio_spi_construct(
54+
spi,
55+
&pin_GPIO14, // CLK
56+
&pin_GPIO13, // MOSI
57+
&pin_GPIO12, // MISO
58+
false); // Not half-duplex
59+
60+
common_hal_busio_spi_never_reset(spi);
61+
62+
bus->base.type = &fourwire_fourwire_type;
63+
64+
common_hal_fourwire_fourwire_construct(
65+
bus,
66+
spi,
67+
&pin_GPIO27, // DC
68+
&pin_GPIO15, // CS
69+
&pin_GPIO4, // RST
70+
24000000, // baudrate
71+
0, // polarity
72+
0 // phase
73+
);
74+
75+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
76+
display->base.type = &busdisplay_busdisplay_type;
77+
78+
common_hal_busdisplay_busdisplay_construct(
79+
display,
80+
bus,
81+
240, // width (after rotation)
82+
240, // height (after rotation)
83+
0, // column start
84+
0, // row start
85+
0, // rotation
86+
16, // color depth
87+
false, // grayscale
88+
false, // pixels in a byte share a row. Only valid for depths < 8
89+
1, // bytes per cell. Only valid for depths < 8
90+
false, // reverse_pixels_in_byte. Only valid for depths < 8
91+
true, // reverse_pixels_in_word
92+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
93+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
94+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
95+
display_init_sequence,
96+
sizeof(display_init_sequence),
97+
&pin_GPIO19, // backlight pin
98+
NO_BRIGHTNESS_COMMAND,
99+
1.0f, // brightness
100+
false, // single_byte_bounds
101+
false, // data_as_commands
102+
true, // auto_refresh
103+
60, // native_frames_per_second
104+
true, // backlight_on_high
105+
false, // SH1107_addressing
106+
50000 // backlight pwm frequency
107+
);
108+
}
109+
110+
void board_init(void) {
111+
// Display
112+
display_init();
113+
}
114+
115+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2022 Dan Halbert 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+
// Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "Oxocard Connect"
30+
#define MICROPY_HW_MCU_NAME "ESP32"
31+
32+
#define MICROPY_HW_LED_STATUS (&pin_GPIO2)
33+
34+
// clang-format off
35+
#define CIRCUITPY_BOARD_I2C (1)
36+
#define CIRCUITPY_BOARD_I2C_PIN { \
37+
{ .scl = &pin_GPIO22, .sda = &pin_GPIO21 }}
38+
// clang-format on
39+
40+
// clang-format off
41+
#define CIRCUITPY_BOARD_SPI (2)
42+
#define CIRCUITPY_BOARD_SPI_PIN { \
43+
{ .clock = &pin_GPIO14, .mosi = &pin_GPIO13, .miso = &pin_GPIO12 }, \
44+
{ .clock = &pin_GPIO7, .mosi = &pin_GPIO5, .miso = &pin_GPIO8 }}
45+
// clang-format on
46+
47+
// UART pins attached to the USB-serial converter chip
48+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
49+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)

0 commit comments

Comments
 (0)