delay_div10_LPC(1); |
Oops, I replied to my reply. Set a GPIO rising edge interrupt on the hardware SSEL output pin and you will get an interrupt when the transfer is complete. I am successfully using this method with LPC11U24 and I assume it will work on others. If you are using multiple SSEL outputs that you are controlling manually, you still want to enable the hardware SSEL output on one of the available muxed pins, but leave it disconnected. The GPIO interrupt hardware will still monitor what's being driven on that unused pin and you'll get an interrupt when the transfer finishes. Then you can manually raise the SSEL output that you were using.
[EDIT: see the follow-up post I made on March 10, 2023. You don't need to connect the SSEL output back to an input pin, you can fire an interrupt from the output pin]
How about this: Enable an SSEL output pin and connect it back to another GPIO input pin, and use a edge (0->1) interrupt on that pin to detect the rising edge, which means that the transfer has completed. This would work, right? If you have multiple SPI devices on the channel, you will still have to drive their chip selects manually, but, you can still use the channel's automatic SSEL output to detect its rise to signal end of transmission. This at least will let you avoid polling.
This works! And you don't have to connect the SSEL output back to an input pin., You can set a GPIO edge interrupt on the SSEL output pin and you get an interrupt when SSEL is released. This works on LPC11U24 and I would assume on others.
int main(void) { CPL_init(); delay_LPC(8000); while(1) { k=0; spi_read(); delay_LPC(16); } return 0 ; } |
void SSP1_IRQHandler (void){ if(LPC_SSP1->MIS & 0x4){ cfg[k]=LPC_SSP1->DR; if(k<2)k++; else k=0; CS=1; BU_Therm=!BU_Therm; delay_div10_LPC(1); CS=0; } return; } |
LPC_SSP1->IMSC |= (0x01 << 2); NVIC_EnableIRQ(SSP1_IRQn); NVIC_SetPriority(SSP1_IRQn,0); |