summaryrefslogtreecommitdiff
path: root/supervisor/shared
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-01-29 16:05:19 -0500
committerLucian Copeland <hierophect@gmail.com>2020-01-29 16:05:19 -0500
commitb9bed98538fb236dc4fa300192c59bf03ac4743b (patch)
treec1568c3d5ac89dd513aa7d6a1f953cbcf88c264f /supervisor/shared
parentab9483b7fb50db46d9cb6abe54641787f5acd7c9 (diff)
parent8a9c3097e3f622d965dfd55b121c4cce6a66344c (diff)
Merge stm32-meowbit
Diffstat (limited to 'supervisor/shared')
-rw-r--r--supervisor/shared/external_flash/spi_flash.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/supervisor/shared/external_flash/spi_flash.c b/supervisor/shared/external_flash/spi_flash.c
index 12888f2d3..67e64c970 100644
--- a/supervisor/shared/external_flash/spi_flash.c
+++ b/supervisor/shared/external_flash/spi_flash.c
@@ -36,33 +36,33 @@
#include "py/mpconfig.h"
digitalio_digitalinout_obj_t cs_pin;
-busio_spi_obj_t spi;
+busio_spi_obj_t supervisor_flash_spi_bus;
const external_flash_device* flash_device;
uint32_t spi_flash_baudrate;
// Enable the flash over SPI.
static void flash_enable(void) {
- while (!common_hal_busio_spi_try_lock(&spi)) {}
+ while (!common_hal_busio_spi_try_lock(&supervisor_flash_spi_bus)) {}
common_hal_digitalio_digitalinout_set_value(&cs_pin, false);
}
// Disable the flash over SPI.
static void flash_disable(void) {
common_hal_digitalio_digitalinout_set_value(&cs_pin, true);
- common_hal_busio_spi_unlock(&spi);
+ common_hal_busio_spi_unlock(&supervisor_flash_spi_bus);
}
static bool transfer(uint8_t* command, uint32_t command_length, uint8_t* data_in, uint8_t* data_out, uint32_t data_length) {
flash_enable();
- bool status = common_hal_busio_spi_write(&spi, command, command_length);
+ bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, command, command_length);
if (status) {
if (data_in != NULL && data_out != NULL) {
- status = common_hal_busio_spi_transfer(&spi, data_out, data_in, data_length);
+ status = common_hal_busio_spi_transfer(&supervisor_flash_spi_bus, data_out, data_in, data_length);
} else if (data_out != NULL) {
- status = common_hal_busio_spi_read(&spi, data_out, data_length, 0xff);
+ status = common_hal_busio_spi_read(&supervisor_flash_spi_bus, data_out, data_length, 0xff);
} else if (data_in != NULL) {
- status = common_hal_busio_spi_write(&spi, data_in, data_length);
+ status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, data_in, data_length);
}
}
flash_disable();
@@ -103,10 +103,10 @@ bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t data_length)
// Write the SPI flash write address into the bytes following the command byte.
address_to_bytes(address, request + 1);
flash_enable();
- common_hal_busio_spi_configure(&spi, spi_flash_baudrate, 0, 0, 8);
- bool status = common_hal_busio_spi_write(&spi, request, 4);
+ common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8);
+ bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, 4);
if (status) {
- status = common_hal_busio_spi_write(&spi, data, data_length);
+ status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, data, data_length);
}
flash_disable();
return status;
@@ -122,10 +122,10 @@ bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t data_length)
// Write the SPI flash write address into the bytes following the command byte.
address_to_bytes(address, request + 1);
flash_enable();
- common_hal_busio_spi_configure(&spi, spi_flash_baudrate, 0, 0, 8);
- bool status = common_hal_busio_spi_write(&spi, request, command_length);
+ common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8);
+ bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, command_length);
if (status) {
- status = common_hal_busio_spi_read(&spi, data, data_length, 0xff);
+ status = common_hal_busio_spi_read(&supervisor_flash_spi_bus, data, data_length, 0xff);
}
flash_disable();
return status;
@@ -140,9 +140,9 @@ void spi_flash_init(void) {
common_hal_digitalio_digitalinout_switch_to_output(&cs_pin, true, DRIVE_MODE_PUSH_PULL);
common_hal_digitalio_digitalinout_never_reset(&cs_pin);
- spi.base.type = &busio_spi_type;
- common_hal_busio_spi_construct(&spi, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN);
- common_hal_busio_spi_never_reset(&spi);
+ supervisor_flash_spi_bus.base.type = &busio_spi_type;
+ common_hal_busio_spi_construct(&supervisor_flash_spi_bus, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN);
+ common_hal_busio_spi_never_reset(&supervisor_flash_spi_bus);
}
void spi_flash_init_device(const external_flash_device* device) {