大家好、我正在寻找一个 SPI 库、用于 ZStack 网状网络中的 CC2530的通用应用。 有什么帮助吗?
我已经修改了 hal_LCD、但我没有得到它。 我期待您的帮助。
感谢您的关注。
此致
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.
您可以在 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;)
// TI 参考设计在 SPI 模式下使用 UART1 Alt. 2。
#define XNV_SPI_init ()\
ST(\
/*模式选择 UART1 SPI 模式作为主器件。 */\
U1CSR = 0;\
\
115200波特的//设置。 */\
U1GCR = 11;\
U1BAUD = 216;\
\
/*将位顺序设置为 MSB */\
U1GCR |= BV (5);\
\
/*将 UART1 I/O 设置为 P1引脚上的替代2个位置。 */\
PERCFG |= 0x02; // U1CFG *//
\
/*在 I/O 引脚上选择外设功能、但 SS 保留为 GPIO 以进行单独控制。 */\
P1SEL |= 0xE0; /* SELP1_[7:4]*/\
/* P1.1、2、3:复位、LCD CS、XNV CS。 */\
P1SEL &=~0x0E;\
P1 |= 0x0E;\
P1_1 = 0;\
P1DIR |= 0x0E;\
\
/*将 UART1优先于 Timer3。 */\
P2SEL &=~0x20; /* PRI2P1 */\
\
/* SPI 配置完成后,将其启用。 */\
U1CSR |= 0x40;\
/*释放 XNV 复位。 */\
P1_1 = 1;\
)
还请参阅以下函数如何使用 SPI 定义对 hal_ota.c 中的外部 SPI 闪存执行读/写操作
静态空 HalSPIRead (uint32 addr、uint8 *pBuf、uint16 len);
静态空 HalSPIWrite (uint32 addr、uint8 *pBuf、uint16 len);
静态空 xnvSPIWrite (uint8 ch);