* Fixed FASTSPI_READ_RAM_LE to wait for tx end before reading

* Added FASTSPI_WRITE_RAM_BE to write to RAM (big-endian order)
This commit is contained in:
nifi 2010-03-15 23:01:37 +00:00
parent 79f4dd467e
commit e834562455

View File

@ -1,5 +1,5 @@
/* -*- C -*- */
/* @(#)$Id: spi.h,v 1.6 2009/09/07 11:31:26 nifi Exp $ */
/* @(#)$Id: spi.h,v 1.7 2010/03/15 23:01:37 nifi Exp $ */
#ifndef SPI_H
#define SPI_H
@ -230,11 +230,24 @@ void spi_init(void);
SPI_DISABLE();\
} while (0)
#define FASTSPI_WRITE_RAM_BE(p,a,c,n) \
do { \
SPI_ENABLE(); \
FASTSPI_TX(0x80 | (a & 0x7F)); \
FASTSPI_TX((a >> 1) & 0xC0); \
for (n = (c); n > 0; n--) { \
FASTSPI_TX(((uint8_t *)(p))[n - 1]); \
} \
SPI_WAITFORTx_ENDED(); \
SPI_DISABLE(); \
} while (0)
#define FASTSPI_READ_RAM_LE(p,a,c,n)\
do {\
SPI_ENABLE();\
FASTSPI_TX(0x80 | (a & 0x7F));\
FASTSPI_TX(((a >> 1) & 0xC0) | 0x20);\
SPI_WAITFORTx_ENDED();\
SPI_RXBUF;\
for (n = 0; n < (c); n++) {\
FASTSPI_RX(((u8_t*)(p))[n]);\