Dartmouth-Formula-Racing / DFR_CVC_2019

Dartmouth Formula Racing Central Vehicle Controller Codebase
10 stars 5 forks source link

Event-triggered SPI_routine_task #18

Closed alexnewman23 closed 5 years ago

alexnewman23 commented 5 years ago

Having trouble implementing xQueueSendfromISR() in order to wake up the SPI_routine_task. Leina checked the function of the CAN demo which also uses xQueueSendfromISR() and the demo functions well. Need to look into the differences in implementation of the CAN and SPI versions in order to get to bottom of problem

leina05 commented 5 years ago

Pretty sure that the SPI routine is too time-sensitive to break up using queues. It seems that the frequency of the SPI interrupts prevent the task from ever waking up even after the call to xQueueSendfromISR(). Tried using taskENTER_CRITICAL after xQueueReceive, still didn't work. Need to keep entire SPI routine within ISR.

Best thing is probably to use semaphores to protect SPI input/output vectors. The task that kicks off the SPI transmission can take the semaphore before doing so, then wait for an event/message that signals the end of the SPI transmission and give the semaphore back.