Call spi_device_transmit inside ISR

Deejay
Posts: 2
Joined: Wed Nov 15, 2017 11:33 am

Call spi_device_transmit inside ISR

Postby Deejay » Wed Nov 15, 2017 11:40 am

Hi there,

I'm currently building a LED Matrix which is multiplexed. I want to achieve this by calling an ISR every x ms and send the data inside the ISR via SPI. When I do this it doesn't work, because it fails getting a result from spi_device_get_trans_result

Can I even use spi_device_transmit inside an ISR? If not how can I achieve a "timed" update call instead?

Thanks in advance.

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: Call spi_device_transmit inside ISR

Postby ESP_Sprite » Thu Nov 16, 2017 4:17 pm

There are quite few functions you can call safely from an ISR... but the FreeRTOS functions that end in FromISR are always safe. Suggest you use this to start off the transfer: have a thread that waits on a semaphore or task notification and then starts the next transfer, and in the ISR use xSemaphoreGiveFromISR or vTaskNotifyGiveFromISR to kick off the next transfer.

Also: you may be interested in this: viewtopic.php?f=17&t=3188

Deejay
Posts: 2
Joined: Wed Nov 15, 2017 11:33 am

Re: Call spi_device_transmit inside ISR

Postby Deejay » Sun Nov 19, 2017 11:33 am

Thanks for your answer, that really helps me. I will look into the freertos functions.

Who is online

Users browsing this forum: Bing [Bot] and 115 guests