summaryrefslogtreecommitdiff
path: root/software/mpu/src/lightsens.c
blob: 230a0c3adcdd257271f411e6eb238977bd5216e7 (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
56
57
58
59
60
61
62
/*
 * lightsens.c
 *
 *  Created on: 23.10.2011
 *      Author: Roland
 */

#include "Types.h"
#include "FreeRTOS.h"
#include "queue.h"

#define	TASK_PRIORITY_lightsens		    ( tskIDLE_PRIORITY + 2 )
#define TASK_STACK_SIZE_lightsens			( ( unsigned short ) 64 )

/* Globals */
static Task_Param_t TaskParam_LightSens;

/*
 * 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 lightsens_Process_Task(void *Param)
{
	Message_t Msg;
	portCHAR chBufLSe[10] = "Seas Knl!";

	if(NULL == TaskParam_LightSens.QueueHandles.hxq_LightSens)
	{
		return;
	}

	Msg.Sender = Sender_LightSens;
	Msg.pData = chBufLSe;
	xQueueSend(TaskParam_LightSens.QueueHandles.hxq_Kernel, &Msg, MS(10));
	while(1)
	{
		if( xQueueReceive( TaskParam_LightSens.QueueHandles.hxq_LightSens, &Msg, MS(5)))
		{
			/*
			 * switch Msg.Sender
			 *
			 */
			Msg.Sender = Sender_LightSens;
			Msg.pData = chBufLSe;
			xQueueSend(TaskParam_LightSens.QueueHandles.hxq_Kernel, &Msg, MS(10));
		}
	}
}

Status_t lightsens_Init_LightSens(QH_t  hxQueues)
{
	TaskParam_LightSens.QueueHandles = hxQueues;

	if(!xTaskCreate( lightsens_Process_Task, (signed char *) "LightSensor",
			TASK_STACK_SIZE_lightsens, &TaskParam_LightSens,
			TASK_PRIORITY_lightsens, &(TaskParam_LightSens.hxTask_Self)))
		return STATUS_ERROR_INIT;

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