Hi all,
I am using a custom board with NRF 52840 with SDK15.2 as slave and STM as master. I cannot receive right data, but the data to STM is right.
void spis_incoming_msg_packet_handling(uint8_t *tmp, int size) {
for(int i = 0 ;i< size;i++)
m_tx_buf[i+1] = tmp[i];
tx_size = size;
if(tmp[0]==0xAA){
if(tmp[1] == 0x01 ||tmp[1] == 0x02){
int tmp_size = (int) tmp[2];
uint16_t tmpLength = (uint16_t)tmp_size;
if(tmp[tmp_size+3] == 0xBB){
for(int i = 0 ;i< tmp_size;i++){
tx_data[i]=tmp[i+2];
}
m_length=size;
if(isConnect)
ble_nus_data_send(&m_nus, tx_data, &tmpLength, m_conn_handle);
}
}
}
}
void spis_event_handler(nrf_drv_spis_event_t event) {
if (event.evt_type == NRF_DRV_SPIS_XFER_DONE) {
spis_xfer_done = true;
printf("enter handler");
spis_incoming_msg_packet_handling(m_rx_buf, 100);
}
}
#if defined(SPI_MODULE)
void switchToSPIS() {
printf("activating SPIS");
nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;
//spis_config.csn_pullup = NRF_GPIO_PIN_PULLUP; // Test 01
//spis_config.csn_pullup = NRF_GPIO_PIN_NOPULL; // Test 02
//spis_config.csn_pullup = NRF_GPIO_PIN_PULLDOWN; // Test 03
spis_config.csn_pin = 4; //29 //7 APP_SPIS_CS_PIN
spis_config.miso_pin = 8; //28 // 8 APP_SPIS_MISO_PIN
spis_config.mosi_pin = NRF_GPIO_PIN_MAP(1,9); //4 // 9 APP_SPIS_MOSI_PIN
spis_config.sck_pin = 6; //3 // 10 APP_SPIS_SCK_PIN
nrf_drv_spis_init(&spis, &spis_config, spis_event_handler);
}
The above are the setup, and the following are the part that prepare buffer.
m_tx_buf[0] = 0xAA; m_tx_buf[tx_size-1]=0xCC; nrf_drv_spis_buffers_set(&spis, m_tx_buf, tx_size, m_rx_buf, 100);
What I got from STM is AAFFFFF...00000CC, may I know what is the problem? As the code works on nrf 52832, just changing the pin. I am not sure if any config is set wrong.
Best regards,
Marco Lai