Skip to content

Commit 56a2199

Browse files
committed
Add frequency support to parallel bus
1 parent b080d62 commit 56a2199

File tree

8 files changed

+15
-10
lines changed

8 files changed

+15
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
3737
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
38-
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
38+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset, uint32_t frequency) {
3939

4040
uint8_t data_pin = data0->number;
4141
if (data_pin % 8 != 0) {

ports/esp32s2/common-hal/displayio/ParallelBus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
4242
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
43-
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
43+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset, uint32_t frequency) {
4444

4545
uint8_t data_pin = data0->number;
4646
if (data_pin % 8 != 0) {

ports/mimxrt10xx/common-hal/displayio/ParallelBus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
3737
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
38-
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
38+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset, uint32_t frequency) {
3939

4040
mp_raise_NotImplementedError(translate("ParallelBus not yet supported"));
4141
}

ports/nrf/common-hal/displayio/ParallelBus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
3737
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
38-
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
38+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset, uint32_t frequency) {
3939

4040
uint8_t data_pin = data0->number;
4141
if (data_pin % 8 != 0) {

ports/raspberrypi/common-hal/displayio/ParallelBus.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ static const uint16_t parallel_program[] = {
4545

4646
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
4747
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
48-
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
48+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset, uint32_t frequency) {
49+
50+
// If we did not set frequency guess at 60Mhz
51+
if (frequency == 0)
52+
frequency = 60000000;
4953

5054
uint8_t data_pin = data0->number;
5155
for (uint8_t i = 0; i < 8; i++) {
@@ -100,7 +104,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel
100104

101105
bool ok = rp2pio_statemachine_construct(&self->state_machine,
102106
parallel_program, sizeof(parallel_program) / sizeof(parallel_program[0]),
103-
60000000, //48000000, //125000000, // freq 24Mhz
107+
frequency, // frequency
104108
NULL, 0, // init
105109
data0, 8, // first out pin, # out pins
106110
NULL, 0, // first in pin, # in pins

ports/stm/common-hal/displayio/ParallelBus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
3737
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
38-
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
38+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset, uint32_t frequency) {
3939

4040
mp_raise_NotImplementedError(translate("ParallelBus not yet supported"));
4141
}

shared-bindings/displayio/ParallelBus.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@
6060
//| ...
6161
//|
6262
STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
63-
enum { ARG_data0, ARG_command, ARG_chip_select, ARG_write, ARG_read, ARG_reset };
63+
enum { ARG_data0, ARG_command, ARG_chip_select, ARG_write, ARG_read, ARG_reset, ARG_frequency };
6464
static const mp_arg_t allowed_args[] = {
6565
{ MP_QSTR_data0, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
6666
{ MP_QSTR_command, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
6767
{ MP_QSTR_chip_select, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
6868
{ MP_QSTR_write, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
6969
{ MP_QSTR_read, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
7070
{ MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
71+
{ MP_QSTR_frequency, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } },
7172
};
7273
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
7374
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
@@ -82,7 +83,7 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t
8283
displayio_parallelbus_obj_t* self = &allocate_display_bus_or_raise()->parallel_bus;
8384
self->base.type = &displayio_parallelbus_type;
8485

85-
common_hal_displayio_parallelbus_construct(self, data0, command, chip_select, write, read, reset);
86+
common_hal_displayio_parallelbus_construct(self, data0, command, chip_select, write, read, reset, args[ARG_frequency].u_int);
8687
return self;
8788
}
8889

shared-bindings/displayio/ParallelBus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern const mp_obj_type_t displayio_parallelbus_type;
3737

3838
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
3939
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
40-
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset);
40+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset, uint32_t frequency);
4141

4242
void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self);
4343

0 commit comments

Comments
 (0)