William Kane / Generic

Dependents:   LaserioLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers abcc_drv_ser_if.h Source File

abcc_drv_ser_if.h

00001 /*******************************************************************************
00002 ********************************************************************************
00003 **                                                                            **
00004 ** ABCC Driver version 4.01.01 (2015-12-14)                                   **
00005 **                                                                            **
00006 ** Delivered with:                                                            **
00007 **    ABP         7.16.01 (2015-10-14)                                        **
00008 **                                                                            */
00009 /*******************************************************************************
00010 ********************************************************************************
00011 ** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB                 **
00012 **                                                                            **
00013 ** This code is the property of HMS Industrial Networks AB.                   **
00014 ** The source code may not be reproduced, distributed, or used without        **
00015 ** permission. When used together with a product from HMS, this code can be   **
00016 ** modified, reproduced and distributed in binary form without any            **
00017 ** restrictions.                                                              **
00018 **                                                                            **
00019 ** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT    **
00020 ** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR     **
00021 ** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR     **
00022 ** THAT DEFECTS IN IT CAN BE CORRECTED.                                       **
00023 ********************************************************************************
00024 ********************************************************************************
00025 ** Defines the generic driver interface implemented by each specific driver.
00026 ********************************************************************************
00027 ********************************************************************************
00028 ** Driver services:
00029 **       ABCC_DrvSerInit()                      - Initialize driver privates and states to default values.
00030 **       ABCC_DrvSerISR()                       - Calls in the interrupt context to acknowledge received interrupts.
00031 **       ABCC_DrvSerExecute()                   - Drives the internal send/receive process if applicable
00032 **       ABCC_DrvSerWriteMessage()              - Writes a message.
00033 **       ABCC_DrvSerWriteProcessData()          - Writes current process data.
00034 **       ABCC_DrvSerIsReadyForWriteMessage()    - Checks if the driver is ready to send a new write message.
00035 **       ABCC_DrvSerIsReadyForCmd()             - Checks if the Anybus is ready to receive a new command message.
00036 **       ABCC_DrvSerSetNbrOfCmds()              - Sets the number of simultaneous commands that is supported by the application.
00037 **       ABCC_DrvSerSetAppStatus()              - Sets the current application status.
00038 **       ABCC_DrvSerSetPdSize()                 - Sets the current process data size.
00039 **       ABCC_DrvSerSetMsgReceiverBuffer()      - Sets the message receiver buffer.
00040 **       ABCC_DrvSerSetIntMask()                - Set interrupt mask
00041 **       ABCC_DrvSerGetWrPdBuffer()             - Get wrpd buffer
00042 **       ABCC_DrvSerGetModCap()                 - Read module capability
00043 **       ABCC_DrvSerGetLedStat()                - Read led status
00044 **       ABCC_DrvSerGetIntStatus()              - Get current interrupt status
00045 **       ABCC_DrvSerGetAnybusState()            - Get current Anybus state
00046 **       ABCC_DrvSerReadProcessData()           - Get read process data if any.
00047 **       ABCC_DrvSerReadMessage()               - Get read message if any.
00048 **       ABCC_DrvSerRegisterWd()                - Function to call when Wd timeOuts
00049 **       ABCC_DrvSerIsSuperviced()              - Is the network supervised
00050 ********************************************************************************
00051 ********************************************************************************
00052 */
00053 #ifndef PHY_DRV_SER_IF_H_
00054 #define PHY_DRV_SER_IF_H_
00055 
00056 #include "abcc_drv_cfg.h"
00057 #include "abcc_td.h"
00058 #include "abp.h"
00059 
00060 #if( ABCC_CFG_DRV_SERIAL )
00061 /*******************************************************************************
00062 ** Constants
00063 ********************************************************************************
00064 */
00065 
00066 /*******************************************************************************
00067 ** Typedefs
00068 ********************************************************************************
00069 */
00070 
00071 
00072 
00073 /*******************************************************************************
00074 ** Public Globals
00075 ********************************************************************************
00076 */
00077 
00078 
00079 /*******************************************************************************
00080 ** Public Services
00081 ********************************************************************************
00082 */
00083 
00084 /*------------------------------------------------------------------------------
00085 ** Initializes the driver to default values.
00086 ** Must be called before the driver is used.
00087 **------------------------------------------------------------------------------
00088 ** Arguments:
00089 **       None.
00090 **
00091 ** Returns:
00092 **       None.
00093 **------------------------------------------------------------------------------
00094 */
00095 EXTFUNC void ABCC_DrvSerInit( UINT8 bOpmode );
00096 
00097 
00098 /*------------------------------------------------------------------------------
00099 ** Calls in the interrupt context to acknowledge received interrupts.
00100 **
00101 ** Remarks:
00102 **       The ISR routine will clear all pending interrupts.
00103 **------------------------------------------------------------------------------
00104 ** Arguments:
00105 **       None.
00106 **
00107 ** Returns:
00108 **       Acknowledged interrupts.
00109 **------------------------------------------------------------------------------
00110 */
00111 EXTFUNC UINT16  ABCC_DrvSerISR( void );
00112 
00113 
00114 /*------------------------------------------------------------------------------
00115 ** Drives the internal send process.
00116 **------------------------------------------------------------------------------
00117 ** Arguments:
00118 **       None.
00119 **
00120 ** Returns:
00121 **       None.
00122 **------------------------------------------------------------------------------
00123 */
00124 EXTFUNC void ABCC_DrvSerRunDriverTx( void );
00125 
00126 /*------------------------------------------------------------------------------
00127 ** Drives the internal receive process.
00128 **------------------------------------------------------------------------------
00129 ** Arguments:
00130 **       None.
00131 **
00132 ** Returns:
00133 **       Pointer to successfully sent write message.
00134 **------------------------------------------------------------------------------
00135 */
00136 EXTFUNC ABP_MsgType* ABCC_DrvSerRunDriverRx( void );
00137 
00138 
00139 /*------------------------------------------------------------------------------
00140 ** Writes a message to the driver.
00141 **------------------------------------------------------------------------------
00142 ** Arguments:
00143 **       psWriteMsg:    Pointer to message.
00144 **
00145 ** Returns:
00146 **       True:          Message was successfully written and can be deallocated
00147 **                      immediately.
00148 **       False:         Message was not yet written and cannot be deallocated.
00149 **                      The psWriteMsg pointer is owned by the driver until the
00150 **                      message is written and the pointer is returned in the
00151 **                      driver execution response.
00152 **------------------------------------------------------------------------------
00153 */
00154 EXTFUNC BOOL ABCC_DrvSerWriteMessage( ABP_MsgType* psWriteMsg );
00155 
00156 
00157 /*------------------------------------------------------------------------------
00158 ** Writes current process data.
00159 ** The data is copied before returning from the method.
00160 **------------------------------------------------------------------------------
00161 ** Arguments:
00162 **       pxProcessData: Pointer to process data to be sent.
00163 **
00164 ** Returns:
00165 **       None.
00166 **------------------------------------------------------------------------------
00167 */
00168 EXTFUNC void ABCC_DrvSerWriteProcessData( void* pxProcessData );
00169 
00170 /*------------------------------------------------------------------------------
00171 ** Checks if the driver is in the correct state for writing process data to the anybus
00172 **------------------------------------------------------------------------------
00173 ** Arguments:
00174 **       None.
00175 **
00176 ** Returns:
00177 **       True:          Driver is in correct state to send WrPd
00178 **       False:         Driver is not in correct state to send Wrpd
00179 **------------------------------------------------------------------------------
00180 */
00181 EXTFUNC BOOL ABCC_DrvSerIsReadyForWrPd( void );
00182 
00183 
00184 /*------------------------------------------------------------------------------
00185 ** Checks if the driver is ready to send a new write message.
00186 **------------------------------------------------------------------------------
00187 ** Arguments:
00188 **       None.
00189 **
00190 ** Returns:
00191 **       True:          Driver is ready to send a new write message.
00192 **       False:         Driver is not ready to send a new write message.
00193 **------------------------------------------------------------------------------
00194 */
00195 EXTFUNC BOOL ABCC_DrvSerIsReadyForWriteMessage( void );
00196 
00197 
00198 /*------------------------------------------------------------------------------
00199 ** The host application checks if the Anybus is ready to receive a new command
00200 ** message.
00201 **------------------------------------------------------------------------------
00202 ** Arguments:
00203 **       None.
00204 **
00205 ** Returns:
00206 **       True:          OK to send new command.
00207 **       False:         NOK to send new command.
00208 **------------------------------------------------------------------------------
00209 */
00210 EXTFUNC BOOL ABCC_DrvSerIsReadyForCmd( void );
00211 
00212 
00213 /*------------------------------------------------------------------------------
00214 ** Sets the number of simultaneous commands that is supported by the application.
00215 **------------------------------------------------------------------------------
00216 ** Arguments:
00217 **       bNbrOfCmds:    Number of commands that the application is ready to receive.
00218 **
00219 ** Returns:
00220 **       None.
00221 **------------------------------------------------------------------------------
00222 */
00223 EXTFUNC void ABCC_DrvSerSetNbrOfCmds( UINT8 bNbrOfCmds );
00224 
00225 
00226 /*------------------------------------------------------------------------------
00227 **  Sets the current application status.
00228 **  Note! This information is not supported by all protocols.
00229 **------------------------------------------------------------------------------
00230 ** Arguments:
00231 **       eAppStatus:    Current application status.
00232 **
00233 ** Returns:
00234 **       None.
00235 **------------------------------------------------------------------------------
00236 */
00237 EXTFUNC void ABCC_DrvSerSetAppStatus( ABP_AppStatusType eAppStatus );
00238 
00239 
00240 /*------------------------------------------------------------------------------
00241 ** Sets the current process data size.
00242 **------------------------------------------------------------------------------
00243 ** Arguments:
00244 **       iReadPdSize:   Size of read process data (bytes)
00245 **       iWritePdSize:  Size of write process data (bytes)
00246 **
00247 ** Returns:
00248 **       None.
00249 **------------------------------------------------------------------------------
00250 */
00251 EXTFUNC void ABCC_DrvSerSetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize );
00252 
00253 
00254 /*------------------------------------------------------------------------------
00255 ** Sets the receiver buffer, to be used for the next read message.
00256 **------------------------------------------------------------------------------
00257 ** Arguments:
00258 **       psReadMsg:     Pointer where next read message will be put.
00259 **                      psReadMsg is not allowed to contain a NULL value.
00260 **
00261 ** Returns:
00262 **       None.
00263 **------------------------------------------------------------------------------
00264 */
00265 EXTFUNC void ABCC_DrvSerSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg );
00266 
00267 
00268 /*------------------------------------------------------------------------------
00269 ** Sets Interrupt mask according to h_aci.h.
00270 **------------------------------------------------------------------------------
00271 ** Arguments:
00272 **       iIntMask:      Interrupt mask set according to h_aci.h.
00273 **
00274 ** Returns:
00275 **       None.
00276 **------------------------------------------------------------------------------
00277 */
00278 EXTFUNC void ABCC_DrvSerSetIntMask( const UINT16 iIntMask );
00279 
00280 
00281 /*------------------------------------------------------------------------------
00282 ** Get WrpdBuffer for the user to update.
00283 **------------------------------------------------------------------------------
00284 ** Arguments:
00285 **       None.
00286 **
00287 ** Returns:
00288 **       Pointer to WrPd buffer.
00289 **------------------------------------------------------------------------------
00290 */
00291 EXTFUNC void* ABCC_DrvSerGetWrPdBuffer( void );
00292 
00293 
00294 /*------------------------------------------------------------------------------
00295 ** Read module capabillity
00296 **------------------------------------------------------------------------------
00297 ** Arguments:
00298 **       None.
00299 **
00300 ** Returns:
00301 **       Module capability.
00302 **------------------------------------------------------------------------------
00303 */
00304 EXTFUNC UINT16 ABCC_DrvSerGetModCap( void );
00305 
00306 
00307 /*------------------------------------------------------------------------------
00308 ** Read module capability
00309 **------------------------------------------------------------------------------
00310 ** Arguments:
00311 **       None.
00312 **
00313 ** Returns:
00314 **       Module capability.
00315 **------------------------------------------------------------------------------
00316 */
00317 EXTFUNC UINT16 ABCC_DrvSerGetLedStatus( void );
00318 
00319 
00320 /*------------------------------------------------------------------------------
00321 ** Gets the Anybus interrupt status.
00322 **
00323 ** Remarks:
00324 **       The ABCC_DrvISR() function will clear all pending interrupts. This
00325 **       function must be called before ABCC_DrvISR() or it will always return 0.
00326 **------------------------------------------------------------------------------
00327 ** Arguments:
00328 **       None.
00329 **
00330 ** Returns:
00331 **       The Anybus interrupt status.
00332 **------------------------------------------------------------------------------
00333 */
00334 EXTFUNC UINT16 ABCC_DrvSerGetIntStatus( void );
00335 
00336 
00337 /*------------------------------------------------------------------------------
00338 ** Gets the Anybus state.
00339 **------------------------------------------------------------------------------
00340 ** Arguments:
00341 **       None.
00342 **
00343 ** Returns:
00344 **       The Anybus state.
00345 **------------------------------------------------------------------------------
00346 */
00347 EXTFUNC UINT8 ABCC_DrvSerGetAnybusState( void );
00348 
00349 
00350 /*------------------------------------------------------------------------------
00351 ** Reads the read process data.
00352 **------------------------------------------------------------------------------
00353 ** Arguments:
00354 **       None.
00355 **
00356 ** Returns:
00357 **       A pointer to the read process data; or NULL if no process data to read
00358 **       was available.
00359 **------------------------------------------------------------------------------
00360 */
00361 EXTFUNC void* ABCC_DrvSerReadProcessData( void );
00362 
00363 
00364 /*------------------------------------------------------------------------------
00365 ** Reads the read message.
00366 **------------------------------------------------------------------------------
00367 ** Arguments:
00368 **       None.
00369 **
00370 ** Returns:
00371 **       A pointer to the read message; or NULL if no message is available.
00372 **       The pointer, if not NULL, will point to the buffer previously set by
00373 **       calling ABCC_DrvSetMsgReceiverBuffer().
00374 **------------------------------------------------------------------------------
00375 */
00376 EXTFUNC ABP_MsgType* ABCC_DrvSerReadMessage( void );
00377 
00378 /*------------------------------------------------------------------------------
00379 **  Returns supervision bit in status register.
00380 **------------------------------------------------------------------------------
00381 ** Arguments:
00382 **          -
00383 **
00384 ** Returns:
00385 **          TRUE: The device is supervised by another network device.
00386 **------------------------------------------------------------------------------
00387 */
00388 EXTFUNC BOOL ABCC_DrvSerIsSupervised( void );
00389 
00390 
00391 /*------------------------------------------------------------------------------
00392 **  Returns anybus status register.
00393 **------------------------------------------------------------------------------
00394 ** Arguments:
00395 **          -
00396 **
00397 ** Returns:
00398 **          Anybus status register
00399 **------------------------------------------------------------------------------
00400 */
00401 EXTFUNC UINT8 ABCC_DrvSerGetAnbStatus( void );
00402 
00403 
00404 #endif  /* ABCC_CFG_DRV_SERIAL */
00405 
00406 #endif  /* inclusion lock */
00407 
00408 /*******************************************************************************
00409 ** End of drv_if.h
00410 ********************************************************************************
00411 */