William Kane / Generic

Dependents:   LaserioLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers appl_abcc_handler.h Source File

appl_abcc_handler.h

00001 /*******************************************************************************
00002 ********************************************************************************
00003 **                                                                            **
00004 ** ABCC Starter Kit version 2.01.01 (2015-12-14)                              **
00005 **                                                                            **
00006 ** Delivered with:                                                            **
00007 **    ABCC Driver 4.01.01 (2015-12-14)                                        **
00008 **    ABP         7.16.01 (2015-10-14)                                        **
00009 **                                                                            */
00010 /*******************************************************************************
00011 ********************************************************************************
00012 ** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB                 **
00013 **                                                                            **
00014 ** This code is the property of HMS Industrial Networks AB.                   **
00015 ** The source code may not be reproduced, distributed, or used without        **
00016 ** permission. When used together with a product from HMS, permission is      **
00017 ** granted to modify, reproduce and distribute the code in binary form        **
00018 ** without any restrictions.                                                  **
00019 **                                                                            **
00020 ** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT    **
00021 ** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR     **
00022 ** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR     **
00023 ** THAT DEFECTS IN IT CAN BE CORRECTED.                                       **
00024 ********************************************************************************
00025 ********************************************************************************
00026 ** This is an example implementation of an application handler to control the
00027 ** ABCC module. It has support to initialize, run and reset/shutdown the ABCC.
00028 ** The state machine shall be executed cyclically and it returns its current
00029 ** status after every execution.
00030 ********************************************************************************
00031 ********************************************************************************
00032 ** Services:
00033 **    APPL_HandleAbcc()              - Runs the state machine controlling the
00034 **                                     ABCC module
00035 **    APPL_RestartAbcc()             - Forces the state machine to restart the
00036 **                                     ABCC module
00037 **    APPL_Shutdown()                - Forces the state machine to shut down the
00038 **                                     ABCC module
00039 **    APPL_Reset()                   - Forces the state machine to reset the
00040 **                                     ABCC module
00041 **    APPL_RestoreToDefault()        - Restores any NVS parameter to its default
00042 **                                     value
00043 **    APPL_GetCandidateFwAvailable() - Call to check if there is a firmware in
00044 **                                     the candidate area
00045 **    APPL_SetCandidateFwAvailable() - Sets whether firmware is available in the
00046 **                                     candidate area
00047 **    APPL_IsResetRequestAllowed()   - Check if a reset is allowed
00048 **
00049 **    APPL_SetHwSwitch1Value()       - Set switch 1 value
00050 ********************************************************************************
00051 ********************************************************************************
00052 */
00053 
00054 #ifndef APPL_ABCC_HANDLER_H
00055 #define APPL_ABCC_HANDLER_H
00056 #include "abcc_td.h"
00057 #include "string.h"
00058 
00059 /*******************************************************************************
00060 ** Constants
00061 ********************************************************************************
00062 */
00063 
00064 /*******************************************************************************
00065 ** Typedefs
00066 ********************************************************************************
00067 */
00068 
00069 /*------------------------------------------------------------------------------
00070 ** Status reported by the ABCC handler controlling the ABCC module
00071 **------------------------------------------------------------------------------
00072 */
00073 typedef enum APPL_AbccHandlerStatus
00074 {
00075    APPL_MODULE_NO_ERROR,         /* Module OK */
00076    APPL_MODULE_NOT_DETECTED,     /* No module plugged */
00077    APPL_MODULE_NOT_SUPPORTED,    /* Unsupported module detected */
00078    APPL_MODULE_NOT_ANSWERING,    /* Possible reasons: Wrong API selected, defect module */
00079    APPL_MODULE_RESET,            /* Reset requested from ABCC */
00080    APPL_MODULE_SHUTDOWN,         /* Shutdown requested */
00081    APPL_MODULE_UNEXPECTED_ERROR  /* Unexpected error occurred */
00082 }
00083 APPL_AbccHandlerStatusType;
00084 
00085 /*******************************************************************************
00086 ** Public Globals
00087 ********************************************************************************
00088 */
00089 
00090 /*******************************************************************************
00091 ** Public Services
00092 ********************************************************************************
00093 */
00094 
00095 /*------------------------------------------------------------------------------
00096 ** This function shall be called on cyclic bases from the main loop to handle
00097 ** the ABCC. It includes a state machine for handling reset, run, and shutdown
00098 ** of the driver.
00099 **------------------------------------------------------------------------------
00100 ** Arguments:
00101 **    None
00102 **
00103 ** Returns:
00104 **    State of the ABCC handler
00105 **------------------------------------------------------------------------------
00106 */
00107 EXTFUNC APPL_AbccHandlerStatusType APPL_HandleAbcc( void );
00108 
00109 /*------------------------------------------------------------------------------
00110 ** This function will force the ABCC handler to restart the ABCC module
00111 **------------------------------------------------------------------------------
00112 ** Arguments:
00113 **    None
00114 **
00115 ** Returns:
00116 **    None
00117 **------------------------------------------------------------------------------
00118 */
00119 EXTFUNC void APPL_RestartAbcc( void );
00120 
00121 /*------------------------------------------------------------------------------
00122 ** This function will force the ABCC handler to shutdown the ABCC module
00123 **------------------------------------------------------------------------------
00124 ** Arguments:
00125 **    None
00126 **
00127 ** Returns:
00128 **    None
00129 **------------------------------------------------------------------------------
00130 */
00131 EXTFUNC void APPL_Shutdown( void );
00132 
00133 /*------------------------------------------------------------------------------
00134 ** This function will force the ABCC handler to reset the ABCC
00135 **------------------------------------------------------------------------------
00136 ** Arguments:
00137 **    None
00138 **
00139 ** Returns:
00140 **    None
00141 **------------------------------------------------------------------------------
00142 */
00143 EXTFUNC void APPL_Reset( void );
00144 
00145 /*------------------------------------------------------------------------------
00146 ** Application has encountered an unexpected error.
00147 ** The abcc main state machine will halt and indicate error.
00148 **------------------------------------------------------------------------------
00149 ** Arguments:
00150 **    None
00151 **
00152 ** Returns:
00153 **    None
00154 **------------------------------------------------------------------------------
00155 */
00156 EXTFUNC void APPL_UnexpectedError( void );
00157 
00158 /*------------------------------------------------------------------------------
00159 ** Called to check if the requested reset is permitted by the application.
00160 **------------------------------------------------------------------------------
00161 ** Arguments:
00162 **    bResetType           - Type of reset, see ABP_RESET_XXX defines.
00163 **
00164 ** Returns:
00165 **    BOOL                 - TRUE: Reset request is allowed.
00166 **                           FALSE: Reset request NOT allowed.
00167 **------------------------------------------------------------------------------
00168 */
00169 EXTFUNC BOOL IsResetRequestAllowed( UINT8 bResetType );
00170 
00171 /*------------------------------------------------------------------------------
00172 ** Set HW switch1 value to the application. The value is used to generate the
00173 ** the node address or the IP address (192.168.0.X) depending on network.
00174 **
00175 ** NOTE: For networks that uses an IP address and if this function is called
00176 **       with address 0 no address will be set to the ABCC.
00177 **------------------------------------------------------------------------------
00178 ** Arguments:
00179 **    bSwitchValue - Switch 1 value
00180 **
00181 ** Returns:
00182 **    None
00183 **------------------------------------------------------------------------------
00184 */
00185 EXTFUNC void APPL_SetAddress( UINT8 bSwitchValue );
00186 
00187 /*------------------------------------------------------------------------------
00188 ** Set HW switch2 value to the application. The value is used to generate the
00189 ** baud rate for networks that implements network configuration object instance
00190 ** 2.
00191 **------------------------------------------------------------------------------
00192 ** Arguments:
00193 **    bSwitchValue - Switch 2 value
00194 **
00195 ** Returns:
00196 **    None
00197 **------------------------------------------------------------------------------
00198 */
00199 EXTFUNC void APPL_SetBaudrate( UINT8 bSwitchValue );
00200 
00201 #endif  /* inclusion lock */