#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"
#include "ethernet.h"
#include "netif/etharp.h"
#include "BasicWEB.h"
#include "conf_usb.h"
#include "usbsys.h"
#include "usb_task.h"
#include "usb_standard_request.h"
#include "usb_drv.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 10 |
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_MAINTENANCE_NBMUTEX_TOTAKE 4 |
The number of system mutexes to take before switching to maintenance mode. More... | |
#define | SUPERVISOR_QUEUE_SIZE 1 |
The supervisor queue length. More... | |
#define | SUPERVISOR_STACK_SIZE ( configMINIMAL_STACK_SIZE + 192 ) |
#define | SUPERVISOR_USB_ROLE_DEVICE 1 |
The Control Panel is acting as a USB device. More... | |
#define | SUPERVISOR_USB_ROLE_HOST 2 |
The Control Panel is acting as a USB host. More... | |
#define | SUPERVISOR_USB_ROLE_NONE 0 |
#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_IsInMaintenanceMode (void) |
Maintenance mode status. More... | |
bool | b_supervisor_leave_UsbMassStorage_mode (void) |
Leave the USB Mass Storage mode while the USB host is plugged in. More... | |
bool | b_supervisor_leave_waitingforhost_mode (void) |
Leave the waiting-for-host mode while the USB host has not been plugged in yet. More... | |
bool | b_supervisor_switch_to_maintenance_mode (void) |
The switch-to-maintenance-mode command: initiate the process to switch to maintenance mode. More... | |
bool | b_USBHostCopyCfg (void) |
Launch the "Upload CFG Files" MMI task that copies the /CFG directory from the USB Mass Storage device to the Control Panel. More... | |
bool | b_USBHostCopyLogs (void) |
Launch the "Copy Logs" MMI task that copies the /LOG directory from the Control Panel to the USB Mass Storage device. More... | |
bool | b_USBHostCopyWeb (void) |
Launch the "Upload WEB Files" MMI task that copies the /WEB directory from the USB Mass Storage device to the Control Panel. More... | |
bool | b_USBHostMoveLogs (void) |
Launch the "Move Logs" MMI task that moves the /LOG directory content from the Control Panel to the USB Mass Storage device. 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 (vSupervisorUserActionTask, pvParameters) |
The MMI user-action task: in charge of launching an action requested through the MMI. More... | |
static | portTASK_FUNCTION (vSupervisorTask, pvParameters) |
Supervisor task. More... | |
static | portTASK_FUNCTION_PROTO (vSupervisorTask, pvParameters) |
static void | prv_v_common_leave_UsbDevice_mode (void) |
Release the semaphores and change the MMI user menu mode. More... | |
static void | prv_v_leave_maintenance_mode (void) |
Do the required actions to leave the maintenance mode. More... | |
static void | prv_v_manage_user_action (void) |
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__ |
static bool | bIsInMaintenance = false |
static bool | bOutOfMaintenance = false |
portBASE_TYPE * | pxHighestHeapAddr = (portBASE_TYPE *)&__heap_start__ |
signed short | sMmiNavId |
static U8 | u8CurrentUsbRole = SUPERVISOR_USB_ROLE_NONE |
U8 | u8IsMaintenanceRequired = 0 |
xSemaphoreHandle | xCFGMutex |
time_t | xcptime_LocalTime |
xSemaphoreHandle | xLOGMutex |
xSemaphoreHandle | xSHELLFSMutex |
xQueueHandle | xSUPERVISORQueue = 0 |
static xTaskHandle | xSupervisorUserActionHndl = NULL |
xSemaphoreHandle | xUSBMutex |
xSemaphoreHandle | xWEBMutex |
#define SUPERVISOR_MAINTENANCE_NBMUTEX_TOTAKE 4 |
The number of system mutexes to take before switching to maintenance mode.
Referenced by e_supervisor_switch_to_maintenance_mode(), and x_supervisor_SemaphoreGive().
Maintenance mode status.
References bIsInMaintenance.
Referenced by e_syscmds_reboot().
Leave the USB Mass Storage mode while the USB host is plugged in.
References bIsInMaintenance, pdTRUE, prv_v_leave_maintenance_mode(), and Usb_detach.
Leave the waiting-for-host mode while the USB host has not been plugged in yet.
References bIsInMaintenance, pdTRUE, and prv_v_common_leave_UsbDevice_mode().
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.
Launch the "Upload CFG Files" MMI task that copies the /CFG directory from the USB Mass Storage device to the Control Panel.
References e_usbsys_cp_cfg_to_local(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, NULL, pdFALSE, pdTRUE, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, vMMI_SetUserMenuMode(), and vTaskDelay().
Launch the "Copy Logs" MMI task that copies the /LOG directory from the
Control Panel to the USB Mass Storage device.
References e_usbsys_cp_logs_to_key(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, NULL, pdFALSE, pdTRUE, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, vMMI_SetUserMenuMode(), and vTaskDelay().
Launch the "Upload WEB Files" MMI task that copies the /WEB directory from the USB Mass Storage device to the Control Panel.
References e_usbsys_cp_web_to_local(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, NULL, pdFALSE, pdTRUE, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, vMMI_SetUserMenuMode(), and vTaskDelay().
Launch the "Move Logs" MMI task that moves the /LOG directory content
from the Control Panel to the USB Mass Storage device.
References e_usbsys_mv_logs_to_key(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, NULL, pdFALSE, pdTRUE, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, vMMI_SetUserMenuMode(), and vTaskDelay().
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.
xModId | Input. The module that is calling this function. |
FsNavId | Ignored. |
ac | Ignored. |
av | Ignored. |
ppcStringReply | Input/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. |
References bIsInMaintenance, CRLF, eUserMenuWaitHost, fat_cache_flush(), Is_usb_clock_frozen, Is_usb_detached, NAKED_TRACE_COM2, nav_reset(), NULL, pdTRUE, SHELL_EXECSTATUS_OK, SUPERVISOR_MAINTENANCE_NBMUTEX_TOTAKE, TRACE_COM2, u8CurrentUsbRole, u8IsMaintenanceRequired, 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 |
The MMI user-action task: in charge of launching an action requested through the MMI.
References NAKED_TRACE_COM2, NULL, pdTRUE, void, vTaskSuspend(), and xQueueReceive.
|
static |
Supervisor task.
References __heap_end__, __heap_start__, b_usbsys_start(), bdatalog_start(), bIsInMaintenance, bMMI_start(), bOutOfMaintenance, bsensor_start(), eUserMenuIdle, eUserMenuUSBDevice, eUserMenuUSBHost, fsaccess_alloc_nav_id(), fsaccess_give_mutex(), fsaccess_take_mutex(), Is_device_enumerated, itracedump_Init(), mainCOMSH_TASK_PRIORITY, mainDATALOG_TASK_PRIORITY, ms_connected, NAKED_TRACE_COM2, nav_select(), NULL, pdFALSE, pdPASS, pdTRUE, prv_v_leave_maintenance_mode(), prv_v_manage_user_action(), prvCheckMallocHeap(), sMmiNavId, sprintf(), SUPERVISOR_DEFAULT_PERIOD, SUPERVISOR_DELAY_HEAPCHECK, SUPERVISOR_DELAY_MMI_TIMEUPDATE, SUPERVISOR_DELAY_PRINTTASKLIST, SUPERVISOR_DELAY_TIMEUPDATE, SUPERVISOR_QUEUE_SIZE, SUPERVISOR_USER_ACTION_STACK_SIZE, SUPERVISOR_USER_ACTION_TASK_PRIORITY, tskIDLE_PRIORITY, v_cptime_ExecuteScheduledCmd(), v_syscmds_display_traces(), vMMI_DisplayDateAndTime(), vMMI_DisplayUSBState(), vMMI_Manage(), vMMI_SetUserMenuMode(), void, vSemaphoreCreateBinary, vStartCom1Shell(), vStartEthernetTaskLauncher(), vTaskDelayUntil(), vTaskDelete(), x_supervisor_SemaphoreTake(), xcptime_LocalTime, xQueueCreate(), xSupervisorUserActionHndl, xTaskCreate, and xTaskGetTickCount().
|
static |
Release the semaphores and change the MMI user menu mode.
References eUserMenuIdle, pdFALSE, pdTRUE, TRACE_COM2, vMMI_SetUserMenuMode(), xSemaphoreGive, and xSemaphoreTake.
Referenced by b_supervisor_leave_waitingforhost_mode(), and prv_v_leave_maintenance_mode().
Do the required actions to leave the maintenance mode.
References bOutOfMaintenance, NAKED_TRACE_COM2, prv_v_common_leave_UsbDevice_mode(), and v_com1shell_mount_local_drive().
Referenced by b_supervisor_leave_UsbMassStorage_mode(), and portTASK_FUNCTION().
References uxQueueMessagesWaiting(), vTaskResume(), vTaskSuspend(), and xSupervisorUserActionHndl.
Referenced by portTASK_FUNCTION().
References __heap_end__, __heap_start__, NAKED_TRACE_COM2, and pxHighestHeapAddr.
Referenced by portTASK_FUNCTION().
Called upon remote device connection (upon PIN ID CHANGE event when we are host)
References SUPERVISOR_USB_ROLE_HOST, SUPERVISOR_USB_ROLE_NONE, and u8CurrentUsbRole.
Called upon remote device disconnection (upon PIN ID CHANGE event when we are host)
Called upon remote device disconnection.
References ms_connected, ms_new_device_connected, SUPERVISOR_USB_ROLE_HOST, SUPERVISOR_USB_ROLE_NONE, and u8CurrentUsbRole.
Called upon remote host connect (upon VBUS ON event when we are device)
References bIsInMaintenance, SUPERVISOR_USB_ROLE_DEVICE, SUPERVISOR_USB_ROLE_NONE, u8CurrentUsbRole, u8IsMaintenanceRequired, Usb_detach, and Usb_unfreeze_clock.
Called upon VBUS OFF event.
Called upon remote host disconnection.
References bIsInMaintenance, bOutOfMaintenance, SUPERVISOR_USB_ROLE_DEVICE, SUPERVISOR_USB_ROLE_NONE, and u8CurrentUsbRole.
void vSupervisor_Start | ( | unsigned portBASE_TYPE | uxPriority | ) |
Start the supervisor module.
uxPriority | The priority base of the supervisor tasks. |
References NULL, SUPERVISOR_STACK_SIZE, and xTaskCreate.
Referenced by main().
portBASE_TYPE x_supervisor_SemaphoreGive | ( | xSemaphoreHandle | xSemaphore | ) |
Release a system mutex.
xSemaphore | A handle to the semaphore being released. |
References bIsInMaintenance, bOutOfMaintenance, eUserMenuWaitHost, fat_cache_flush(), Is_usb_clock_frozen, Is_usb_detached, nav_reset(), pdTRUE, SUPERVISOR_MAINTENANCE_NBMUTEX_TOTAKE, TRACE_COM2, u8IsMaintenanceRequired, Usb_attach, Usb_detach, Usb_unfreeze_clock, vMMI_SetUserMenuMode(), vTaskDelay(), and xSemaphoreGive.
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_syscmds_cmd_set_config(), portTASK_FUNCTION(), prvEthernetConfigureInterface(), Shell_exec(), and usb_mass_storage_csw().
portBASE_TYPE x_supervisor_SemaphoreTake | ( | xSemaphoreHandle | xSemaphore, |
portTickType | xBlockTime | ||
) |
Take a system mutex.
xSemaphore | A handle to the semaphore being released. |
xBlockTime | The time in ticks to wait for the semaphore to become available. |
References bOutOfMaintenance, 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__ |
Referenced by portTASK_FUNCTION(), and prvCheckMallocHeap().
void __heap_start__ |
Referenced by portTASK_FUNCTION(), and prvCheckMallocHeap().
Maintenance mode flag.
Referenced by b_supervisor_IsInMaintenanceMode(), b_supervisor_leave_UsbMassStorage_mode(), b_supervisor_leave_waitingforhost_mode(), e_supervisor_switch_to_maintenance_mode(), portTASK_FUNCTION(), v_supervisor_Host_Connects(), v_supervisor_Host_Disconnects(), and x_supervisor_SemaphoreGive().
Out-of-Maintenance mode flag.
Referenced by portTASK_FUNCTION(), prv_v_leave_maintenance_mode(), v_supervisor_Host_Disconnects(), x_supervisor_SemaphoreGive(), and x_supervisor_SemaphoreTake().
portBASE_TYPE* pxHighestHeapAddr = (portBASE_TYPE *)&__heap_start__ |
Referenced by prvCheckMallocHeap().
signed short sMmiNavId |
MMI navigator ID.
Referenced by b_mmi_format_a(), b_mmi_format_b(), b_mmi_mkdir_aLOG(), b_mmi_mkdir_bLOG(), b_USBHostCopyCfg(), b_USBHostCopyLogs(), b_USBHostCopyWeb(), b_USBHostMoveLogs(), and portTASK_FUNCTION().
|
static |
The Control Panel current USB role.
Referenced by e_supervisor_switch_to_maintenance_mode(), v_supervisor_Device_Connects(), v_supervisor_Device_Disconnects(), v_supervisor_Host_Connects(), and v_supervisor_Host_Disconnects().
U8 u8IsMaintenanceRequired = 0 |
Maintenance mode requested variable.
Referenced by e_supervisor_switch_to_maintenance_mode(), v_supervisor_Host_Connects(), and x_supervisor_SemaphoreGive().
xSemaphoreHandle xCFGMutex |
The CFG system mutex.
Referenced by prvEthernetConfigureInterface().
time_t xcptime_LocalTime |
The local time raw value.
Referenced by e_cptime_cmd_get_config(), e_cptime_cmd_set_config(), e_cptime_RecordScheduledCmd(), portTASK_FUNCTION(), prv_xopen_current_logfile(), pxdatalog_log_alloc_init(), v_cptime_ExecuteScheduledCmd(), v_cptime_GetDateInFatStringFormat(), v_cptime_Init(), and v_cptime_UpdateLocalTime().
xSemaphoreHandle xLOGMutex |
The LOG system mutex.
xSemaphoreHandle xSHELLFSMutex |
The SHELL system mutex.
xQueueHandle xSUPERVISORQueue = 0 |
The handle of the queue of SUPERVISOR, holding user actions to perform.
|
static |
MMI User Action task handle.
Referenced by portTASK_FUNCTION(), and prv_v_manage_user_action().
xSemaphoreHandle xUSBMutex |
The USB system mutex.
xSemaphoreHandle xWEBMutex |
The Web server system mutex.