William Kane / Generic

Dependents:   LaserioLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers abcc_port.h Source File

abcc_port.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, permission is      **
00016 ** granted to modify, reproduce and distribute the code in binary form        **
00017 ** without any 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 ** ABCC driver API used by the the application.
00026 ********************************************************************************
00027 ********************************************************************************
00028 ** Services:
00029 **    ABCC_PORT_DebugPrint()        - Prints a string
00030 **    ABCC_PORT_UseCritical()       - Used if any preparation is needed before
00031 **                                    calling "ABCC_PORT_EnterCritical()".
00032 **    ABCC_PORT_EnterCritical()     - Disables all interrupts, if they are not
00033 **                                    already disabled.
00034 **    ABCC_PORT_ExitCritical()      - Restore interrupts to the state they were
00035 **                                    in when "ABCC_PORT_EnterCritical()" was
00036 **                                    called.
00037 **    ABCC_PORT_MemCopy()           - Copy a number of octets, from the source
00038 **                                    pointer to the destination pointer.
00039 **    ABCC_PORT_StrCpyToNative()    - Copy native char string to octet string
00040 **    ABCC_PORT_StrCpyToPacked()    - Copy octetstring to native char* string
00041 **    ABCC_PORT_CopyOctets()        - Copy octet aligned buffer.
00042 **    ABCC_PORT_Copy8()             - Copy octet aligned 8 bit data.
00043 **    ABCC_PORT_Copy16()            - Copy octet aligned 16 bit data.
00044 **    ABCC_PORT_Copy32()            - Copy octet aligned 32 bit data.
00045 **    ABCC_PORT_Copy64()            - Copy octet aligned 64 bit data.
00046 **
00047 ********************************************************************************
00048 ********************************************************************************
00049 */
00050 
00051 #include "abcc_sw_port.h"
00052 
00053 #ifndef ABCC_PORT_H_
00054 #define ABCC_PORT_H_
00055 
00056 /*******************************************************************************
00057 ** Constants
00058 ********************************************************************************
00059 */
00060 
00061 /*******************************************************************************
00062 ** Typedefs
00063 ********************************************************************************
00064 */
00065 
00066 /*******************************************************************************
00067 ** Public Globals
00068 ********************************************************************************
00069 */
00070 
00071 /*******************************************************************************
00072 ** Public Services
00073 ********************************************************************************
00074 */
00075 
00076 /*------------------------------------------------------------------------------
00077 ** Macro is used by driver for debug prints such as events or error debug
00078 ** information. If not defined the driver will be silent.
00079 ** Note! The compiler need to be C99 compliant to support VA_ARGS in in macro.
00080 **------------------------------------------------------------------------------
00081 ** Arguments:
00082 **    args - Formatted string
00083 **
00084 ** Returns:
00085 **    None
00086 **------------------------------------------------------------------------------
00087 */
00088 #ifndef ABCC_PORT_DebugPrint
00089 #define ABCC_PORT_DebugPrint( args )
00090 #endif
00091 
00092 /*------------------------------------------------------------------------------
00093 ** Copy a number of octets, from the source pointer to the destination pointer.
00094 ** This function can be modified to use performance enhancing platform specific
00095 ** instructions. The default implementation is memcpy().
00096 ** Note that for a 16 bit char platform this function only supports an even
00097 ** number of octets.
00098 **------------------------------------------------------------------------------
00099 ** Arguments:
00100 **    pbDest         - Pointer to the destination.
00101 **    pbSource       - Pointer to source data.
00102 **    iNbrOfOctets   - The number of octets that shall be copied.
00103 **
00104 ** Returns:
00105 **    None
00106 **------------------------------------------------------------------------------
00107 */
00108 #ifndef ABCC_PORT_MemCpy
00109 #define ABCC_PORT_MemCpy( pbDest, pbSource, iNbrOfOctets )  \
00110         #error "ABCC_PORT_MemCpy() must be ported in abcc_sw_port.h"
00111 #endif
00112 
00113 /*------------------------------------------------------------------------------
00114 ** Critical section implementation guidance.
00115 **
00116 ** Critical sections are used when there is a risk of resource conflicts or race
00117 ** conditions between ABCC interrupt handler context and the application thread.
00118 **
00119 ** Three macros are used to implement the critical sections:
00120 ** ABCC_PORT_UseCritical()
00121 ** ABCC_PORT_EnterCritical()
00122 ** ABCC_PORT_ExitCritical()
00123 **
00124 ** Depending on the configuration of the driver there are different requirements
00125 ** on the critical section implementation. Please choose the most suitable
00126 ** implementation from the numbered list below. The first statement that is true
00127 ** will choose the requirement.
00128 **
00129 ** 1. All three macros need to be implemented if any of the statements below are
00130 **    true.
00131 **       - Any message handling is done within interrupt context.
00132 **
00133 **       Requirements:
00134 **       - The implementation must support that a critical section is entered
00135 **       from interrupt context. ABCC_PORT_UseCritical() should be used for any
00136 **       declarations needed in advance by ABCC_PORT_EnterCritical().
00137 **       - When entering the critical section the required interrupts i.e.
00138 **       any interrupt that may lead to driver access, must be disabled. When
00139 **       leaving the critical section the interrupt configuration must be
00140 **       restored to the previous state.
00141 **
00142 ** 2. ABCC_PORT_EnterCritical() and ABCC_PORT_ExitCritical() need to be
00143 **    implemented if any of the statements below are true.
00144 **       - ABCC_RunTimerSystem() is called from a timer interrupt.
00145 **       - The application is accessing the ABCC driver message interface from
00146 **       different processes or threads without protecting the message
00147 **       interface on a higher level (semaphores or similar).
00148 **
00149 **       Requirement:
00150 **         - When entering the critical section the required interrupts i.e. any
00151 **         interrupt that may lead to driver access, must be disabled. When
00152 **         leaving the critical section the interrupts must be enabled again.
00153 **
00154 ** 3. If none of the above is true no implementation is required.
00155 **
00156 **------------------------------------------------------------------------------
00157 */
00158 
00159 /*------------------------------------------------------------------------------
00160 ** Please read the general description above about the critical sections
00161 ** implementation for implementation guidance.
00162 **
00163 ** If any preparation is needed before calling "ABCC_PORT_EnterCritical()" or
00164 ** "ABCC_PORT_ExitCritical()" this macro is used to add HW specific necessities.
00165 ** This could for example be a local variable to store the current interrupt
00166 ** status.
00167 **
00168 **------------------------------------------------------------------------------
00169 ** Arguments:
00170 **    None
00171 **
00172 ** Returns:
00173 **    None
00174 **------------------------------------------------------------------------------
00175 */
00176 #ifndef ABCC_PORT_UseCritical
00177 #define ABCC_PORT_UseCritical()
00178 #endif
00179 
00180 /*------------------------------------------------------------------------------
00181 ** Please read the general description above about the critical sections
00182 ** implementation for implementation guidance.
00183 **
00184 ** If required the macro temporary disables interrupts
00185 ** to avoid conflict. Note that all interrupts that could lead to a driver
00186 ** access must be disabled.
00187 **------------------------------------------------------------------------------
00188 ** Arguments:
00189 **    None
00190 **
00191 ** Returns:
00192 **    None
00193 **------------------------------------------------------------------------------
00194 */
00195 #ifndef ABCC_PORT_EnterCritical
00196 #define ABCC_PORT_EnterCritical()
00197 #endif
00198 
00199 /*------------------------------------------------------------------------------
00200 ** Please read the general description above about the critical sections
00201 ** implementation for implementation guidance.
00202 **
00203 ** Restore interrupts to the state when "ABCC_PORT_EnterCritical()"
00204 ** was called.
00205 **------------------------------------------------------------------------------
00206 ** Arguments:
00207 **    None
00208 **
00209 ** Returns:
00210 **    None
00211 **------------------------------------------------------------------------------
00212 */
00213 #ifndef ABCC_PORT_ExitCritical
00214 #define ABCC_PORT_ExitCritical()
00215 #endif
00216 
00217 /*------------------------------------------------------------------------------
00218 ** Copy a native formatted string to a packed string
00219 **------------------------------------------------------------------------------
00220 ** Arguments:
00221 **    pxDest            - Pointer to the destination.
00222 **    iDestOctetOffset  - Octet offset to the destination where the copy will
00223 **                        begin.
00224 **    pxSrc             - Pointer to source data.
00225 **    iNbrOfChars       - The number of bytes that shall be copied.
00226 **
00227 ** Returns:
00228 **    None
00229 **------------------------------------------------------------------------------
00230 */
00231 #ifndef ABCC_PORT_StrCpyToPacked
00232 #define ABCC_PORT_StrCpyToPacked( pxDest, iDestOctetOffset, pxSrc, iNbrOfChars ) \
00233         #error "ABCC_PORT_StrCpyToPacked() must be ported in abcc_sw_port.h"
00234 #endif
00235 
00236 /*------------------------------------------------------------------------------
00237 ** Copy a packed string to a native formatted string
00238 **------------------------------------------------------------------------------
00239 ** Arguments:
00240 **    pxDest            - Pointer to the destination.
00241 **    pxSrc             - Pointer to source data.
00242 **    iSrcOctetOffset   - Octet offset to the source where the copy will begin.
00243 **    iNbrOfChars       - The number of bytes that shall be copied.
00244 **
00245 ** Returns:
00246 **    None
00247 **------------------------------------------------------------------------------
00248 */
00249 #ifndef ABCC_PORT_StrCpyToNative
00250 #define ABCC_PORT_StrCpyToNative( pxDest, pxSrc, iSrcOctetOffset, iNbrOfChars ) \
00251         #error "ABCC_PORT_StrCpyToNative() must be ported in abcc_sw_port.h"
00252 #endif
00253 
00254 /*------------------------------------------------------------------------------
00255 ** Copy a number of octets from a source to a destination.
00256 ** For a 16 bit char platform octet alignment support (the octet offset is odd)
00257 ** need to be considered when porting this macro.
00258 **------------------------------------------------------------------------------
00259 ** Arguments:
00260 **    pxDest            - Base pointer to the destination.
00261 **    iDestOctetOffset  - Octet offset to the destination where the copy will
00262 **                        begin.
00263 **    pxSrc             - Base pointer to source data.
00264 **    iSrcOctetOffset   - Octet offset to the source where the copy will begin.
00265 **    iNumOctets        - Number of octets to copy.
00266 **
00267 ** Returns:
00268 **    None
00269 **------------------------------------------------------------------------------
00270 */
00271 #ifndef ABCC_PORT_CopyOctets
00272 #define ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset, iNumOctets ) \
00273         #error "ABCC_PORT_CopyOctets() must be ported in abcc_sw_port.h"
00274 #endif
00275 
00276 /*------------------------------------------------------------------------------
00277 ** Copy 8 bits from a source to a destination.
00278 ** For a 16 bit char platform octet alignment support (the octet offset is odd)
00279 ** need to be considered when porting this macro.
00280 **------------------------------------------------------------------------------
00281 ** Arguments:
00282 **    pxDest            - Base pointer to the destination.
00283 **    iDestOctetOffset  - Octet offset to the destination where the copy will
00284 **                        begin.
00285 **    pxSrc             - Base pointer to source data.
00286 **    iSrcOctetOffset   - Octet offset to the source where the copy will begin.
00287 **
00288 ** Returns:
00289 **    None
00290 **------------------------------------------------------------------------------
00291 */
00292 #ifndef ABCC_PORT_Copy8
00293 #define ABCC_PORT_Copy8( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset )   \
00294         #error "ABCC_PORT_Copy8() must be ported in abcc_sw_port.h"
00295 #endif
00296 
00297 /*------------------------------------------------------------------------------
00298 ** Copy 16 bits from a source to a destination.
00299 ** Octet alignment support (the octet offset is odd) need to be considered
00300 ** when porting this macro.
00301 **------------------------------------------------------------------------------
00302 ** Arguments:
00303 **    pxDest            - Base pointer to the destination.
00304 **    iDestOctetOffset  - Octet offset to the destination where the copy will
00305 **                        begin.
00306 **    pxSrc             - Base pointer to source data.
00307 **    iSrcOctetOffset   - Octet offset to the source where the copy will begin.
00308 **
00309 ** Returns:
00310 **    None
00311 **------------------------------------------------------------------------------
00312 */
00313 
00314 #ifndef ABCC_PORT_Copy16
00315 #define ABCC_PORT_Copy16( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \
00316         #error "ABCC_PORT_Copy16() must be ported in abcc_sw_port.h"
00317 #endif
00318 
00319 /*------------------------------------------------------------------------------
00320 ** Copy 32 bits from a source to a destination.
00321 ** Octet alignment support (the octet offset is odd) need to be considered
00322 ** when porting this macro.
00323 **------------------------------------------------------------------------------
00324 ** Arguments:
00325 **    pxDest            - Base pointer to the destination.
00326 **    iDestOctetOffset  - Octet offset to the destination where the copy will
00327 **                        begin.
00328 **    pxSrc             - Base pointer to source data.
00329 **    iSrcOctetOffset   - Octet offset to the source where the copy will begin.
00330 **
00331 ** Returns:
00332 **    None
00333 **------------------------------------------------------------------------------
00334 */
00335 #ifndef ABCC_PORT_Copy32
00336 #define ABCC_PORT_Copy32( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset )
00337         #error "ABCC_PORT_Copy32() must be ported in abcc_sw_port.h"
00338 #endif
00339 
00340 /*------------------------------------------------------------------------------
00341 ** Copy 64 bits from a source to a destination.
00342 ** Octet alignment support (the octet offset is odd) need to be considered
00343 ** when porting this macro.
00344 **------------------------------------------------------------------------------
00345 ** Arguments:
00346 **    pxDest            - Base pointer to the destination.
00347 **    iDestOctetOffset  - Octet offset to the destination where the copy will
00348 **                        begin.
00349 **    pxSrc             - Base pointer to source data.
00350 **    iSrcOctetOffset   - Octet offset to the source where the copy will begin.
00351 **
00352 ** Returns:
00353 **    None
00354 **------------------------------------------------------------------------------
00355 */
00356 #if( ABCC_CFG_64BIT_ADI_SUPPORT )
00357 #ifndef ABCC_PORT_Copy64
00358 #define ABCC_PORT_Copy64( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset )   \
00359         #error "ABCC_PORT_Copy64() must be ported in abcc_sw_port.h"
00360 #endif
00361 #endif
00362 #endif  /* inclusion lock */