drivers/memory/spiflash: Change to use low-level SPI object not uPy one.

This patch alters the SPI-flash memory driver so that it uses the new
low-level C SPI protocol (from drivers/bus/spi.h) instead of the uPy SPI
protocol (from extmod/machine_spi.h).  This allows the SPI-flash driver to
be used independently from the uPy runtime.
pull/3662/merge
Damien George 2018-03-09 17:32:28 +11:00
rodzic 58ebeca6a9
commit a739b35a96
3 zmienionych plików z 6 dodań i 9 usunięć

Wyświetl plik

@ -162,7 +162,7 @@ void mp_spiflash_init(mp_spiflash_t *self) {
if (self->config->bus_kind == MP_SPIFLASH_BUS_SPI) {
mp_hal_pin_write(self->config->bus.u_spi.cs, 1);
mp_hal_pin_output(self->config->bus.u_spi.cs);
self->config->bus.u_spi.proto->init(self->config->bus.u_spi.data, 0, NULL, (mp_map_t*)&mp_const_empty_map);
self->config->bus.u_spi.proto->ioctl(self->config->bus.u_spi.data, MP_SPI_IOCTL_INIT);
} else {
self->config->bus.u_qspi.proto->ioctl(self->config->bus.u_qspi.data, MP_QSPI_IOCTL_INIT);
}

Wyświetl plik

@ -26,8 +26,8 @@
#ifndef MICROPY_INCLUDED_DRIVERS_MEMORY_SPIFLASH_H
#define MICROPY_INCLUDED_DRIVERS_MEMORY_SPIFLASH_H
#include "drivers/bus/spi.h"
#include "drivers/bus/qspi.h"
#include "extmod/machine_spi.h"
enum {
MP_SPIFLASH_BUS_SPI,
@ -40,7 +40,7 @@ typedef struct _mp_spiflash_config_t {
struct {
mp_hal_pin_obj_t cs;
void *data;
const mp_machine_spi_p_t *proto;
const mp_spi_proto_t *proto;
} u_spi;
struct {
void *data;

Wyświetl plik

@ -40,23 +40,20 @@ static uint32_t flash_tick_counter_last_write;
// External SPI flash uses standard SPI interface
STATIC const mp_machine_soft_spi_obj_t spiflash_spi_bus = {
.base = {&mp_machine_soft_spi_type},
.spi = {
STATIC const mp_soft_spi_obj_t soft_spi_bus = {
.delay_half = MICROPY_HW_SOFTSPI_MIN_DELAY,
.polarity = 0,
.phase = 0,
.sck = &MICROPY_HW_SPIFLASH_SCK,
.mosi = &MICROPY_HW_SPIFLASH_MOSI,
.miso = &MICROPY_HW_SPIFLASH_MISO,
}
};
STATIC const mp_spiflash_config_t spiflash_config = {
.bus_kind = MP_SPIFLASH_BUS_SPI,
.bus.u_spi.cs = &MICROPY_HW_SPIFLASH_CS,
.bus.u_spi.data = (void*)&spiflash_spi_bus,
.bus.u_spi.proto = &mp_machine_soft_spi_p,
.bus.u_spi.data = (void*)&soft_spi_bus,
.bus.u_spi.proto = &mp_soft_spi_proto,
};
#elif defined(MICROPY_HW_SPIFLASH_IO0)