I am using SSP V1.1.0alpha.
My SPI code kept causing an exception that would land me in Default_Handler().
I traced the problem to a bug in r_sci_sspi_spei_isr_common() where an element of the callback argument structure is not set.
A context diff of the fix is shown below.
*** r_sci_spi_original.c 2016-05-13 08:10:14.882357400 -0400
--- r_sci_spi_fixed.c 2016-05-13 07:59:54.731517100 -0400
***************
*** 832,861 ****
--- 832,872 ----
/***************************************************************************************************************
* @brief This function is common ISR handler for RSPI SPEI-error interrupts.
*
* @param[in] channel Channel number to use.
* @retval void
***************************************************************************************************************/
void r_sci_sspi_spei_isr_common (uint32_t channel)
{
spi_callback_args_t sspi_cb_data;
/* Get the error status and return back through the caller function */
if (NULL != g_sspi_handles[channel].p_callback)
{
sspi_cb_data.channel = channel;
+ /**
+ * BUG FIX:
+ *
+ * sspi_cb_data.p_context was not set.
+ * If this code executed, an exception would be thrown (eventually) because
+ * sspi_cb_data.p_context would point to whatever garbage happened to be
+ * on the stack rather than pointing to XXX.p_ctrl.
+ */
+ sspi_cb_data.p_context = g_sspi_handles[channel].p_context;
+ /* End of Bug Fix */
+
if (HW_SCI_OverRunErrorCheck(channel))
{
sspi_cb_data.event = SPI_EVENT_ERR_OVERRUN;
}
else if (HW_SCI_ParityErrorCheck(channel))
{
sspi_cb_data.event = SPI_EVENT_ERR_PARITY;
}
else if (HW_SCI_SPIModeFaultCheck(channel))
{
sspi_cb_data.event = SPI_EVENT_ERR_MODE_FAULT;
}
else if (HW_SCI_FramingErrorCheck(channel))
{
sspi_cb_data.event = SPI_EVENT_ERR_FRAMING;