void SQUEUE_Init(void) { SQUEUE_Queue = FRTOS1_xQueueCreate(SQUEUE_LENGTH, SQUEUE_ITEM_SIZE); if (SQUEUE_Queue==NULL) { for(;;){} /* out of memory? */ } FRTOS1_vQueueAddToRegistry(SQUEUE_Queue, "ShellQueue"); }
void VS_Init(void) { MCS_SetVal(); /* chip select is low active, deselect it */ DCS_SetVal(); /* data mode is low active, deselect data mode */ VS_SPIDataReceivedFlag = FALSE; /* Initialization */ spiSem = FRTOS1_xSemaphoreCreateRecursiveMutex(); if (spiSem==NULL) { /* creation failed? */ for(;;); } FRTOS1_vQueueAddToRegistry(spiSem, "SpiSem"); }
void DRV_Init(void) { DRV_Status.mode = DRV_MODE_NONE; DRV_Status.speed.left = 0; DRV_Status.speed.right = 0; DRV_Status.pos.left = 0; DRV_Status.pos.right = 0; DRV_Queue = FRTOS1_xQueueCreate(QUEUE_LENGTH, QUEUE_ITEM_SIZE); if (DRV_Queue==NULL) { for(;;){} /* out of memory? */ } FRTOS1_vQueueAddToRegistry(DRV_Queue, "Drive"); if (FRTOS1_xTaskCreate(DriveTask, "Drive", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+3, NULL) != pdPASS) { for(;;){} /* error */ } }
void REF_Init(void) { #if REF_START_STOP_CALIB FRTOS1_vSemaphoreCreateBinary(REF_StartStopSem); if (REF_StartStopSem==NULL) { /* semaphore creation failed */ for(;;){} /* error */ } (void)FRTOS1_xSemaphoreTake(REF_StartStopSem, 0); /* empty token */ FRTOS1_vQueueAddToRegistry(REF_StartStopSem, "RefStartStopSem"); #endif refState = REF_STATE_INIT; timerHandle = RefCnt_Init(NULL); /*! \todo You might need to adjust priority or other task settings */ if (FRTOS1_xTaskCreate(ReflTask, "Refl", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } }
/*! \brief Initializes module */ void SEM_Init(void) { vSemaphoreCreateBinary(MySemTest); if (MySemTest == NULL) { for(;;); /* creation failed */ } FRTOS1_vQueueAddToRegistry(MySemTest, "Sem"); /* if (FRTOS1_xTaskCreate(vMasterTask, "Master", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} } if (FRTOS1_xTaskCreate(vSlaveTask, "Slave", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} } */ }
static portTASK_FUNCTION(vMasterTask, pvParameters) { /*! \todo Implement functionality */ xSemaphoreHandle sem = NULL; (void)pvParameters; /* parameter not used */ sem = FRTOS1_xSemaphoreCreateBinary(); if (sem==NULL) { /* semaphore creation failed */ for(;;){} /* error */ } FRTOS1_vQueueAddToRegistry(sem, "IPC_Sem"); /* create slave task */ if (FRTOS1_xTaskCreate(vSlaveTask, "Slave", configMINIMAL_STACK_SIZE, sem, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } for(;;) { if (sem != NULL) { /* valid semaphore? */ (void)xSemaphoreGive(sem); /* give control to other task */ FRTOS1_vTaskDelay(1000/portTICK_RATE_MS); } } }