Fix I2C and feedback from Dan

This commit is contained in:
Scott Shawcroft 2021-11-23 17:23:13 -08:00
parent a1052d5f73
commit 927a720de9
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
24 changed files with 346 additions and 49 deletions

View File

@ -60,13 +60,9 @@ STATIC mp_obj_t videocore_framebuffer_make_new(const mp_obj_type_t *type, size_t
videocore_framebuffer_obj_t *self = &allocate_display_bus_or_raise()->videocore;
self->base.type = &videocore_framebuffer_type;
if (args[ARG_width].u_int <= 0) {
mp_raise_ValueError(translate("width must be greater than zero"));
}
common_hal_videocore_framebuffer_construct(self,
args[ARG_width].u_int,
args[ARG_height].u_int);
mp_uint_t width = (mp_uint_t)mp_arg_validate_int_min(args[ARG_width].u_int, 0, MP_QSTR_width);
mp_uint_t height = (mp_uint_t)mp_arg_validate_int_min(args[ARG_height].u_int, 0, MP_QSTR_height);
common_hal_videocore_framebuffer_construct(self, width, height);
return MP_OBJ_FROM_PTR(self);
}
@ -136,7 +132,7 @@ STATIC void videocore_framebuffer_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t
common_hal_videocore_framebuffer_get_buffer(self_in, bufinfo, 0);
}
// These version exists so that the prototype matches the protocol,
// These versions exist so that the prototype matches the protocol,
// avoiding a type cast that can hide errors
STATIC void videocore_framebuffer_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) {
(void)dirty_row_bitmap;

View File

@ -30,7 +30,7 @@
extern const mp_obj_type_t videocore_framebuffer_type;
void common_hal_videocore_framebuffer_construct(videocore_framebuffer_obj_t *self, uint16_t width, uint16_t height);
void common_hal_videocore_framebuffer_construct(videocore_framebuffer_obj_t *self, mp_uint_t width, mp_uint_t height);
void common_hal_videocore_framebuffer_deinit(videocore_framebuffer_obj_t *self);
bool common_hal_videocore_framebuffer_deinited(videocore_framebuffer_obj_t *self);
void common_hal_videocore_framebuffer_refresh(videocore_framebuffer_obj_t *self);

View File

@ -1 +1,4 @@
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Compute Module 4 IO Board"
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)

View File

@ -57,6 +57,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

View File

@ -1 +1,4 @@
#define MICROPY_HW_BOARD_NAME "Raspberry Pi 4B"
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)

View File

@ -57,6 +57,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

View File

@ -1 +1,4 @@
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Zero 2W"
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)

View File

@ -2,10 +2,59 @@
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
// These match the names used in Blinka
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_GPIO18), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_GPIO19), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_GPIO20), MP_ROM_PTR(&pin_GPIO20) },
{ MP_ROM_QSTR(MP_QSTR_GPIO21), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_CE1), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_CE0), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_SCLK), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_TXD), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_RXD), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) },
{ MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) },
{ MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_MISO_1), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_GPIO20) },
{ MP_ROM_QSTR(MP_QSTR_MOSI_1), MP_ROM_PTR(&pin_GPIO20) },
{ MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_SCLK_1), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_SCK_1), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO23) },
{ MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO24) },
{ MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

View File

@ -30,46 +30,73 @@
#include "py/runtime.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Pin.h"
#define NO_PIN 0xff
#include "peripherals/broadcom/cpu.h"
#include "peripherals/broadcom/vcmailbox.h"
// One second
#define BUS_TIMEOUT_US 1000000
#define NUM_I2C (2)
STATIC bool never_reset_i2c[2];
// STATIC i2c_inst_t *i2c[2] = {i2c0, i2c1};
STATIC bool never_reset_i2c[NUM_I2C];
STATIC bool in_use_i2c[NUM_I2C];
STATIC BSC0_Type *i2c[2] = {BSC0, BSC1};
void reset_i2c(void) {
for (size_t i = 0; i < 2; i++) {
if (never_reset_i2c[i]) {
continue;
}
in_use_i2c[i] = false;
}
}
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) {
size_t instance_index = NUM_I2C;
if ((scl == &pin_GPIO1 || scl == &pin_GPIO29 || scl == &pin_GPIO45) &&
(sda == &pin_GPIO0 || sda == &pin_GPIO28 || sda == &pin_GPIO44)) {
instance_index = 0;
} else if ((scl == &pin_GPIO44 || scl == &pin_GPIO3) &&
(sda == &pin_GPIO43 || sda == &pin_GPIO2)) {
instance_index = 1;
}
if (instance_index == NUM_I2C) {
mp_raise_ValueError(translate("Invalid pins"));
}
in_use_i2c[instance_index] = true;
self->index = instance_index;
self->peripheral = i2c[self->index];
self->sda_pin = sda;
self->scl_pin = scl;
uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
uint16_t clock_divider = source_clock / frequency;
self->peripheral->DIV_b.CDIV = clock_divider;
gpio_set_function(sda->number, GPIO_GPFSEL0_FSEL2_SDA1);
gpio_set_function(scl->number, GPIO_GPFSEL0_FSEL3_SCL1);
}
bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) {
return self->sda_pin == NO_PIN;
return self->sda_pin == NULL;
}
void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
if (common_hal_busio_i2c_deinited(self)) {
return;
}
// never_reset_i2c[i2c_hw_index(self->peripheral)] = false;
never_reset_i2c[self->index] = false;
reset_pin_number(self->sda_pin);
reset_pin_number(self->scl_pin);
self->sda_pin = NO_PIN;
self->scl_pin = NO_PIN;
common_hal_reset_pin(self->sda_pin);
common_hal_reset_pin(self->scl_pin);
self->sda_pin = NULL;
self->scl_pin = NULL;
}
bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
return common_hal_busio_i2c_write(self, addr, NULL, 0, true) == 0;
uint8_t result = common_hal_busio_i2c_write(self, addr, NULL, 0, true);
// mp_printf(&mp_plat_print, "result %d %d\n", addr, result);
return result == 0;
}
bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) {
@ -89,20 +116,111 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) {
self->has_lock = false;
}
// Discussion of I2C implementation is here: https://github.com/raspberrypi/linux/issues/254
uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr,
const uint8_t *data, size_t len, bool transmit_stop_bit) {
COMPLETE_MEMORY_READS;
self->peripheral->S_b.DONE = true;
self->peripheral->A_b.ADDR = addr;
size_t loop_len = len;
// Prevent the stop bit by transmitting everything but the last byte. Doing
// so is left up to the subsequent read.
if (!transmit_stop_bit) {
loop_len -= 1;
}
self->peripheral->DLEN_b.DLEN = len;
self->peripheral->C = BSC0_C_ST_Msk | BSC0_C_I2CEN_Msk;
// Wait for the transaction to start.
while (self->peripheral->S_b.TA == 0) {
RUN_BACKGROUND_TASKS;
}
for (size_t i = 0; i < loop_len; i++) {
if (self->peripheral->S_b.ERR) {
break;
}
self->peripheral->FIFO_b.DATA = data[i];
// Wait for the FIFO to empty enough that we can write more data.
while (self->peripheral->S_b.TXE == 0) {
RUN_BACKGROUND_TASKS;
}
}
// Wait for the FIFO to empty completely, not DONE, because we may not complete the
// transaction with a write.
while (self->peripheral->S_b.ERR == 0 &&
((!transmit_stop_bit && self->peripheral->S_b.TXE == 0) ||
(transmit_stop_bit && self->peripheral->S_b.TA == 1))) {
RUN_BACKGROUND_TASKS;
}
self->finish_write = false;
if (self->peripheral->S_b.ERR) {
// Wait for the transfer to finish.
while (self->peripheral->S_b.TA == 1) {
RUN_BACKGROUND_TASKS;
}
// Clear the flag by writing it and wait for it to clear.
self->peripheral->S_b.ERR = true;
while (self->peripheral->S_b.ERR == 1) {
RUN_BACKGROUND_TASKS;
}
return MP_ENODEV;
}
if (loop_len < len) {
self->finish_write = true;
self->last_write_data = data[len - 1];
}
return 0;
}
uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
uint8_t *data, size_t len) {
COMPLETE_MEMORY_READS;
self->peripheral->A_b.ADDR = addr;
if (self->finish_write) {
self->finish_write = false;
if (self->peripheral->S_b.ERR == 1) {
return MP_ENODEV;
}
self->peripheral->FIFO_b.DATA = self->last_write_data;
} else {
self->peripheral->S_b.DONE = true;
}
self->peripheral->DLEN_b.DLEN = len;
self->peripheral->C = BSC0_C_READ_Msk | BSC0_C_ST_Msk | BSC0_C_I2CEN_Msk;
// Wait for the transaction to start.
while (self->peripheral->S_b.TA == 0) {
RUN_BACKGROUND_TASKS;
}
for (size_t i = 0; i < len; i++) {
if (self->peripheral->S_b.ERR) {
break;
}
// Wait for the FIFO to have enough data that we can read it. RXR is low
// once the transaction is done so we check the done bit too.
while (!self->peripheral->S_b.RXR && !self->peripheral->S_b.DONE) {
RUN_BACKGROUND_TASKS;
}
data[i] = self->peripheral->FIFO_b.DATA;
}
// Wait for the transaction to finish.
while (!self->peripheral->S_b.DONE && !self->peripheral->S_b.ERR) {
RUN_BACKGROUND_TASKS;
}
if (self->peripheral->S_b.ERR) {
self->peripheral->S_b.ERR = true;
while (self->peripheral->S_b.ERR == 1) {
RUN_BACKGROUND_TASKS;
}
return MP_ENODEV;
}
return 0;
}
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
// never_reset_i2c[i2c_hw_index(self->peripheral)] = true;
never_reset_i2c[self->index] = true;
never_reset_pin_number(self->scl_pin);
never_reset_pin_number(self->sda_pin);
common_hal_never_reset_pin(self->scl_pin);
common_hal_never_reset_pin(self->sda_pin);
}

View File

@ -31,12 +31,18 @@
#include "py/obj.h"
#include "peripherals/broadcom/defines.h"
#include "peripherals/broadcom/gpio.h"
typedef struct {
mp_obj_base_t base;
const mcu_pin_obj_t *scl_pin;
const mcu_pin_obj_t *sda_pin;
BSC0_Type *peripheral;
uint8_t index;
bool has_lock;
uint baudrate;
uint8_t scl_pin;
uint8_t sda_pin;
bool finish_write;
uint8_t last_write_data;
} busio_i2c_obj_t;
void reset_i2c(void);

View File

@ -49,6 +49,11 @@ typedef enum {
STATUS_NEVER_RESET
} uart_status_t;
// The Broadcom chips have two different types of UARTs. UART1 is the "mini-UART"
// that is most available so we've implemented it first. The ARM PL011 UART
// support will be added later. We set NUM_UARTS to 2 here so that we can match
// the indexing even though UART0 isn't supported yet. We currently use this
// UART for debugging so we don't support user use of UART yet.
#define NUM_UARTS 2
static uart_status_t uart_status[NUM_UARTS];

View File

@ -104,9 +104,36 @@ PIN(24)
PIN(25)
PIN(26)
PIN(27)
PIN(28)
PIN(29)
PIN(30)
PIN(31)
PIN(32)
PIN(33)
PIN(34)
PIN(35)
PIN(36)
PIN(37)
PIN(38)
PIN(39)
PIN(40)
PIN(41)
PIN(42)
PIN(43)
PIN(44)
PIN(45)
PIN(46)
PIN(47)
PIN(48)
PIN(49)
PIN(50)
PIN(51)
PIN(52)
PIN(53)
PIN(54)
PIN(55)
PIN(56)
PIN(57)

View File

@ -47,6 +47,7 @@ extern const mcu_pin_obj_t pin_GPIO6;
extern const mcu_pin_obj_t pin_GPIO7;
extern const mcu_pin_obj_t pin_GPIO8;
extern const mcu_pin_obj_t pin_GPIO9;
extern const mcu_pin_obj_t pin_GPIO10;
extern const mcu_pin_obj_t pin_GPIO11;
extern const mcu_pin_obj_t pin_GPIO12;
@ -57,6 +58,7 @@ extern const mcu_pin_obj_t pin_GPIO16;
extern const mcu_pin_obj_t pin_GPIO17;
extern const mcu_pin_obj_t pin_GPIO18;
extern const mcu_pin_obj_t pin_GPIO19;
extern const mcu_pin_obj_t pin_GPIO20;
extern const mcu_pin_obj_t pin_GPIO21;
extern const mcu_pin_obj_t pin_GPIO22;
@ -68,13 +70,36 @@ extern const mcu_pin_obj_t pin_GPIO27;
extern const mcu_pin_obj_t pin_GPIO28;
extern const mcu_pin_obj_t pin_GPIO29;
extern const mcu_pin_obj_t pin_GPIO30;
extern const mcu_pin_obj_t pin_GPIO31;
extern const mcu_pin_obj_t pin_GPIO32;
extern const mcu_pin_obj_t pin_GPIO33;
extern const mcu_pin_obj_t pin_GPIO34;
extern const mcu_pin_obj_t pin_GPIO35;
extern const mcu_pin_obj_t pin_GPIO36;
extern const mcu_pin_obj_t pin_GPIO37;
extern const mcu_pin_obj_t pin_GPIO38;
extern const mcu_pin_obj_t pin_GPIO39;
extern const mcu_pin_obj_t pin_GPIO40;
extern const mcu_pin_obj_t pin_GPIO41;
extern const mcu_pin_obj_t pin_GPIO42;
extern const mcu_pin_obj_t pin_GPIO43;
extern const mcu_pin_obj_t pin_GPIO44;
extern const mcu_pin_obj_t pin_GPIO45;
extern const mcu_pin_obj_t pin_GPIO46;
extern const mcu_pin_obj_t pin_GPIO47;
extern const mcu_pin_obj_t pin_GPIO48;
extern const mcu_pin_obj_t pin_GPIO49;
extern const mcu_pin_obj_t pin_GPIO50;
extern const mcu_pin_obj_t pin_GPIO51;
extern const mcu_pin_obj_t pin_GPIO52;
extern const mcu_pin_obj_t pin_GPIO53;
extern const mcu_pin_obj_t pin_GPIO54;
extern const mcu_pin_obj_t pin_GPIO55;
extern const mcu_pin_obj_t pin_GPIO56;
extern const mcu_pin_obj_t pin_GPIO57;
void reset_all_pins(void);
// reset_pin_number takes the pin number instead of the pointer so that objects don't

View File

@ -26,6 +26,7 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/microcontroller/Processor.h"
#include "common-hal/microcontroller/__init__.h"
#include "peripherals/broadcom/interrupts.h"
@ -127,6 +128,68 @@ watchdog_watchdogtimer_obj_t common_hal_mcu_watchdogtimer_obj = {
#endif
// This maps MCU pin names to pin objects.
#define PIN(num) { MP_ROM_QSTR(MP_QSTR_GPIO##num), MP_ROM_PTR(&pin_GPIO##num) },
const mp_rom_map_elem_t mcu_pin_global_dict_table[TOTAL_GPIO_COUNT] = {
PIN(0)
PIN(1)
PIN(2)
PIN(3)
PIN(4)
PIN(5)
PIN(6)
PIN(7)
PIN(8)
PIN(9)
PIN(10)
PIN(11)
PIN(12)
PIN(13)
PIN(14)
PIN(15)
PIN(16)
PIN(17)
PIN(18)
PIN(19)
PIN(20)
PIN(21)
PIN(22)
PIN(23)
PIN(24)
PIN(25)
PIN(26)
PIN(27)
PIN(28)
PIN(29)
PIN(30)
PIN(31)
PIN(32)
PIN(33)
PIN(34)
PIN(35)
PIN(36)
PIN(37)
PIN(38)
PIN(39)
PIN(40)
PIN(41)
PIN(42)
PIN(43)
PIN(44)
PIN(45)
PIN(46)
PIN(47)
PIN(48)
PIN(49)
PIN(50)
PIN(51)
PIN(52)
PIN(53)
PIN(54)
PIN(55)
PIN(56)
PIN(57)
};
MP_DEFINE_CONST_DICT(mcu_pin_globals, mcu_pin_global_dict_table);

View File

@ -27,6 +27,6 @@
#ifndef MICROPY_INCLUDED_BROADCOM_COMMON_HAL_MICROCONTROLLER___INIT___H
#define MICROPY_INCLUDED_BROADCOM_COMMON_HAL_MICROCONTROLLER___INIT___H
#define TOTAL_GPIO_COUNT 10
#define TOTAL_GPIO_COUNT 58
#endif // MICROPY_INCLUDED_BROADCOM_COMMON_HAL_MICROCONTROLLER___INIT___H

View File

@ -8,7 +8,7 @@
#include "peripherals/broadcom/vcmailbox.h"
void common_hal_videocore_framebuffer_construct(videocore_framebuffer_obj_t *self,
uint16_t width, uint16_t height) {
mp_uint_t width, mp_uint_t height) {
// These will be modified on success to indicate actual values.
uint32_t virtual_width = width;
uint32_t virtual_height = height;
@ -27,7 +27,6 @@ void common_hal_videocore_framebuffer_construct(videocore_framebuffer_obj_t *sel
self->height = 0;
return;
}
mp_printf(&mp_plat_print, "%dx%d pitch %d\n", virtual_width, virtual_height, pitch);
self->width = virtual_width;
self->height = virtual_height;
self->pitch = pitch;

View File

@ -31,8 +31,8 @@
typedef struct {
mp_obj_base_t base;
uint32_t *framebuffer;
uint16_t width;
uint16_t height;
uint16_t pitch;
mp_uint_t width;
mp_uint_t height;
uint32_t pitch;
bool doublebuffer;
} videocore_framebuffer_obj_t;

View File

@ -36,7 +36,7 @@
#define MICROPY_PY_SYS_PLATFORM "BROADCOM"
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
#define MICROPY_PY_FUNCTION_ATTRS (1)
#define MICROPY_OBJ_REPR (0)
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
#define CIRCUITPY_DEFAULT_STACK_SIZE (0x10000)
#define CIRCUITPY_DISPLAY_AREA_BUFFER_SIZE (1920)
#define CIRCUITPY_PROCESSOR_COUNT (4)

@ -1 +1 @@
Subproject commit 764ea35db106d2d4a2fe2f827a65485eded42e00
Subproject commit 8057af2d614c27a1e103d5f4300428f341da6bcb

View File

@ -34,8 +34,6 @@
extern const mp_obj_type_t displayio_display_type;
#define DELAY 0x80
#define NO_BRIGHTNESS_COMMAND 0x100
void common_hal_displayio_display_construct(displayio_display_obj_t *self,

View File

@ -34,8 +34,6 @@
extern const mp_obj_type_t displayio_epaperdisplay_type;
#define DELAY 0x80
#define NO_COMMAND 0x100
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t *self,

View File

@ -35,8 +35,6 @@
extern const mp_obj_type_t framebufferio_framebufferdisplay_type;
#define DELAY 0x80
#define NO_BRIGHTNESS_COMMAND 0x100
void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t *self,

View File

@ -43,6 +43,8 @@
#include <stdint.h>
#include <string.h>
#define DELAY 0x80
void common_hal_displayio_display_construct(displayio_display_obj_t *self,
mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart,
uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row,

View File

@ -44,6 +44,8 @@
#include <stdint.h>
#include <string.h>
#define DELAY 0x80
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t *self,
mp_obj_t bus, const uint8_t *start_sequence, uint16_t start_sequence_len,
const uint8_t *stop_sequence, uint16_t stop_sequence_len,