stm32f103c8t6端按照官方给的格式指令将数据传送查看是否正常
- uint8_t* data = (uint8_t *)malloc(5);
- memset(data, 0x00, 5);
- data[0] = 0x01;
- int* len2 = (int*)(data + 1);
- *len2 = 4;
- HAL_StatusTypeDef re = HAL_SPI_Transmit(&hspi1,data,5,0xFFFF);
- static IRAM_ATTR void spi_intr(void *arg)
- {
- spi_host_t host;
- uint32_t trans_done;
- uint32_t cnt = 0;
- if (READ_PERI_REG(DPORT_SPI_INT_STATUS_REG) & DPORT_SPI_INT_STATUS_SPI0) { // DPORT_SPI_INT_STATUS_SPI0
- trans_done = SPI0.slave.val & 0x1F;
- SPI0.slave.val &= ~0x3FF;
- host = CSPI_HOST;
- } else if (READ_PERI_REG(DPORT_SPI_INT_STATUS_REG) & DPORT_SPI_INT_STATUS_SPI1) { // DPORT_SPI_INT_STATUS_SPI1
- ets_printf("TIP: SPI1.slave.val 0 is %d\r\n",SPI1.slave.val);
- trans_done = SPI1.slave.val & 0x1F;
- ets_printf("TIP: trans_done is %d\r\n",trans_done);
- SPI1.slave.val &= ~0x1F;
- ets_printf("TIP: SPI1.slave.val 1 is %d\r\n",SPI1.slave.val);
- // Hardware issues: We need to wait for the hardware to clear the registers successfully.
- while ((SPI1.slave.val & 0x1F) != 0) {
- if (cnt >= 50) {
- ets_printf("WARNING: waiting too much time, maybe error\r\n");
- cnt = 0;
- }
- SPI1.slave.val &= ~0x1F;
- cnt++;
- //ets_printf("TIP: SPI1.slave.val 2 is %d\r\n",SPI1.slave.val);
- }
- host = HSPI_HOST;
- } else {
- return;
- }
- ets_printf("TIP: if generated by software");
- if (spi_object[host]) {
- // Hardware has no interrupt flag, which can be generated by software.
- trans_done &= spi_object[host]->intr_enable.val;
- ets_printf("TIP: trans_done is %d\r\n",trans_done);
- ets_printf("TIP: spi_object[host]->event_cb && trans_done is %d\r\n",spi_object[host]->event_cb && trans_done);
- if (spi_object[host]->event_cb && trans_done != 0) {
- spi_object[host]->event_cb(SPI_TRANS_DONE_EVENT, &trans_done);
- }
- }
- }
[REC]TIP: SPI1.slave.val 0 is 2003829244
TIP: trans_done is 28
TIP: SPI1.slave.val 1 is 1936720380
WARNING: waiting too much time, maybe error
WARNING: waiting too much time, maybe error
更多WARNING: waiting too much time, maybe error......
接线与官方给的一致
| Signal | (ESP8266)Slave | (STM32)Master |
| --------- | ------ | ------ |
| SCLK | GPIO14 | GPIO14 |
| MISO | GPIO12 | GPIO12 |
| MOSI | GPIO13 | GPIO13 |
| CS | GPIO15 | GPIO15 |
| HANDSHARK | GPIO4 | GPIOA PIN1 |
| GND | GND | GND |
作为初学者,对该问题很困扰,不知道该如何下手,虚心请教一下各位。