GEX core repository.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gex-core/tasks/task_sched.c

63 lines
1.4 KiB

7 years ago
//
// Created by MightyPork on 2017/11/21.
//
#include "platform.h"
#include "task_sched.h"
extern osMessageQId queSchedHandle;
7 years ago
volatile uint32_t jobQueHighWaterMark = 0;
7 years ago
/**
* Schedule a function for later execution in the jobs thread
*
* @param callback - the callback function
*/
void scheduleJob(Job *job)
7 years ago
{
QueueHandle_t que = queSchedHandle;
7 years ago
assert_param(que != NULL);
assert_param(job->cb != NULL);
uint32_t count;
if (inIRQ()) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
assert_param(pdPASS == xQueueSendFromISR(que, job, &xHigherPriorityTaskWoken));
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
#if USE_STACK_MONITOR
count = (uint32_t) uxQueueMessagesWaitingFromISR(que);
#endif
} else {
assert_param(pdPASS == xQueueSend(que, job, 100));
#if USE_STACK_MONITOR
count = (uint32_t) uxQueueMessagesWaiting(que);
#endif
}
#if USE_STACK_MONITOR
jobQueHighWaterMark = MAX(jobQueHighWaterMark, count);
7 years ago
#endif
}
/**
* job queue handler (for use in interrupts to do longer stuff on a thread)
7 years ago
*
* @param argument
*/
void TaskJobQueue(const void *argument)
7 years ago
{
dbg("> High priority queue task started!");
struct sched_que_item job;
while (1) {
xQueueReceive(queSchedHandle, &job, osWaitForever);
7 years ago
assert_param(job.cb != NULL);
job.cb(&job);
}
}