hi everyone, I'm looking for a SPI library to use in generic application for cc2530 in zstack mesh. Is there any help?
I've revised hal_lcd but i don't get it. I'm looking forward for your helps.
thanks for your attentions.
regards
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hi everyone, I'm looking for a SPI library to use in generic application for cc2530 in zstack mesh. Is there any help?
I've revised hal_lcd but i don't get it. I'm looking forward for your helps.
thanks for your attentions.
regards
You can refer to the following defines in hal_board_cfg.h
/* ----------- XNV ---------- */
#define XNV_SPI_BEGIN() st(P1_3 = 0;)
#define XNV_SPI_TX(x) st(U1CSR &= ~0x02; U1DBUF = (x);)
#define XNV_SPI_RX() U1DBUF
#define XNV_SPI_WAIT_RXRDY() st(while (!(U1CSR & 0x02));)
#define XNV_SPI_END() st(P1_3 = 1;)
// The TI reference design uses UART1 Alt. 2 in SPI mode.
#define XNV_SPI_INIT() \
st( \
/* Mode select UART1 SPI Mode as master. */\
U1CSR = 0; \
\
/* Setup for 115200 baud. */\
U1GCR = 11; \
U1BAUD = 216; \
\
/* Set bit order to MSB */\
U1GCR |= BV(5); \
\
/* Set UART1 I/O to alternate 2 location on P1 pins. */\
PERCFG |= 0x02; /* U1CFG */\
\
/* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\
P1SEL |= 0xE0; /* SELP1_[7:4] */\
/* P1.1,2,3: reset, LCD CS, XNV CS. */\
P1SEL &= ~0x0E; \
P1 |= 0x0E; \
P1_1 = 0; \
P1DIR |= 0x0E; \
\
/* Give UART1 priority over Timer3. */\
P2SEL &= ~0x20; /* PRI2P1 */\
\
/* When SPI config is complete, enable it. */\
U1CSR |= 0x40; \
/* Release XNV reset. */\
P1_1 = 1; \
)
and also refer to how the following functions use SPI defines to do read/write to external SPI flash in hal_ota.c
static void HalSPIRead(uint32 addr, uint8 *pBuf, uint16 len);
static void HalSPIWrite(uint32 addr, uint8 *pBuf, uint16 len);
static void xnvSPIWrite(uint8 ch);