X-Git-Url: https://rtime.felk.cvut.cz/gitweb/arc.git/blobdiff_plain/07bbcb79799c461e4dc58be060a0c3e01f466c97..60966c493db6916acb0f8d9beaa9c1e77c206ef2:/boards/ti_tms570ls/examples/tms570_hdk_can/Tasks.c diff --git a/boards/ti_tms570ls/examples/tms570_hdk_can/Tasks.c b/boards/ti_tms570ls/examples/tms570_hdk_can/Tasks.c new file mode 100644 index 00000000..ac4638a5 --- /dev/null +++ b/boards/ti_tms570ls/examples/tms570_hdk_can/Tasks.c @@ -0,0 +1,116 @@ +/* +* Configuration of module: Os (Tasks.c) +* +* Created by: +* Copyright: +* +* Configured for (MCU): TMS570 +* +* Module vendor: ArcCore +* Generator version: 2.0.34 +* +* Generated by Arctic Studio (http://arccore.com) +* on Tue Jul 05 15:02:10 CEST 2011 +*/ + +#include "Os.h" +#include "EcuM.h" +#include "Com.h" +#include "CanIf.h" +#include "Dio.h" + +// #define USE_LDEBUG_PRINTF // Uncomment this to turn debug statements on. +#include "debug.h" + +// Tasks +void OsIdle( void ) { + while(1); +} + +void StartupTask( void ) { + + EcuM_StartupTwo(); + + CanIf_InitController(CANIF_Channel_1, CANIF_Channel_1_CONFIG_0); + CanIf_SetControllerMode(CANIF_Channel_1, CANIF_CS_STARTED); + CanIf_InitController(CANIF_Channel_2, CANIF_Channel_2_CONFIG_0); + CanIf_SetControllerMode(CANIF_Channel_2, CANIF_CS_STARTED); + //Com_IpduGroupStart(CanDbImportedPdus, 1); + Com_IpduGroupStart(ComPduGroup, 0); + + SetEvent(TASK_ID_StepTask, EVENT_MASK_StepEvent); + + TerminateTask(); +} + +void MainTask( void ) { + Com_MainFunctionTx(); // Com_MainFunctionRx(); + Com_MainFunctionRx(); // Com_MainFunctionTx(); + TerminateTask(); +} + +// Task that toggles the LED +Dio_LevelType level = 1; +void BlinkerTask( void ) { + level = !level; + Dio_WriteChannel(DIO_CHANNEL_NAME_LED_CHANNEL, level); + TerminateTask(); +} + +// Hooks +#define ERROR_LOG_SIZE 20 + +struct LogBad_s { + uint32_t param1; + uint32_t param2; + uint32_t param3; + TaskType taskId; + OsServiceIdType serviceId; + StatusType error; +}; + +void ErrorHook ( StatusType Error ) { + + TaskType task; + static struct LogBad_s LogBad[ERROR_LOG_SIZE]; + static uint8_t ErrorCount = 0; + GetTaskID(&task); + OsServiceIdType service = OSErrorGetServiceId(); + + LDEBUG_PRINTF("## ErrorHook err=%d\n",Error); + + /* Log the errors in a buffer for later review */ + LogBad[ErrorCount].param1 = os_error.param1; + LogBad[ErrorCount].param2 = os_error.param2; + LogBad[ErrorCount].param3 = os_error.param3; + LogBad[ErrorCount].serviceId = service; + LogBad[ErrorCount].taskId = task; + LogBad[ErrorCount].error = Error; + + ErrorCount++; + + // Stall if buffer is full. + while(ErrorCount >= ERROR_LOG_SIZE); + +} + +void PostTaskHook ( void ) { + TaskType task; + GetTaskID(&task); + LDEBUG_PRINTF("## PreTaskHook, taskid=%d\n",task); +} + +void PreTaskHook ( void ) { + TaskType task; + GetTaskID(&task); + LDEBUG_PRINTF("## PreTaskHook, taskid=%d\n",task); +} + +void ShutdownHook ( StatusType Error ) { + LDEBUG_PRINTF("## ShutdownHook\n"); + while(1); +} + +void StartupHook ( void ) { + LDEBUG_PRINTF("## StartupHook\n"); +}