freertos related macros
This commit is contained in:
parent
197201458e
commit
bdb3d48d8a
|
@ -51,7 +51,7 @@
|
||||||
#define configTICK_RATE_HZ ((TickType_t)1000)
|
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||||
#define configMAX_PRIORITIES 5
|
#define configMAX_PRIORITIES 5
|
||||||
#define configMINIMAL_STACK_SIZE ((unsigned short)40)
|
#define configMINIMAL_STACK_SIZE ((unsigned short)40)
|
||||||
#define configMAX_TASK_NAME_LEN 20
|
#define configMAX_TASK_NAME_LEN 10
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
#define configIDLE_SHOULD_YIELD 1
|
#define configIDLE_SHOULD_YIELD 1
|
||||||
#define configUSE_TASK_NOTIFICATIONS 1
|
#define configUSE_TASK_NOTIFICATIONS 1
|
||||||
|
|
19
app/common.h
19
app/common.h
|
@ -39,4 +39,23 @@
|
||||||
__typeof__ (b) _b = (b); \
|
__typeof__ (b) _b = (b); \
|
||||||
_a < _b ? _a : _b; \
|
_a < _b ? _a : _b; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#define _APP_DEF_TASK(__NAME__, __STACK_SIZE__) \
|
||||||
|
static StaticTask_t __NAME__##_task_memory; \
|
||||||
|
static StackType_t __NAME__##_task_stack[__STACK_SIZE__]
|
||||||
|
|
||||||
|
#define _APP_CREATE_TASK(__NAME__, __PRIO__) \
|
||||||
|
xTaskCreateStatic(__NAME__##_task_entry, #__NAME__, sizeof(__NAME__##_task_stack), NULL, __PRIO__, __NAME__##_task_stack, &__NAME__##_task_memory)
|
||||||
|
|
||||||
|
#define APP_DEF_TASK(__NAME__, __STACK_SIZE__) \
|
||||||
|
_APP_DEF_TASK(__NAME__, __STACK_SIZE__) \
|
||||||
|
TaskHandle_t __NAME__##_task
|
||||||
|
|
||||||
|
#define APP_CREATE_TASK(__NAME__, __PRIO__) \
|
||||||
|
__NAME__##_task = _APP_CREATE_TASK(__NAME__, __PRIO__)
|
||||||
|
|
||||||
|
#define APP_DEF_CREATE_TASK(__NAME__, __PRIO__, __STACK_SIZE__) \
|
||||||
|
_APP_DEF_TASK(__NAME__, __STACK_SIZE__); \
|
||||||
|
_APP_CREATE_TASK(__NAME__, __PRIO__)
|
||||||
|
|
||||||
#endif //__APP_COMMON_H__
|
#endif //__APP_COMMON_H__
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
|
||||||
|
static StaticTask_t xIdleTaskTCBBuffer;
|
||||||
|
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
|
||||||
|
*ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
|
||||||
|
*ppxIdleTaskStackBuffer = xIdleStack;
|
||||||
|
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (configUSE_TIMERS == 1)
|
||||||
|
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize) {
|
||||||
|
static StaticTask_t xTimerTaskTCB;
|
||||||
|
static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
|
||||||
|
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||||
|
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||||
|
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||||
|
}
|
||||||
|
#endif
|
27
app/main.c
27
app/main.c
|
@ -1,35 +1,18 @@
|
||||||
#include <app_tasks.h>
|
#include <app_tasks.h>
|
||||||
|
#include "common.h"
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
|
|
||||||
static StaticTask_t xIdleTaskTCBBuffer;
|
|
||||||
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
|
|
||||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
|
|
||||||
*ppxIdleTaskStackBuffer = xIdleStack;
|
|
||||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (configUSE_TIMERS == 1)
|
|
||||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize) {
|
|
||||||
static StaticTask_t xTimerTaskTCB;
|
|
||||||
static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
|
|
||||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
|
||||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
|
||||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define QRSCAN_STACK_SIZE 512
|
#define QRSCAN_STACK_SIZE 512
|
||||||
static StaticTask_t qrscan_task_memory;
|
#define QRSCAN_TASK_PRIO 1
|
||||||
static StackType_t qrscan_task_stack[QRSCAN_STACK_SIZE];
|
|
||||||
TaskHandle_t qrscan_task;
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
hal_init();
|
hal_init();
|
||||||
|
|
||||||
qrscan_task = xTaskCreateStatic(qrscan_task_entry, "QR Scan", QRSCAN_STACK_SIZE, NULL, 1, qrscan_task_stack, &qrscan_task_memory);
|
APP_DEF_CREATE_TASK(qrscan, QRSCAN_TASK_PRIO, QRSCAN_STACK_SIZE);
|
||||||
|
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
Loading…
Reference in New Issue