Other Parts Discussed in Thread: CC1310
首先参考这篇文章SimpleLink MCU代码移植指南:CC1310从VQFN48(7×7)到VQFN32(5×5)代码移植流程参考 - 嵌入式处理 - 技术文章 - E2E 设计支持 (ti.com),将CC1310_LAUNCHXL.h中除了SPI0的IO都赋值PIN_UNASSIGNED。
CC1310_LAUNCHXL.H:
#define CC1310_LAUNCHXL_DIO23_ANALOG PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO24_ANALOG PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO25_ANALOG PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO26_ANALOG PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO27_ANALOG PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO28_ANALOG PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO29_ANALOG PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO30_ANALOG PIN_UNASSIGNED /* Digital IOs */ #define CC1310_LAUNCHXL_DIO0 IOID_0 #define CC1310_LAUNCHXL_DIO1 IOID_1 #define CC1310_LAUNCHXL_DIO12 PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO15 PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO16_TDO PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO17_TDI PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO21 PIN_UNASSIGNED #define CC1310_LAUNCHXL_DIO22 PIN_UNASSIGNED /* Discrete Inputs */ #define CC1310_LAUNCHXL_PIN_BTN1 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PIN_BTN2 PIN_UNASSIGNED /* GPIO */ #define CC1310_LAUNCHXL_GPIO_LED_ON 1 #define CC1310_LAUNCHXL_GPIO_LED_OFF 0 /* I2C */ #define CC1310_LAUNCHXL_I2C0_SCL0 PIN_UNASSIGNED #define CC1310_LAUNCHXL_I2C0_SDA0 PIN_UNASSIGNED /* I2S */ #define CC1310_LAUNCHXL_I2S_ADO PIN_UNASSIGNED #define CC1310_LAUNCHXL_I2S_ADI PIN_UNASSIGNED #define CC1310_LAUNCHXL_I2S_BCLK PIN_UNASSIGNED #define CC1310_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED #define CC1310_LAUNCHXL_I2S_WCLK PIN_UNASSIGNED /* LEDs */ #define CC1310_LAUNCHXL_PIN_LED_ON 1 #define CC1310_LAUNCHXL_PIN_LED_OFF 0 #define CC1310_LAUNCHXL_PIN_RLED PIN_UNASSIGNED #define CC1310_LAUNCHXL_PIN_GLED PIN_UNASSIGNED /* PWM Outputs */ #define CC1310_LAUNCHXL_PWMPIN0 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PWMPIN1 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PWMPIN2 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PWMPIN3 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PWMPIN4 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PWMPIN5 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PWMPIN6 PIN_UNASSIGNED #define CC1310_LAUNCHXL_PWMPIN7 PIN_UNASSIGNED /* SPI */ #define CC1310_LAUNCHXL_SPI_FLASH_CS PIN_UNASSIGNED #define CC1310_LAUNCHXL_FLASH_CS_ON 0 #define CC1310_LAUNCHXL_FLASH_CS_OFF 1 /* SPI Board */ #define CC1310_LAUNCHXL_SPI0_MISO IOID_4 /* RF1.20 */ #define CC1310_LAUNCHXL_SPI0_MOSI IOID_5 /* RF1.18 */ #define CC1310_LAUNCHXL_SPI0_CLK IOID_7 /* RF1.16 */ #define CC1310_LAUNCHXL_SPI0_CSN IOID_6 #define CC1310_LAUNCHXL_SPI0_IRQ IOID_8 #define CC1310_LAUNCHXL_SPI0_CE IOID_9 #define CC1310_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1310_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1310_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED #define CC1310_LAUNCHXL_SPI1_CSN PIN_UNASSIGNED /* UART Board */ #define CC1310_LAUNCHXL_UART_RX PIN_UNASSIGNED /* RXD */ #define CC1310_LAUNCHXL_UART_TX PIN_UNASSIGNED /* TXD */ #define CC1310_LAUNCHXL_UART_CTS PIN_UNASSIGNED /* CTS */ #define CC1310_LAUNCHXL_UART_RTS PIN_UNASSIGNED /* RTS */
主函数如下:
void *mainThread(void *arg0) { uint16_t buf_num; for(buf_num = 0 ; buf_num < MASSAGE ; buf_num ++) { transmitBuffer[buf_num] = buf_num; } SPI_init(); SPI_Params_init(&spiParams); // Initialize SPI parameters spiParams.transferMode = SPI_MODE_BLOCKING; // spiParams.dataSize = 8; // 8-bit data size spiParams.mode = SPI_MASTER; //SPI MASTER spiParams.frameFormat = SPI_POL0_PHA1; //SPI POL0 PHA0 spiParams.bitRate = 4000000; //4MHZ spiTransaction.count = MASSAGE; spiTransaction.txBuf = (void *)transmitBuffer; spiTransaction.rxBuf = (void *)receiveBuffer; spi = SPI_open(Board_SPI0, &spiParams); if (spi == NULL) { while (1); // SPI_open() failed } SPI_transfer(spi,&spiTransaction); usleep(100); return (NULL); }
代码会在跑完SPI_transfer之后跑飞。代码在7X7封装上依然可以运行,但是在4X4上会跑飞。请问还有哪些地方需要修改,才可以正常工作?