Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
abcc_sw_port.c
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) 2015 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 ** Platform dependent macros and functions required by the ABCC driver and 00027 ** Anybus objects implementation to be platform independent. 00028 ******************************************************************************** 00029 ******************************************************************************** 00030 */ 00031 00032 #include "abcc_sw_port.h" 00033 #include "abcc.h" 00034 00035 /******************************************************************************* 00036 ** Constants 00037 ******************************************************************************** 00038 */ 00039 00040 /******************************************************************************* 00041 ** Typedefs 00042 ******************************************************************************** 00043 */ 00044 00045 /******************************************************************************* 00046 ** Public Globals 00047 ******************************************************************************** 00048 */ 00049 00050 /******************************************************************************* 00051 ** Private Globals 00052 ******************************************************************************** 00053 */ 00054 00055 /******************************************************************************* 00056 ** Private Services 00057 ******************************************************************************** 00058 */ 00059 00060 /******************************************************************************* 00061 ** Public Services 00062 ******************************************************************************** 00063 */ 00064 00065 #ifdef ABCC_SYS_16_BIT_CHAR 00066 void ABCC_PORT_CopyOctetsImpl( void* pxDest, UINT16 iDestOctetOffset, 00067 void* pxSrc, UINT16 iSrcOctetOffset, 00068 UINT16 iNumOctets ) 00069 { 00070 UINT16 i; 00071 UINT16 iData; 00072 BOOL fOddDestOctet; 00073 BOOL fOddSrcOctet; 00074 UINT16* piDest; 00075 UINT16* piSrc; 00076 00077 fOddDestOctet = iDestOctetOffset & 1; 00078 fOddSrcOctet = iSrcOctetOffset & 1; 00079 piDest = (UINT16*)pxDest + ( iDestOctetOffset >> 1 ); 00080 piSrc = (UINT16*)pxSrc + ( iSrcOctetOffset >> 1 ); 00081 00082 for( i = 0; i < iNumOctets; i++ ) 00083 { 00084 if( fOddSrcOctet ) 00085 { 00086 iData = ABCC_GetHighAddrOct( *piSrc ); 00087 piSrc++; 00088 } 00089 else 00090 { 00091 iData = ABCC_GetLowAddrOct( *piSrc ); 00092 } 00093 fOddSrcOctet ^= 1; 00094 00095 if( fOddDestOctet ) 00096 { 00097 ABCC_SetHighAddrOct( *piDest, iData ); 00098 piDest++; 00099 } 00100 else 00101 { 00102 ABCC_SetLowAddrOct( *piDest, iData ); 00103 } 00104 fOddDestOctet ^= 1; 00105 } 00106 } 00107 00108 void ABCC_PORT_StrCpyToNativeImpl( void* pxDest, void* pxSrc, 00109 UINT16 iSrcOctetOffset, UINT16 iNbrOfChars ) 00110 { 00111 UINT16 i; 00112 UINT16* piDest; 00113 const UINT16* piSrc; 00114 BOOL fOddSrc; 00115 00116 piDest = pxDest; 00117 piSrc = pxSrc; 00118 fOddSrc = iSrcOctetOffset & 1; 00119 00120 for( i = 0; i < iNbrOfChars; i++ ) 00121 { 00122 if ( fOddSrc ) 00123 { 00124 piDest[ i ] = ABCC_GetHighAddrOct( piSrc[ i >> 1 ] ); 00125 } 00126 else 00127 { 00128 piDest[ i ] = ABCC_GetLowAddrOct( piSrc[ i >> 1 ] ); 00129 } 00130 fOddSrc ^= 1; 00131 } 00132 } 00133 00134 void ABCC_PORT_StrCpyToPackedImpl( void* pxDest, UINT16 iDestOctetOffset, 00135 const void* pxSrc, UINT16 iNbrOfChars ) 00136 { 00137 UINT16 i; 00138 UINT16* piDest; 00139 const UINT16* piSrc; 00140 BOOL fOddDest; 00141 00142 piDest = pxDest; 00143 piSrc = pxSrc; 00144 fOddDest = iDestOctetOffset & 1; 00145 00146 for( i = 0; i < iNbrOfChars; i++ ) 00147 { 00148 if ( fOddDest ) 00149 { 00150 ABCC_SetHighAddrOct( piDest[ i >> 1 ], piSrc[ i ] ); 00151 } 00152 else 00153 { 00154 ABCC_SetLowAddrOct( piDest[ i >> 1 ], piSrc[ i ] ); 00155 } 00156 fOddDest ^= 1; 00157 } 00158 } 00159 #endif 00160
Generated on Tue Jul 12 2022 15:51:56 by
