TWAI_TRANSMIT thread safety
Posted: Fri Dec 15, 2023 4:42 pm
Is it safe to use twai_transmit() from multiple tasks?
If not, are critical sections appropriate like so:
Or is it better to pass messages to a single task for transmission?
If not, are critical sections appropriate like so:
- //Disables interrupts and context-switching during twai_transmit
- void threadSafeTwaiTransmit(twai_message_t message){
- taskENTER_CRITICAL(&my_spinlock);
- twai_transmit(&message, pdMS_TO_TICKS(0));//(message, ticks to wait if tx queue full)
- taskEXIT_CRITICAL(&my_spinlock);
- }