summaryrefslogtreecommitdiffstatshomepage
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bus/qspi.h1
-rw-r--r--drivers/esp-hosted/esp_hosted_bthci_uart.c4
-rw-r--r--drivers/esp-hosted/esp_hosted_wifi.c4
-rw-r--r--drivers/memory/spiflash.c8
4 files changed, 12 insertions, 5 deletions
diff --git a/drivers/bus/qspi.h b/drivers/bus/qspi.h
index 32b2890e3f..05d9dd473c 100644
--- a/drivers/bus/qspi.h
+++ b/drivers/bus/qspi.h
@@ -46,6 +46,7 @@ typedef struct _mp_qspi_proto_t {
int (*write_cmd_addr_data)(void *self, uint8_t cmd, uint32_t addr, size_t len, const uint8_t *src);
int (*read_cmd)(void *self, uint8_t cmd, size_t len, uint32_t *dest);
int (*read_cmd_qaddr_qdata)(void *self, uint8_t cmd, uint32_t addr, uint8_t num_dummy, size_t len, uint8_t *dest);
+ int (*direct_read)(void *self, uint32_t addr, size_t len, uint8_t *dest); // can be NULL if direct read not supported
} mp_qspi_proto_t;
typedef struct _mp_soft_qspi_obj_t {
diff --git a/drivers/esp-hosted/esp_hosted_bthci_uart.c b/drivers/esp-hosted/esp_hosted_bthci_uart.c
index 003054460d..069509edde 100644
--- a/drivers/esp-hosted/esp_hosted_bthci_uart.c
+++ b/drivers/esp-hosted/esp_hosted_bthci_uart.c
@@ -72,7 +72,7 @@ int esp_hosted_hci_cmd(int ogf, int ocf, size_t param_len, const uint8_t *param_
// Receive HCI event packet, initially reading 3 bytes (HCI Event, Event code, Plen).
for (mp_uint_t start = mp_hal_ticks_ms(), size = 3, i = 0; i < size;) {
while (!mp_bluetooth_hci_uart_any()) {
- MICROPY_EVENT_POLL_HOOK
+ mp_event_wait_ms(1);
// Timeout.
if ((mp_hal_ticks_ms() - start) > HCI_COMMAND_TIMEOUT) {
error_printf("timeout waiting for HCI packet\n");
@@ -126,7 +126,7 @@ int mp_bluetooth_hci_controller_init(void) {
if (mp_bluetooth_hci_uart_any()) {
mp_bluetooth_hci_uart_readchar();
}
- MICROPY_EVENT_POLL_HOOK
+ mp_event_wait_ms(1);
}
#ifdef MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY
diff --git a/drivers/esp-hosted/esp_hosted_wifi.c b/drivers/esp-hosted/esp_hosted_wifi.c
index d1b6333aa0..763b04db37 100644
--- a/drivers/esp-hosted/esp_hosted_wifi.c
+++ b/drivers/esp-hosted/esp_hosted_wifi.c
@@ -243,7 +243,7 @@ static int esp_hosted_request(CtrlMsgId msg_id, void *ctrl_payload) {
static CtrlMsg *esp_hosted_response(CtrlMsgId msg_id, uint32_t timeout) {
CtrlMsg *ctrl_msg = NULL;
- for (mp_uint_t start = mp_hal_ticks_ms(); ; mp_hal_delay_ms(10)) {
+ for (mp_uint_t start = mp_hal_ticks_ms(); ; mp_event_wait_ms(10)) {
if (!esp_hosted_stack_empty(&esp_state.stack)) {
ctrl_msg = esp_hosted_stack_pop(&esp_state.stack, true);
if (ctrl_msg->msg_id == msg_id) {
@@ -264,8 +264,6 @@ static CtrlMsg *esp_hosted_response(CtrlMsgId msg_id, uint32_t timeout) {
if ((mp_hal_ticks_ms() - start) >= timeout) {
return NULL;
}
-
- MICROPY_EVENT_POLL_HOOK
}
// If message type is a response, check the response struct's return value.
diff --git a/drivers/memory/spiflash.c b/drivers/memory/spiflash.c
index 1ae0bbbc67..7cd1d18a3f 100644
--- a/drivers/memory/spiflash.c
+++ b/drivers/memory/spiflash.c
@@ -197,6 +197,10 @@ void mp_spiflash_init(mp_spiflash_t *self) {
} else {
uint8_t num_dummy = MICROPY_HW_SPIFLASH_QREAD_NUM_DUMMY(self);
self->config->bus.u_qspi.proto->ioctl(self->config->bus.u_qspi.data, MP_QSPI_IOCTL_INIT, num_dummy);
+ if (self->config->bus.u_qspi.proto->direct_read != NULL) {
+ // A bus with a custom read function should not have any further initialisation done.
+ return;
+ }
}
mp_spiflash_acquire_bus(self);
@@ -318,6 +322,10 @@ int mp_spiflash_read(mp_spiflash_t *self, uint32_t addr, size_t len, uint8_t *de
if (len == 0) {
return 0;
}
+ const mp_spiflash_config_t *c = self->config;
+ if (c->bus_kind == MP_SPIFLASH_BUS_QSPI && c->bus.u_qspi.proto->direct_read != NULL) {
+ return c->bus.u_qspi.proto->direct_read(c->bus.u_qspi.data, addr, len, dest);
+ }
mp_spiflash_acquire_bus(self);
int ret = mp_spiflash_read_data(self, addr, len, dest);
mp_spiflash_release_bus(self);