* 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:
parent
79f4dd467e
commit
e834562455
1 changed files with 14 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
/* -*- C -*- */
|
/* -*- 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
|
#ifndef SPI_H
|
||||||
#define SPI_H
|
#define SPI_H
|
||||||
|
@ -230,11 +230,24 @@ void spi_init(void);
|
||||||
SPI_DISABLE();\
|
SPI_DISABLE();\
|
||||||
} while (0)
|
} 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)\
|
#define FASTSPI_READ_RAM_LE(p,a,c,n)\
|
||||||
do {\
|
do {\
|
||||||
SPI_ENABLE();\
|
SPI_ENABLE();\
|
||||||
FASTSPI_TX(0x80 | (a & 0x7F));\
|
FASTSPI_TX(0x80 | (a & 0x7F));\
|
||||||
FASTSPI_TX(((a >> 1) & 0xC0) | 0x20);\
|
FASTSPI_TX(((a >> 1) & 0xC0) | 0x20);\
|
||||||
|
SPI_WAITFORTx_ENDED();\
|
||||||
SPI_RXBUF;\
|
SPI_RXBUF;\
|
||||||
for (n = 0; n < (c); n++) {\
|
for (n = 0; n < (c); n++) {\
|
||||||
FASTSPI_RX(((u8_t*)(p))[n]);\
|
FASTSPI_RX(((u8_t*)(p))[n]);\
|
||||||
|
|
Loading…
Reference in a new issue