Changed to monitor the UART transmitter buffer ready flag instead of the UART transmitter empty flag. This almost doubles the speed of transmitting data to CC2420. Patch by James Brown.
This commit is contained in:
parent
ebd91b9f9d
commit
3a8ee769cb
|
@ -1,5 +1,5 @@
|
||||||
/* -*- C -*- */
|
/* -*- C -*- */
|
||||||
/* @(#)$Id: spi.h,v 1.4 2007/11/18 12:27:44 ksb Exp $ */
|
/* @(#)$Id: spi.h,v 1.5 2009/08/31 12:06:34 nifi Exp $ */
|
||||||
|
|
||||||
#ifndef SPI_H
|
#ifndef SPI_H
|
||||||
#define SPI_H
|
#define SPI_H
|
||||||
|
@ -20,8 +20,8 @@ void spi_init(void);
|
||||||
|
|
||||||
#define FASTSPI_TX(x)\
|
#define FASTSPI_TX(x)\
|
||||||
do {\
|
do {\
|
||||||
|
SPI_WAITFOREOTxBUF();\
|
||||||
SPI_TXBUF = x;\
|
SPI_TXBUF = x;\
|
||||||
SPI_WAITFOREOTx();\
|
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define FASTSPI_RX(x)\
|
#define FASTSPI_RX(x)\
|
||||||
|
@ -46,6 +46,7 @@ void spi_init(void);
|
||||||
for (spiCnt = 0; spiCnt < (c); spiCnt++) {\
|
for (spiCnt = 0; spiCnt < (c); spiCnt++) {\
|
||||||
FASTSPI_TX(((u8_t*)(p))[spiCnt]);\
|
FASTSPI_TX(((u8_t*)(p))[spiCnt]);\
|
||||||
}\
|
}\
|
||||||
|
SPI_WAITFOREOTx();\
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,6 +94,7 @@ void spi_init(void);
|
||||||
FASTSPI_TX_ADDR(a);\
|
FASTSPI_TX_ADDR(a);\
|
||||||
FASTSPI_TX((u8_t) ((v) >> 8));\
|
FASTSPI_TX((u8_t) ((v) >> 8));\
|
||||||
FASTSPI_TX((u8_t) (v));\
|
FASTSPI_TX((u8_t) (v));\
|
||||||
|
SPI_WAITFOREOTx();\
|
||||||
SPI_DISABLE();\
|
SPI_DISABLE();\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -133,6 +135,7 @@ void spi_init(void);
|
||||||
for (i = 0; i < (c); i++) {\
|
for (i = 0; i < (c); i++) {\
|
||||||
FASTSPI_TX(((u8_t*)(p))[i]);\
|
FASTSPI_TX(((u8_t*)(p))[i]);\
|
||||||
}\
|
}\
|
||||||
|
SPI_WAITFOREOTx();\
|
||||||
SPI_DISABLE();\
|
SPI_DISABLE();\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -142,6 +145,7 @@ void spi_init(void);
|
||||||
for (u8_t spiCnt = 0; spiCnt < (c); spiCnt++) {\
|
for (u8_t spiCnt = 0; spiCnt < (c); spiCnt++) {\
|
||||||
FASTSPI_TX(((u8_t*)(p))[spiCnt]);\
|
FASTSPI_TX(((u8_t*)(p))[spiCnt]);\
|
||||||
}\
|
}\
|
||||||
|
SPI_WAITFOREOTx();\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define FASTSPI_READ_FIFO_BYTE(b)\
|
#define FASTSPI_READ_FIFO_BYTE(b)\
|
||||||
|
@ -208,6 +212,7 @@ void spi_init(void);
|
||||||
for (n = 0; n < (c); n++) {\
|
for (n = 0; n < (c); n++) {\
|
||||||
FASTSPI_TX(((u8_t*)(p))[n]);\
|
FASTSPI_TX(((u8_t*)(p))[n]);\
|
||||||
}\
|
}\
|
||||||
|
SPI_WAITFOREOTx();\
|
||||||
SPI_DISABLE();\
|
SPI_DISABLE();\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* -*- C -*- */
|
/* -*- C -*- */
|
||||||
/* @(#)$Id: contiki-conf.h,v 1.57 2009/06/29 09:54:39 nifi Exp $ */
|
/* @(#)$Id: contiki-conf.h,v 1.58 2009/08/31 12:06:35 nifi Exp $ */
|
||||||
|
|
||||||
#ifndef CONTIKI_CONF_H
|
#ifndef CONTIKI_CONF_H
|
||||||
#define CONTIKI_CONF_H
|
#define CONTIKI_CONF_H
|
||||||
|
@ -170,10 +170,12 @@ typedef unsigned long off_t;
|
||||||
#define SPI_TXBUF U0TXBUF
|
#define SPI_TXBUF U0TXBUF
|
||||||
#define SPI_RXBUF U0RXBUF
|
#define SPI_RXBUF U0RXBUF
|
||||||
|
|
||||||
/* USART0 Tx buffer ready? */
|
/* USART0 Tx ready? */
|
||||||
#define SPI_WAITFOREOTx() while ((U0TCTL & TXEPT) == 0)
|
#define SPI_WAITFOREOTx() while ((U0TCTL & TXEPT) == 0)
|
||||||
/* USART0 Rx buffer ready? */
|
/* USART0 Rx buffer ready? */
|
||||||
#define SPI_WAITFOREORx() while ((IFG1 & URXIFG0) == 0)
|
#define SPI_WAITFOREORx() while ((IFG1 & URXIFG0) == 0)
|
||||||
|
/* USART0 Tx buffer ready? */
|
||||||
|
#define SPI_WAITFOREOTxBUF() while ((IFG1 & UTXIFG0) == 0)
|
||||||
|
|
||||||
#define SCK 1 /* P3.1 - Output: SPI Serial Clock (SCLK) */
|
#define SCK 1 /* P3.1 - Output: SPI Serial Clock (SCLK) */
|
||||||
#define MOSI 2 /* P3.2 - Output: SPI Master out - slave in (MOSI) */
|
#define MOSI 2 /* P3.2 - Output: SPI Master out - slave in (MOSI) */
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)$Id: xmem.c,v 1.8 2009/05/11 15:26:24 nvt-se Exp $
|
* @(#)$Id: xmem.c,v 1.9 2009/08/31 12:06:35 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,12 +70,6 @@
|
||||||
#define SPI_FLASH_INS_RES 0xab
|
#define SPI_FLASH_INS_RES 0xab
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
spi_tx(unsigned byte)
|
|
||||||
{
|
|
||||||
FASTSPI_TX(byte);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
write_enable(void)
|
write_enable(void)
|
||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
|
@ -83,7 +77,8 @@ write_enable(void)
|
||||||
s = splhigh();
|
s = splhigh();
|
||||||
SPI_FLASH_ENABLE();
|
SPI_FLASH_ENABLE();
|
||||||
|
|
||||||
spi_tx(SPI_FLASH_INS_WREN);
|
FASTSPI_TX(SPI_FLASH_INS_WREN);
|
||||||
|
SPI_WAITFOREOTx();
|
||||||
|
|
||||||
SPI_FLASH_DISABLE();
|
SPI_FLASH_DISABLE();
|
||||||
splx(s);
|
splx(s);
|
||||||
|
@ -99,7 +94,8 @@ read_status_register(void)
|
||||||
s = splhigh();
|
s = splhigh();
|
||||||
SPI_FLASH_ENABLE();
|
SPI_FLASH_ENABLE();
|
||||||
|
|
||||||
spi_tx(SPI_FLASH_INS_RDSR);
|
FASTSPI_TX(SPI_FLASH_INS_RDSR);
|
||||||
|
SPI_WAITFOREOTx();
|
||||||
|
|
||||||
FASTSPI_CLEAR_RX();
|
FASTSPI_CLEAR_RX();
|
||||||
FASTSPI_RX(u);
|
FASTSPI_RX(u);
|
||||||
|
@ -137,10 +133,11 @@ erase_sector(unsigned long offset)
|
||||||
s = splhigh();
|
s = splhigh();
|
||||||
SPI_FLASH_ENABLE();
|
SPI_FLASH_ENABLE();
|
||||||
|
|
||||||
spi_tx(SPI_FLASH_INS_SE);
|
FASTSPI_TX(SPI_FLASH_INS_SE);
|
||||||
spi_tx(offset >> 16); /* MSB */
|
FASTSPI_TX(offset >> 16); /* MSB */
|
||||||
spi_tx(offset >> 8);
|
FASTSPI_TX(offset >> 8);
|
||||||
spi_tx(offset >> 0); /* LSB */
|
FASTSPI_TX(offset >> 0); /* LSB */
|
||||||
|
SPI_WAITFOREOTx();
|
||||||
|
|
||||||
SPI_FLASH_DISABLE();
|
SPI_FLASH_DISABLE();
|
||||||
splx(s);
|
splx(s);
|
||||||
|
@ -174,10 +171,11 @@ xmem_pread(void *_p, int size, unsigned long offset)
|
||||||
s = splhigh();
|
s = splhigh();
|
||||||
SPI_FLASH_ENABLE();
|
SPI_FLASH_ENABLE();
|
||||||
|
|
||||||
spi_tx(SPI_FLASH_INS_READ);
|
FASTSPI_TX(SPI_FLASH_INS_READ);
|
||||||
spi_tx(offset >> 16); /* MSB */
|
FASTSPI_TX(offset >> 16); /* MSB */
|
||||||
spi_tx(offset >> 8);
|
FASTSPI_TX(offset >> 8);
|
||||||
spi_tx(offset >> 0); /* LSB */
|
FASTSPI_TX(offset >> 0); /* LSB */
|
||||||
|
SPI_WAITFOREOTx();
|
||||||
|
|
||||||
FASTSPI_CLEAR_RX();
|
FASTSPI_CLEAR_RX();
|
||||||
for(; p < end; p++) {
|
for(; p < end; p++) {
|
||||||
|
@ -207,14 +205,15 @@ program_page(unsigned long offset, const unsigned char *p, int nbytes)
|
||||||
s = splhigh();
|
s = splhigh();
|
||||||
SPI_FLASH_ENABLE();
|
SPI_FLASH_ENABLE();
|
||||||
|
|
||||||
spi_tx(SPI_FLASH_INS_PP);
|
FASTSPI_TX(SPI_FLASH_INS_PP);
|
||||||
spi_tx(offset >> 16); /* MSB */
|
FASTSPI_TX(offset >> 16); /* MSB */
|
||||||
spi_tx(offset >> 8);
|
FASTSPI_TX(offset >> 8);
|
||||||
spi_tx(offset >> 0); /* LSB */
|
FASTSPI_TX(offset >> 0); /* LSB */
|
||||||
|
|
||||||
for(; p < end; p++) {
|
for(; p < end; p++) {
|
||||||
spi_tx(~*p);
|
FASTSPI_TX(~*p);
|
||||||
}
|
}
|
||||||
|
SPI_WAITFOREOTx();
|
||||||
|
|
||||||
SPI_FLASH_DISABLE();
|
SPI_FLASH_DISABLE();
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
Loading…
Reference in a new issue