summaryrefslogtreecommitdiff
path: root/software/mpu/src/camera.c
blob: 8ec62d3776bd7488e5d5b8a99c2765b592fea4d7 (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
/*
 * camera.c
 *
 *  Created on: 23.10.2011
 *      Author: Roland
 */

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

#define	TASK_PRIORITY_camera		    ( tskIDLE_PRIORITY + 2 )
#define TASK_STACK_SIZE_camera			( ( unsigned short ) 64 )

/* Globals */
static Task_Param_t TaskParam_Camera;

/*
 * The camera is connected to the MPU vie I2C to control the camera,
 * and has a 8 bit bus for data transmission ...
 * */
static void camera_Process_Task(void *Param)
{
	Message_t Msg;
	portCHAR chMsgBufCam[10] = "Hello Kl!";

	if(NULL == TaskParam_Camera.QueueHandles.hxq_Camera)
	{
		return;
	}

	while(1)
	{
		if( xQueueReceive( TaskParam_Camera.QueueHandles.hxq_Camera, &Msg, MS(5) ))
		{
			switch (Msg.Sender)
			{
			case Sender_Kernel:
				{
					Msg.Sender = Sender_Camera;
					Msg.pData = chMsgBufCam;
					xQueueSend(TaskParam_Camera.QueueHandles.hxq_Kernel, &Msg, MS(10));
				}
			default: {;}	/* for the time being we ignore messages received from
							   someone other than the kernel. */
			}
		}
	}
}

Status_t camera_Init_Camera(QH_t  hxQueues)
{
	TaskParam_Camera.QueueHandles = hxQueues;

	if(!xTaskCreate( camera_Process_Task, (signed char *) "Camera",
			TASK_STACK_SIZE_camera, &TaskParam_Camera,
			TASK_PRIORITY_camera, &(TaskParam_Camera.hxTask_Self)))
		return STATUS_ERROR_INIT;

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