This module is in charge of the Ctrl Panel system.
Definition in file supervisor.h.
#include "FreeRTOS.h"
#include "semphr.h"
#include "conf_usb.h"
Go to the source code of this file.
Defines | |
#define | SYS_NB_MOD 4 |
Enumerations | |
enum | eModId { SYS_MODID_NONE = -1, SYS_MODID_COM1SHELL = 1, SYS_MODID_HTTP = 2, SYS_MODID_USB = 4, SYS_MODID_MMI = 8 } |
enum | eStatus { SYS_STATUS_STARTUP, SYS_STATUS_RUNNING, SYS_STATUS_DOWN } |
Functions | |
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. | |
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. | |
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. | |
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. | |
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. | |
void | v_supervisor_Host_Connects (void) |
Called upon remote host connect (upon VBUS ON event when we are device). | |
void | v_supervisor_Host_Disconnects (void) |
Called upon remote host disconnection. | |
void | vSupervisor_Start (unsigned portBASE_TYPE uxPriority) |
Start the supervisor module. | |
portBASE_TYPE | x_supervisor_SemaphoreGive (xSemaphoreHandle xSemaphore) |
Release a system mutex. | |
portBASE_TYPE | x_supervisor_SemaphoreTake (xSemaphoreHandle xSemaphore, portTickType xBlockTime) |
Take a system mutex. |
#define SYS_NB_MOD 4 |
Number of modules id.
Definition at line 82 of file supervisor.h.
enum eModId |
Modules id.
Definition at line 71 of file supervisor.h.
00072 { 00073 SYS_MODID_NONE = -1, // No specific module 00074 SYS_MODID_COM1SHELL = 1, // The COM1SHELL module. 00075 SYS_MODID_HTTP = 2, // The HTTP module. 00076 SYS_MODID_USB = 4, // The USB module. 00077 SYS_MODID_MMI = 8 // The MMI module. 00078 } eModId;
enum eStatus |
Modules status.
Definition at line 60 of file supervisor.h.
00061 { 00062 SYS_STATUS_STARTUP, // The module is being created. 00063 SYS_STATUS_RUNNING, // The module is up & running. 00064 SYS_STATUS_DOWN // The module is not running. 00065 } eStatus;
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.
Definition at line 722 of file supervisor.c.
References e_usbsys_cp_cfg_to_local(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, and vMMI_SetUserMenuMode().
00723 { 00724 #if configCTRLPANEL_TRACE == 1 00725 eExecStatus xRet; 00726 #endif 00727 00728 00729 // Display User Menu Acting 00730 vMMI_SetUserMenuMode(eUserMenuUSBHostActing, pdFALSE); 00731 vTaskDelay( 3 ); // So that the supervisor task gets the focus to update the 00732 // LCD screen. 00733 NAKED_TRACE_COM2( "Copy Config Files" ); 00734 00735 // Perform the task 00736 #if configCTRLPANEL_TRACE == 1 00737 xRet = 00738 #endif 00739 e_usbsys_cp_cfg_to_local( SYS_MODID_MMI, sMmiNavId, -1, NULL, NULL ); 00740 #if configCTRLPANEL_TRACE == 1 00741 if( SHELL_EXECSTATUS_KO == xRet ) 00742 NAKED_TRACE_COM2( "Copying /CFG from USB MS device to Ctrl Panel failed.") 00743 #endif 00744 00745 // Display User Menu 00746 vMMI_SetUserMenuMode(eUserMenuUSBHost, pdFALSE); 00747 return (pdTRUE); 00748 }
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.
Definition at line 617 of file supervisor.c.
References e_usbsys_cp_logs_to_key(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, and vMMI_SetUserMenuMode().
00618 { 00619 #if configCTRLPANEL_TRACE == 1 00620 eExecStatus xRet; 00621 #endif 00622 00623 00624 // Display User Menu Acting 00625 vMMI_SetUserMenuMode(eUserMenuUSBHostActing, pdFALSE); 00626 vTaskDelay( 3 ); // So that the supervisor task gets the focus to update the 00627 // LCD screen. 00628 NAKED_TRACE_COM2( "Copy Logs" ); 00629 00630 // Perform the task 00631 #if configCTRLPANEL_TRACE == 1 00632 xRet = 00633 #endif 00634 e_usbsys_cp_logs_to_key( SYS_MODID_MMI, sMmiNavId, -1, NULL, NULL ); 00635 #if configCTRLPANEL_TRACE == 1 00636 if( SHELL_EXECSTATUS_KO == xRet ) 00637 NAKED_TRACE_COM2( "Copying logs from Ctrl Panel to USB MS device failed.") 00638 #endif 00639 00640 // Display User Menu 00641 vMMI_SetUserMenuMode(eUserMenuUSBHost, pdFALSE); 00642 return (pdTRUE); 00643 }
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.
Definition at line 687 of file supervisor.c.
References e_usbsys_cp_web_to_local(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, and vMMI_SetUserMenuMode().
00688 { 00689 #if configCTRLPANEL_TRACE == 1 00690 eExecStatus xRet; 00691 #endif 00692 00693 00694 // Display User Menu Acting 00695 vMMI_SetUserMenuMode(eUserMenuUSBHostActing, pdFALSE); 00696 vTaskDelay( 3 ); // So that the supervisor task gets the focus to update the 00697 // LCD screen. 00698 NAKED_TRACE_COM2( "Copy Web Files" ); 00699 00700 // Perform the task 00701 #if configCTRLPANEL_TRACE == 1 00702 xRet = 00703 #endif 00704 e_usbsys_cp_web_to_local( SYS_MODID_MMI, sMmiNavId, -1, NULL, NULL ); 00705 #if configCTRLPANEL_TRACE == 1 00706 if( SHELL_EXECSTATUS_KO == xRet ) 00707 NAKED_TRACE_COM2( "Copying /WEB from USB MS device to Ctrl Panel failed.") 00708 #endif 00709 00710 // Display User Menu 00711 vMMI_SetUserMenuMode(eUserMenuUSBHost, pdFALSE); 00712 return (pdTRUE); 00713 }
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.
Definition at line 652 of file supervisor.c.
References e_usbsys_mv_logs_to_key(), eUserMenuUSBHost, eUserMenuUSBHostActing, NAKED_TRACE_COM2, SHELL_EXECSTATUS_KO, sMmiNavId, SYS_MODID_MMI, and vMMI_SetUserMenuMode().
00653 { 00654 #if configCTRLPANEL_TRACE == 1 00655 eExecStatus xRet; 00656 #endif 00657 00658 00659 // Display User Menu Acting 00660 vMMI_SetUserMenuMode(eUserMenuUSBHostActing, pdFALSE); 00661 vTaskDelay( 3 ); // So that the supervisor task gets the focus to update the 00662 // LCD screen. 00663 NAKED_TRACE_COM2( "Move Logs" ); 00664 00665 // Perform the task 00666 #if configCTRLPANEL_TRACE == 1 00667 xRet = 00668 #endif 00669 e_usbsys_mv_logs_to_key( SYS_MODID_MMI, sMmiNavId, -1, NULL, NULL ); 00670 #if configCTRLPANEL_TRACE == 1 00671 if( SHELL_EXECSTATUS_KO == xRet ) 00672 NAKED_TRACE_COM2( "Copying logs from Ctrl Panel to USB MS device failed.") 00673 #endif 00674 00675 // Display User Menu 00676 vMMI_SetUserMenuMode(eUserMenuUSBHost, pdFALSE); 00677 return (pdTRUE); 00678 }
void v_supervisor_Device_Connects | ( | void | ) |
Called upon remote device connection (upon PIN ID CHANGE event when we are host).
Definition at line 903 of file supervisor.c.
References SUPERVISOR_USB_ROLE_HOST, SUPERVISOR_USB_ROLE_NONE, and u8CurrentUsbRole.
00904 { 00905 #ifdef USB_ENABLE 00906 if( SUPERVISOR_USB_ROLE_NONE == u8CurrentUsbRole ) 00907 { // Consider only one of these events in case we get several. 00908 u8CurrentUsbRole = SUPERVISOR_USB_ROLE_HOST; 00909 } 00910 #endif 00911 }
void v_supervisor_Device_Disconnects | ( | void | ) |
Called upon remote device disconnection.
Definition at line 916 of file supervisor.c.
References ms_connected, ms_new_device_connected, SUPERVISOR_USB_ROLE_HOST, SUPERVISOR_USB_ROLE_NONE, and u8CurrentUsbRole.
00917 { 00918 #ifdef USB_ENABLE 00919 if( SUPERVISOR_USB_ROLE_HOST == u8CurrentUsbRole ) 00920 { // Consider only one of these events in case we get several. 00921 u8CurrentUsbRole = SUPERVISOR_USB_ROLE_NONE; 00922 ms_new_device_connected = FALSE, ms_connected = FALSE; 00923 } 00924 #endif 00925 }
void v_supervisor_Host_Connects | ( | void | ) |
Called upon remote host connect (upon VBUS ON event when we are device).
Definition at line 853 of file supervisor.c.
References bIsInMaintenance, SUPERVISOR_USB_ROLE_DEVICE, SUPERVISOR_USB_ROLE_NONE, u8CurrentUsbRole, and u8IsMaintenanceRequired.
00854 { 00855 #ifdef USB_ENABLE 00856 #if configCTRLPANEL_TRACE == 1 00857 TempoVbusOn++; 00858 #endif 00859 if(( 0 == u8IsMaintenanceRequired )&&( FALSE == bIsInMaintenance )) 00860 { 00861 // If we connect to the host and the Control Panel is not "set as USB key", 00862 // properly detach from the USB host (instead of behaving out of the USB spec 00863 // by not completely enumerating as a Mass Storage device). 00864 Usb_unfreeze_clock(); 00865 Usb_detach(); 00866 } 00867 if( SUPERVISOR_USB_ROLE_NONE == u8CurrentUsbRole ) 00868 { // Consider only one of these events in case we get several. 00869 u8CurrentUsbRole = SUPERVISOR_USB_ROLE_DEVICE; 00870 } 00871 #endif 00872 }
void v_supervisor_Host_Disconnects | ( | void | ) |
Called upon remote host disconnection.
Called upon remote host disconnection.
Definition at line 881 of file supervisor.c.
References bIsInMaintenance, bOutOfMaintenance, SUPERVISOR_USB_ROLE_DEVICE, SUPERVISOR_USB_ROLE_NONE, and u8CurrentUsbRole.
00882 { 00883 #ifdef USB_ENABLE 00884 #if configCTRLPANEL_TRACE == 1 00885 TempoVbusOff++; 00886 #endif 00887 if( SUPERVISOR_USB_ROLE_DEVICE == u8CurrentUsbRole ) 00888 { // Consider only one of these events in case we get several. 00889 u8CurrentUsbRole = SUPERVISOR_USB_ROLE_NONE; 00890 if( TRUE == bIsInMaintenance ) 00891 { 00892 bIsInMaintenance = FALSE; // We're not in maintenance mode anymore. 00893 bOutOfMaintenance = TRUE; // We have actions to take upon maintenance mode leave. 00894 } 00895 } 00896 #endif 00897 }
void vSupervisor_Start | ( | unsigned portBASE_TYPE | uxPriority | ) |
Start the supervisor module.
uxPriority | The priority base of the supervisor tasks. |
Definition at line 253 of file supervisor.c.
References SUPERVISOR_STACK_SIZE.
Referenced by main().
00254 { 00255 /* Spawn the Sentinel task. */ 00256 xTaskCreate( vSupervisorTask, ( const signed portCHAR * )"SUPER", 00257 SUPERVISOR_STACK_SIZE, NULL, uxPriority, ( xTaskHandle * )NULL ); 00258 }
portBASE_TYPE x_supervisor_SemaphoreGive | ( | xSemaphoreHandle | xSemaphore | ) |
Release a system mutex.
xSemaphore | A handle to the semaphore being released. |
Definition at line 799 of file supervisor.c.
References bIsInMaintenance, bOutOfMaintenance, eUserMenuWaitHost, SUPERVISOR_MAINTENANCE_NBMUTEX_TOTAKE, TRACE_COM2, u8IsMaintenanceRequired, vMMI_SetUserMenuMode(), and xUSBMutex.
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().
00800 { 00801 #ifdef USB_ENABLE 00802 #if USB_DEVICE_FEATURE == ENABLED 00803 if( ( 0 != u8IsMaintenanceRequired ) && ( FALSE == bOutOfMaintenance ) ) 00804 { 00805 // If we have to enter in the maintenance mode, do not release the mutex. 00806 // => this mutex is now the property of the supervisor. 00807 u8IsMaintenanceRequired++; 00808 00809 // If all mutexes have been acquired, switch to maintenance mode. 00810 if( ( SUPERVISOR_MAINTENANCE_NBMUTEX_TOTAKE +1 ) == u8IsMaintenanceRequired ) 00811 { 00812 fat_cache_flush(); // Flush the FAT cache. 00813 nav_reset(); // Reset all file system navigators. We will mount 00814 // the com1shell default drive when we'll leave the 00815 // maintenance mode. 00816 // Switch to maintenance mode. 00817 xSemaphoreGive( xUSBMutex ); 00818 00819 // If the USB clock is frozen, unfreeze it so that we can write in the 00820 // USB registers. The USB clock is frozen if a "Device Suspend" event 00821 // occured (no more USB activity detected) (cf. usb_general_interrupt()). 00822 if(TRUE == Is_usb_clock_frozen()) 00823 { 00824 Usb_unfreeze_clock(); 00825 } 00826 // If it is not already detached, physically detach the USB device. 00827 if(FALSE == Is_usb_detached()) 00828 { 00829 Usb_detach(); 00830 } 00831 vTaskDelay(500); // Wait 500ms 00832 Usb_attach(); // Reconnect the device. 00833 00834 bIsInMaintenance = TRUE; 00835 u8IsMaintenanceRequired = 0; 00836 TRACE_COM2( "Entering maintenance mode"); 00837 #ifdef MMILCD_ENABLE 00838 vMMI_SetUserMenuMode( eUserMenuWaitHost, pdTRUE ); 00839 #endif 00840 } 00841 return( pdTRUE ); 00842 } 00843 else 00844 #endif 00845 #endif 00846 return( xSemaphoreGive( xSemaphore ) ); 00847 }
portBASE_TYPE x_supervisor_SemaphoreTake | ( | xSemaphoreHandle | xSemaphore, | |
portTickType | xBlockTime | |||
) |
Take a system mutex.
xSemaphore | A handle to the semaphore being obtained. | |
xBlockTime | The time in ticks to wait for the semaphore to become available. |
xSemaphore | A handle to the semaphore being released. | |
xBlockTime | The time in ticks to wait for the semaphore to become available. |
Definition at line 778 of file supervisor.c.
References bOutOfMaintenance, and xUSBMutex.
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().
00779 { 00780 #ifdef USB_ENABLE 00781 #if USB_DEVICE_FEATURE == ENABLED 00782 // Deal with the case where (the remote USB host disconnects then plugs back 00783 // almost immediately) AND (we haven't fully left the maintenance mode yet). 00784 if( ( xSemaphore == xUSBMutex ) && ( TRUE == bOutOfMaintenance ) ) 00785 return( pdFALSE ); 00786 else 00787 #endif 00788 #endif 00789 return( xSemaphoreTake( xSemaphore, xBlockTime ) ); 00790 }