I am currently working on a real time operating system(freertos) task,
there are 3 tasks here and the problem im having is with the 1st task. it is basically to have 2 modes, toggled by a single button "RIGHT" (keys = ~PTH & BOTH). this has got to go basically from what it is now, to a mode that just displays "RESET" on the screen. it will toggle between these two modes by pressing the "RIGHT" button. please help in anyway you can!
#define _SCI
#include <stdio.h>
/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
/*-----------------------------------------------------------
Definitions.
-----------------------------------------------------------*/
/* Priorities assigned to demo application tasks. */
#define mainCOM_PRIORITY1 ( tskIDLE_PRIORITY + 1 )
#define mainCOM_PRIORITY2 ( tskIDLE_PRIORITY + 2 )
/*-----------------------------------------------------------
Local functions prototypes.
-----------------------------------------------------------*/
static portTASK_FUNCTION_PROTO( vCOMSendTask1, pvParameters );
static portTASK_FUNCTION_PROTO( vCOMSendTask2, pvParameters );
void main( void )
{
// Set up PORTB as output and turn all LEDs off
DDRB = 0xFF;
PORTB = 0xFF;
// Light the top (b7) LED
PORTB &= ~bit(7); /* Clear appropriate bit on port */
/* Create two comms tasks.*/
xTaskCreate( vCOMSendTask1, (const signed portCHAR * const)"COM1", configMINIMAL_STACK_SIZE, NULL, mainCOM_PRIORITY1, NULL );
xTaskCreate( vCOMSendTask2, (const signed portCHAR * const)"COM2", configMINIMAL_STACK_SIZE, NULL, mainCOM_PRIORITY2, NULL );
/* The tasks have been created - start the scheduler. */
vTaskStartScheduler();
/* Should not reach here! */
for( ;; );
}
/*-----------------------------------------------------------*/
static portTASK_FUNCTION( vCOMSendTask1, pvParameters )
{
portTickType xLastWakeTime;
portTickType xFlashRate = 1000 / portTICK_RATE_MS; // Char rate in ms
xLastWakeTime = xTaskGetTickCount();
for(;;)
{
putchar('1');
vTaskDelayUntil( &xLastWakeTime, xFlashRate );
}
}
/*-----------------------------------------------------------*/
static portTASK_FUNCTION( vCOMSendTask2, pvParameters )
{
portTickType xLastWakeTime;
portTickType xFlashRate = 1500 / portTICK_RATE_MS; // Char rate in ms
xLastWakeTime = xTaskGetTickCount();
for(;;)
{
putchar('2');
vTaskDelayUntil( &xLastWakeTime, xFlashRate );
}
}