summaryrefslogtreecommitdiff
path: root/software/mpu/src/kernel.c
blob: 71ef57f6c3d859108a652418067b30aea2ffa321 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * kernel.c
 *
 *  Created on: 13.09.2011
 *      Author: Roland
 */
#include "Types.h"
#include "FreeRTOS.h"
#include "queue.h"

#define	kernel_TASK_PRIORITY		    ( tskIDLE_PRIORITY + 2 )
#define kernel_TASK_STACK_SIZE			( ( unsigned short ) 32 )

/* Globals */
xQueueHandle * gpxQueue_Kernel;
//static xTaskHandle *pkernel_TaskHandle;
//static Task_Param_t kernel_Param;
xTaskHandle *pkernel_TaskHandle;
Task_Param_t kernel_Param;

/*
 * Wake up other tasks, send them messages telling what to do,
 * wait for them to have processed the commands or not, maybe
 * put them to sleep again, ...
 * */
static void kernel_Process_Task(void *Param)
{
	Message_t Msg;

	while(1)
	{
		xQueueReceive( gpxQueue_Kernel, &Msg, portMAX_DELAY );
		/*TODO: execute desired command of message */

		/*
		 * switch Msg.Sender
		 *
		 * case Sender_Kernel:
		 * 		yeah, that's myself
		 *
		 */
	}
}

Status_t kernel_Init_Kernel(xQueueHandle * pxQueue)
{
	kernel_Param.pxQueue = pxQueue;

	xTaskCreate( kernel_Process_Task, (signed char *) "Kernel",
			kernel_TASK_STACK_SIZE, &kernel_Param,
			kernel_TASK_PRIORITY, pkernel_TaskHandle );

	/*TODO: check for success and pass it over to caller. */
	return STATUS_OK;
}