Skip to content

Commit 84292ad

Browse files
committed
External fourwire works and blinka splash after
1 parent 05d8885 commit 84292ad

18 files changed

Lines changed: 255 additions & 82 deletions

File tree

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ bool run_code_py(safe_mode_t safe_mode) {
201201
}
202202
}
203203
// Turn off the display before the heap disappears.
204-
reset_primary_display();
204+
reset_displays();
205205
stop_mp();
206206
free_memory(heap);
207207

ports/atmel-samd/background.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void run_background_tasks(void) {
4444
audio_dma_background();
4545
#endif
4646
#ifdef CIRCUITPY_DISPLAYIO
47-
displayio_refresh_display();
47+
displayio_refresh_displays();
4848
#endif
4949

5050
#if MICROPY_PY_NETWORK

ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@
4646
#define IGNORE_PIN_PA25 1
4747

4848
#define CIRCUITPY_I2CSLAVE
49+
#define CIRCUITPY_DISPLAYIO (1)
50+
#define CIRCUITPY_DISPLAY_LIMIT (3)

ports/atmel-samd/boards/grandcentral_m4_express/pins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "shared-bindings/board/__init__.h"
22

3-
#include "board_busses.h"
3+
#include "supervisor/shared/board_busses.h"
44

55
// This mapping only includes functional names because pins broken
66
// out on connectors are labeled with their MCU name available from

ports/atmel-samd/boards/pyportal/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// QSPI Data pins
1414
#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 )
1515
// QSPI CS, and QSPI SCK
16-
#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 )
16+
#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 )
1717
#define MICROPY_PORT_C ( 0 )
1818
#define MICROPY_PORT_D (0)
1919

ports/atmel-samd/boards/pyportal/pins.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "shared-bindings/board/__init__.h"
22

33
#include "boards/board.h"
4-
#include "board_busses.h"
4+
#include "supervisor/shared/board_busses.h"
55

66
// This mapping only includes functional names because pins broken
77
// out on connectors are labeled with their MCU name available from
@@ -72,7 +72,5 @@ STATIC const mp_map_elem_t board_global_dict_table[] = {
7272
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
7373
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
7474
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
75-
76-
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&board_display_obj)}
7775
};
7876
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/common-hal/busio/SPI.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ void never_reset_sercom(Sercom* sercom) {
5454
}
5555
}
5656

57+
void allow_reset_sercom(Sercom* sercom) {
58+
// Reset all SERCOMs except the ones being used by on-board devices.
59+
Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS;
60+
for (int i = 0; i < SERCOM_INST_NUM; i++) {
61+
if (sercom_instances[i] == sercom) {
62+
never_reset_sercoms[i] = false;
63+
break;
64+
}
65+
}
66+
}
67+
5768
void reset_sercoms(void) {
5869
// Reset all SERCOMs except the ones being used by on-board devices.
5970
Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS;
@@ -235,6 +246,8 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
235246
if (common_hal_busio_spi_deinited(self)) {
236247
return;
237248
}
249+
allow_reset_sercom(self->spi_desc.dev.prvt);
250+
238251
spi_m_sync_disable(&self->spi_desc);
239252
spi_m_sync_deinit(&self->spi_desc);
240253
reset_pin_number(self->clock_pin);

ports/atmel-samd/common-hal/displayio/FourWire.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self,
5353
never_reset_pin_number(reset->number);
5454
}
5555

56+
void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t* self) {
57+
if (self->bus == &self->inline_bus) {
58+
common_hal_busio_spi_deinit(self->bus);
59+
}
60+
61+
reset_pin_number(self->command.pin->number);
62+
reset_pin_number(self->chip_select.pin->number);
63+
reset_pin_number(self->reset.pin->number);
64+
}
65+
5666
bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) {
5767
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
5868
if (!common_hal_busio_spi_try_lock(self->bus)) {

ports/atmel-samd/common-hal/displayio/FourWire.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
typedef struct {
3535
mp_obj_base_t base;
3636
busio_spi_obj_t* bus;
37+
busio_spi_obj_t inline_bus;
3738
digitalio_digitalinout_obj_t command;
3839
digitalio_digitalinout_obj_t chip_select;
3940
digitalio_digitalinout_obj_t reset;

ports/atmel-samd/common-hal/microcontroller/Pin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void never_reset_pin_number(uint8_t pin_number) {
100100
}
101101

102102
void reset_pin_number(uint8_t pin_number) {
103+
never_reset_pins[GPIO_PORT(pin_number)] &= ~(1 << GPIO_PIN(pin_number));
104+
103105
if (pin_number >= PORT_BITS) {
104106
return;
105107
}

0 commit comments

Comments
 (0)