summaryrefslogtreecommitdiff
path: root/software/mpu/src/kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'software/mpu/src/kernel.c')
-rw-r--r--software/mpu/src/kernel.c67
1 files changed, 45 insertions, 22 deletions
diff --git a/software/mpu/src/kernel.c b/software/mpu/src/kernel.c
index 71ef57f..d75f9dd 100644
--- a/software/mpu/src/kernel.c
+++ b/software/mpu/src/kernel.c
@@ -8,15 +8,11 @@
#include "FreeRTOS.h"
#include "queue.h"
-#define kernel_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
-#define kernel_TASK_STACK_SIZE ( ( unsigned short ) 32 )
+#define kernel_TASK_PRIORITY ( tskIDLE_PRIORITY + 5 )
+#define kernel_TASK_STACK_SIZE ( ( unsigned short ) 64 )
/* Globals */
-xQueueHandle * gpxQueue_Kernel;
-//static xTaskHandle *pkernel_TaskHandle;
-//static Task_Param_t kernel_Param;
-xTaskHandle *pkernel_TaskHandle;
-Task_Param_t kernel_Param;
+static Task_Param_t kernel_Param;
/*
* Wake up other tasks, send them messages telling what to do,
@@ -26,29 +22,56 @@ Task_Param_t kernel_Param;
static void kernel_Process_Task(void *Param)
{
Message_t Msg;
+ Message_t SndMsg;
+ portTickType tick;
+ portCHAR chBufCam[10] = "Seas Cam!";
+ portCHAR chBufLSen[10] = "Seas LSe!";
+ if(NULL == kernel_Param.QueueHandles.hxq_Kernel)
+ {
+ return;
+ }
+
+ tick = xTaskGetTickCount();
while(1)
{
- xQueueReceive( gpxQueue_Kernel, &Msg, portMAX_DELAY );
- /*TODO: execute desired command of message */
-
- /*
- * switch Msg.Sender
- *
- * case Sender_Kernel:
- * yeah, that's myself
- *
- */
+ vTaskDelayUntil(&tick, MS(3));
+
+ if( xQueueReceive( kernel_Param.QueueHandles.hxq_Kernel, &Msg, MS(5)))
+ {
+ /*
+ * switch Msg.Sender and act accordingly.
+ */
+ switch (Msg.Sender)
+ {
+ case Sender_Camera:
+ {
+ SndMsg.Sender = Sender_Kernel;
+ SndMsg.pData = chBufCam;
+ xQueueSend(kernel_Param.QueueHandles.hxq_Camera, &SndMsg, MS(10));
+ }
+
+ case Sender_LightSens:
+ {
+ SndMsg.Sender = Sender_Kernel;
+ SndMsg.pData = chBufLSen;
+ xQueueSend(kernel_Param.QueueHandles.hxq_LightSens, &SndMsg, MS(10));
+ }
+ default: {;}
+ }
+ }
}
}
-Status_t kernel_Init_Kernel(xQueueHandle * pxQueue)
+Status_t kernel_Init_Kernel(QH_t hxQueues)
{
- kernel_Param.pxQueue = pxQueue;
+portBASE_TYPE xResult;
+
+ xResult = xTaskCreate( kernel_Process_Task, (signed char *) "Kernel",
+ kernel_TASK_STACK_SIZE, &kernel_Param,
+ kernel_TASK_PRIORITY, &(kernel_Param.hxTask_Self) );
- xTaskCreate( kernel_Process_Task, (signed char *) "Kernel",
- kernel_TASK_STACK_SIZE, &kernel_Param,
- kernel_TASK_PRIORITY, pkernel_TaskHandle );
+ kernel_Param.QueueHandles = hxQueues;
/*TODO: check for success and pass it over to caller. */
return STATUS_OK;