Atmel Software Framework

supervisor.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
#include "conf_ctrlpanel.h"
#include "tracedump.h"
#include "navigation.h"
#include "com1shell.h"
#include "datalog.h"
#include "cptime.h"
#include "sensor.h"
#include "mmi.h"
#include "shell.h"
#include "syscmds.h"
#include "fsaccess.h"

Macros

#define mainCOMSH_TASK_PRIORITY   ( tskIDLE_PRIORITY + 2 )
 Priority definitions for most of the tasks in the demo application. More...
 
#define mainDATALOG_TASK_PRIORITY   ( tskIDLE_PRIORITY + 2 )
 
#define mainETH_TASK_PRIORITY   ( tskIDLE_PRIORITY + 1 )
 
#define SUPERVISOR_CHECK_KO   (-1)
 Return status false. More...
 
#define SUPERVISOR_CHECK_OK   0
 Return status true. More...
 
#define SUPERVISOR_DEFAULT_PERIOD   ( ( portTickType ) 100 / portTICK_RATE_MS )
 The supervisor rate in ticks. More...
 
#define SUPERVISOR_DELAY_HEAPCHECK   600
 The delay between each heap usage check. More...
 
#define SUPERVISOR_DELAY_MMI_TIMEUPDATE   600
 The delay between each time update on the MMI. More...
 
#define SUPERVISOR_DELAY_PRINTTASKLIST   600
 The delay between each tasks list display. More...
 
#define SUPERVISOR_DELAY_TIMEUPDATE   10
 The delay between each time update. More...
 
#define SUPERVISOR_QUEUE_SIZE   1
 The supervisor queue length. More...
 
#define SUPERVISOR_STACK_SIZE   ( configMINIMAL_STACK_SIZE + 192 )
 
#define SUPERVISOR_USER_ACTION_STACK_SIZE   (configMINIMAL_STACK_SIZE+64)
 The supervisor User Action stack size. More...
 
#define SUPERVISOR_USER_ACTION_TASK_PRIORITY   ( tskIDLE_PRIORITY + 2 )
 The supervisor User Action task priority. More...
 

Functions

bool b_supervisor_switch_to_maintenance_mode (void)
 The switch-to-maintenance-mode command: initiate the process to
switch to maintenance mode. More...
 
eExecStatus e_supervisor_switch_to_maintenance_mode (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The switch-to-maintenance-mode command: initiate the process to
switch to maintenance mode. Format: maintain. More...
 
static portTASK_FUNCTION (vSupervisorTask, pvParameters)
 Supervisor task. More...
 
static portTASK_FUNCTION_PROTO (vSupervisorTask, pvParameters)
 
static void prv_v_leave_maintenance_mode (void)
 Do the required actions to leave the maintenance mode. More...
 
void prvCheckMallocHeap (void)
 
void v_supervisor_Device_Connects (void)
 Called upon remote device connection (upon PIN ID CHANGE event when we are host) More...
 
void v_supervisor_Device_Disconnects (void)
 Called upon remote device disconnection (upon PIN ID CHANGE event when we are host) More...
 
void v_supervisor_Host_Connects (void)
 Called upon remote host connect (upon VBUS ON event when we are device) More...
 
void v_supervisor_Host_Disconnects (void)
 Called upon VBUS OFF event. More...
 
void vSupervisor_Start (unsigned portBASE_TYPE uxPriority)
 Start the supervisor module. More...
 
portBASE_TYPE x_supervisor_SemaphoreGive (xSemaphoreHandle xSemaphore)
 Release a system mutex. More...
 
portBASE_TYPE x_supervisor_SemaphoreTake (xSemaphoreHandle xSemaphore, portTickType xBlockTime)
 Take a system mutex. More...
 

Variables

void __heap_end__
 
void __heap_start__
 
portBASE_TYPE * pxHighestHeapAddr = (portBASE_TYPE *)&__heap_start__
 
xSemaphoreHandle xCFGMutex
 
time_t xcptime_LocalTime
 The watchdog timeout delay. More...
 
xSemaphoreHandle xLOGMutex
 
xSemaphoreHandle xSHELLFSMutex
 

bool b_supervisor_switch_to_maintenance_mode ( void  )

The switch-to-maintenance-mode command: initiate the process to
switch to maintenance mode.

References e_supervisor_switch_to_maintenance_mode(), NULL, pdTRUE, and SYS_MODID_NONE.

eExecStatus e_supervisor_switch_to_maintenance_mode ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The switch-to-maintenance-mode command: initiate the process to
switch to maintenance mode. Format: maintain.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acIgnored.
avIgnored.
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns
the status of the command execution.

References CRLF, eUserMenuWaitHost, fat_cache_flush(), Is_usb_clock_frozen, Is_usb_detached, NAKED_TRACE_COM2, nav_reset(), NULL, pdTRUE, SHELL_EXECSTATUS_OK, TRACE_COM2, Usb_attach, Usb_detach, Usb_unfreeze_clock, vMMI_SetUserMenuMode(), vTaskDelay(), x_supervisor_SemaphoreTake(), and xSemaphoreGive.

Referenced by b_supervisor_switch_to_maintenance_mode(), and e_syscmds_reboot().

static portTASK_FUNCTION_PROTO ( vSupervisorTask  ,
pvParameters   
)
static
static void prv_v_leave_maintenance_mode ( void  )
static

Do the required actions to leave the maintenance mode.

References NAKED_TRACE_COM2, and v_com1shell_mount_local_drive().

Referenced by portTASK_FUNCTION().

void prvCheckMallocHeap ( void  )
void v_supervisor_Device_Connects ( void  )

Called upon remote device connection (upon PIN ID CHANGE event when we are host)

void v_supervisor_Device_Disconnects ( void  )

Called upon remote device disconnection (upon PIN ID CHANGE event when we are host)

Called upon remote device disconnection.

References ms_connected, and ms_new_device_connected.

void v_supervisor_Host_Connects ( void  )

Called upon remote host connect (upon VBUS ON event when we are device)

References Usb_detach, and Usb_unfreeze_clock.

void v_supervisor_Host_Disconnects ( void  )

Called upon VBUS OFF event.

Called upon remote host disconnection.

Warning
: the name of the function may imply that this is called in case we were a device, but this may not always be the case: this function may be called when we are a device. Explanation: the VBUS OFF event occurs in both cases.
void vSupervisor_Start ( unsigned portBASE_TYPE  uxPriority)

Start the supervisor module.

Parameters
uxPriorityThe priority base of the supervisor tasks.

References NULL, SUPERVISOR_STACK_SIZE, and xTaskCreate.

Referenced by main().

portBASE_TYPE x_supervisor_SemaphoreGive ( xSemaphoreHandle  xSemaphore)
portBASE_TYPE x_supervisor_SemaphoreTake ( xSemaphoreHandle  xSemaphore,
portTickType  xBlockTime 
)

Take a system mutex.

Parameters
xSemaphoreA handle to the semaphore being released.
xBlockTimeThe time in ticks to wait for the semaphore to become available.
Returns
pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime expired without the semaphore becoming available.

References pdFALSE, and xSemaphoreTake.

Referenced by b_joystick_init(), b_light_init(), b_potentiometer_init(), b_pushb1_init(), b_pushb2_init(), b_pushb3_init(), b_temperature_init(), e_sensor_cmd_set_config(), e_supervisor_switch_to_maintenance_mode(), e_syscmds_cmd_set_config(), portTASK_FUNCTION(), prvEthernetConfigureInterface(), Shell_exec(), and usb_mass_storage_cbw().

void __heap_end__
void __heap_start__
portBASE_TYPE* pxHighestHeapAddr = (portBASE_TYPE *)&__heap_start__

Referenced by prvCheckMallocHeap().

xSemaphoreHandle xCFGMutex

The CFG system mutex.

Referenced by prvEthernetConfigureInterface().

time_t xcptime_LocalTime

The watchdog timeout delay.

The local time raw value.

xSemaphoreHandle xLOGMutex

The LOG system mutex.

xSemaphoreHandle xSHELLFSMutex

The SHELL system mutex.