Switch to "unmeasured" core clock speed check
This commit is contained in:
parent
c7d9eecfd6
commit
7c717a54f3
@ -98,7 +98,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||||||
self->sda_pin = sda;
|
self->sda_pin = sda;
|
||||||
self->scl_pin = scl;
|
self->scl_pin = scl;
|
||||||
|
|
||||||
uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
|
uint32_t source_clock = vcmailbox_get_clock_rate(VCMAILBOX_CLOCK_CORE);
|
||||||
uint16_t clock_divider = source_clock / frequency;
|
uint16_t clock_divider = source_clock / frequency;
|
||||||
self->peripheral->DIV_b.CDIV = clock_divider;
|
self->peripheral->DIV_b.CDIV = clock_divider;
|
||||||
|
|
||||||
|
@ -87,6 +87,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BCM_VERSION != 2711 have 3 SPI but as listed in peripherals/gen/pins.c two are on
|
||||||
|
// index 0, once one index 0 SPI is found the other will throw an invalid_pins error.
|
||||||
for (size_t i = 0; i < NUM_SPI; i++) {
|
for (size_t i = 0; i < NUM_SPI; i++) {
|
||||||
if (spi_in_use[i]) {
|
if (spi_in_use[i]) {
|
||||||
continue;
|
continue;
|
||||||
@ -157,6 +159,7 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
|
|||||||
common_hal_reset_pin(self->MOSI);
|
common_hal_reset_pin(self->MOSI);
|
||||||
common_hal_reset_pin(self->MISO);
|
common_hal_reset_pin(self->MISO);
|
||||||
self->clock = NULL;
|
self->clock = NULL;
|
||||||
|
spi_in_use[self->index] = false;
|
||||||
|
|
||||||
if (self->index == 1 ||
|
if (self->index == 1 ||
|
||||||
self->index == 2) {
|
self->index == 2) {
|
||||||
@ -198,7 +201,7 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
|
|||||||
SPI0_Type *p = spi[self->index];
|
SPI0_Type *p = spi[self->index];
|
||||||
p->CS = polarity << SPI0_CS_CPOL_Pos |
|
p->CS = polarity << SPI0_CS_CPOL_Pos |
|
||||||
phase << SPI0_CS_CPHA_Pos;
|
phase << SPI0_CS_CPHA_Pos;
|
||||||
uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
|
uint32_t source_clock = vcmailbox_get_clock_rate(VCMAILBOX_CLOCK_CORE);
|
||||||
uint16_t clock_divider = source_clock / baudrate;
|
uint16_t clock_divider = source_clock / baudrate;
|
||||||
if (source_clock % baudrate > 0) {
|
if (source_clock % baudrate > 0) {
|
||||||
clock_divider += 2;
|
clock_divider += 2;
|
||||||
|
@ -460,7 +460,7 @@ uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) {
|
|||||||
|
|
||||||
void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
|
void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
|
||||||
if (self->uart_id == 1) {
|
if (self->uart_id == 1) {
|
||||||
uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
|
uint32_t source_clock = vcmailbox_get_clock_rate(VCMAILBOX_CLOCK_CORE);
|
||||||
UART1->BAUD = ((source_clock / (baudrate * 8)) - 1);
|
UART1->BAUD = ((source_clock / (baudrate * 8)) - 1);
|
||||||
} else {
|
} else {
|
||||||
ARM_UART_PL011_Type *pl011 = uart[self->uart_id];
|
ARM_UART_PL011_Type *pl011 = uart[self->uart_id];
|
||||||
|
Loading…
Reference in New Issue
Block a user