物联网中经常用到NFC功能,接下来我们介绍6621CXC驱动NFC芯片SI522,我们以simple例子介绍,添加相应接口 1)我们用到7,8,9,10,口,main.c文件头定义做修改 #define PIN_WAKEUP_0 2 // UART-RTS@EVB #define PIN_WAKEUP_1 24 // KEY1@EVB #define PIN_LED_0 13 #define PIN_LED_1 13//9 #define PIN_LED_2 13 #define PIN_LED_3 25 #define PIN_LED_4 13 #define PIN_LED_5 14 #define PIN_LED_6 14 #define PIN_LED_7 14 #define PIN_UART0_TX 5//7 #define PIN_UART1_TX 13//5 #define PIN_UART1_RX 6 2)添加example_spi函数 void example_spi(void) { CO_ALIGN(4) uint8_t txbuf[100] = {0}; // SPI DMA request 4bytes align CO_ALIGN(4) uint8_t rxbuf[100] = {0}; // SPI DMA request 4bytes align int i; for(i=0;i<100;i++) txbuf[i]=i; for(i=0;i<100;i++) rxbuf[i]=0; // Pinmux pinmux_config(7, PINMUX_SPI0_MST_SDA_I_CFG); /*MISO*/ pinmux_config(8, PINMUX_SPI0_MST_SDA_O_CFG); /*MOSI*/ pinmux_config(9, PINMUX_SPI0_MST_SCK_CFG); /*SCLK*/ pinmux_config(10, PINMUX_SPI0_MST_CSN_CFG); /*CSN */ // SPI Init spi_open(HS_SPI0, SPI_MODE_MASTER, SPI_TRANS_MODE_0, 200000); // Exchange data spi_master_cs_low(HS_SPI0); spi_master_exchange(HS_SPI0, txbuf, rxbuf, 10); spi_master_cs_high(HS_SPI0); log_debug_array_ex("rxbuf[0] \n", rxbuf,10); } 3)main函数修改 int main(void) { ble_stack_config(); hardware_init(); rwip_init(RESET_NO_ERROR); co_power_register_sleep_event(power_sleep_event_handler); log_debug("running %d\n", pmu_reboot_reason()); appm_init(); //example_i2c(); example_spi(); //co_timer_set(&simple_timer, 100, TIMER_REPEAT, simple_timer_handler, NULL); while(1) { rwip_schedule(); } } 4)程序打印输出 running 0 rxbuf[0] : 09 00 01 02 03 04 05 06 07 08 [10bytes] 5)SPI口波形数据如下截图 |