SpinLock API introduction in FreeRTOS SMP architecture: Create smp task to specified cpu: bk_err_t rtos_create_thread_with_affinity( beken_thread_t *thread, uint32_t affinity, uint8_t priority, const char* name, beken_thread_function_t function, uint32_t stack_size, beken_thread_arg...
/* lubancat ledtest*/#include "lubancat_led_test.h"void prvCmdQuRunTask(void *pvParameters){... cvi_spinlock_init();printf("prvCmdQuRunTask run\n");...for(;;){xQueueReceive(gTaskCtx[E_QUEUE_CMDQU].queHandle,&rtos_cmdq, portMAX_DELAY);switch(rtos_cmdq.cmd_id){caseSYS_CMD_...
vPortSetBASEPRI(x)前面已经说明,ulPortRaiseBASEPRI()位于也portmacro.h文件中: staticportFORCE_INLINE uint32_t ulPortRaiseBASEPRI(void) { uint32_t ulReturn, ulNewBASEPRI=configMAX_SYSCALL_INTERRUPT_PRIORITY;__asm {/*Set BASEPRI to the max syscall priority to effect a critical section.*/mrs ul...
portEXIT_CRITICAL(&spinlock); Note that these guards also disable interrupts (up to the priority set byconfigMAX_SYSCALL_INTERRUPT_PRIORITYin the FreeRTOS config file). In ESP-IDF we must also provide these critical section guards with a spinlock. This spinlock works much like a mutex, but i...
static SemaphoreHandle_t sem_done_reading = NULL; static portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; static QueueHandle_t msg_queue; static volatile uint16_t buf_0[BUF_LEN]; // One buffer in the pair static volatile uint16_t buf_1[BUF_LEN]; // The other buffer in the pair...
I would not do parameter passing via global variables not protected by mutex ( spinlock ) In ESP-IDF there are proper mechanisms to pass data between tasks ( queue ... ), gpio_task received data, sent it to the queue, oled_task took it from the queue and sent it to the screen boar...
DEFINE_CVI_SPINLOCK(mailbox_lock, SPIN_MBOX); #include "hal_dw_i2c.h" void my_task_test() { uint8_t data= 0,data_read; hal_i2c_init(I2C0); printf("hal_i2c_init after\n"); uint8_t *data_write =&data; for (;;) {
4 changes: 4 additions & 0 deletions 4 components/freertos/test_apps/freertos/port/test_spinlocks.c Original file line numberDiff line numberDiff line change @@ -20,6 +20,8 @@ #include "test_utils.h" #if !CONFIG_FREERTOS_SMP // Known issue in Amazon SMP FreeRTOS port IDF-6204 ...
message = mailbox_message_create_from_term(type, t); // Ensure we can acquire the spinlock if (smp_spinlock_trylock(&glb->processes_spinlock)) { // We can send the message. mailbox_enqueue_message(p, message); scheduler_signal_message_from_task(p); ...
their own synchronization primitives using essentially spinlocks (which you shouldn't do between threads in the first place in a RTOS context), I can't see any clear use case where that would be the case. Again, if you have a counter-example, I would be mightily interested in hearing it...