spi: support 32- and 64-kB erase blocks
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
cbf4958236
commit
ac349ce1a1
@ -70,7 +70,8 @@ void spiWriteSecurity(struct ff_spi *spi, uint8_t sr, uint8_t security[256]);
|
||||
int spiSetType(struct ff_spi *spi, enum spi_type type);
|
||||
int spiRead(struct ff_spi *spi, uint32_t addr, uint8_t *data, unsigned int count);
|
||||
int spiIsBusy(struct ff_spi *spi);
|
||||
int spiBeginErase(struct ff_spi *spi, uint32_t erase_addr);
|
||||
int spiBeginErase32(struct ff_spi *spi, uint32_t erase_addr);
|
||||
int spiBeginErase64(struct ff_spi *spi, uint32_t erase_addr);
|
||||
int spiBeginWrite(struct ff_spi *spi, uint32_t addr, const void *data, unsigned int count);
|
||||
|
||||
struct spi_id spiId(struct ff_spi *spi);
|
||||
|
21
sw/src/spi.c
21
sw/src/spi.c
@ -32,7 +32,7 @@ static void gpioWrite(int pin, int val) {
|
||||
do_mirror |= 1 << pin;
|
||||
else
|
||||
do_mirror &= ~(1 << pin);
|
||||
// bbspi_do_write(do_mirror);
|
||||
bbspi_do_write(do_mirror);
|
||||
}
|
||||
|
||||
static int gpioRead(int pin) {
|
||||
@ -40,7 +40,7 @@ static int gpioRead(int pin) {
|
||||
}
|
||||
|
||||
static void gpioSync(void) {
|
||||
bbspi_do_write(do_mirror);
|
||||
// bbspi_do_write(do_mirror);
|
||||
}
|
||||
|
||||
#define SPI_ONLY_SINGLE
|
||||
@ -706,7 +706,7 @@ int spiIsBusy(struct ff_spi *spi) {
|
||||
return spiReadStatus(spi, 1) & (1 << 0);
|
||||
}
|
||||
|
||||
int spiBeginErase(struct ff_spi *spi, uint32_t erase_addr) {
|
||||
int spiBeginErase32(struct ff_spi *spi, uint32_t erase_addr) {
|
||||
// Enable Write-Enable Latch (WEL)
|
||||
spiBegin(spi);
|
||||
spiCommand(spi, 0x06);
|
||||
@ -721,6 +721,21 @@ int spiBeginErase(struct ff_spi *spi, uint32_t erase_addr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spiBeginErase64(struct ff_spi *spi, uint32_t erase_addr) {
|
||||
// Enable Write-Enable Latch (WEL)
|
||||
spiBegin(spi);
|
||||
spiCommand(spi, 0x06);
|
||||
spiEnd(spi);
|
||||
|
||||
spiBegin(spi);
|
||||
spiCommand(spi, 0xD8);
|
||||
spiCommand(spi, erase_addr >> 16);
|
||||
spiCommand(spi, erase_addr >> 8);
|
||||
spiCommand(spi, erase_addr >> 0);
|
||||
spiEnd(spi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spiBeginWrite(struct ff_spi *spi, uint32_t addr, const void *v_data, unsigned int count) {
|
||||
uint8_t write_cmd = 0x02;
|
||||
const uint8_t *data = v_data;
|
||||
|
Loading…
Reference in New Issue
Block a user