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.
appl_adimap_separate16.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 ** Example of an ADI setup with 32 ADIs each one holding a 16 bit value. 00027 ** 00028 ** In abcc_drv_cfg.h make sure that the following definitions are set to: 00029 ** ABCC_CFG_STRUCT_DATA_TYPE ( FALSE ) 00030 ** ABCC_CFG_ADI_GET_SET_CALLBACK ( TRUE ) 00031 ******************************************************************************** 00032 ******************************************************************************** 00033 */ 00034 00035 #include "appl_adi_config.h" 00036 00037 #if ( APPL_ACTIVE_ADI_SETUP == APPL_ADI_SETUP_SEPARATE_16 ) 00038 00039 #if( ABCC_CFG_STRUCT_DATA_TYPE || !ABCC_CFG_ADI_GET_SET_CALLBACK ) 00040 #error ABCC_CFG_ADI_GET_SET_CALLBACK must be set to TRUE and ABCC_CFG_STRUCT_DATA_TYPE set to FALSE in order to run this example 00041 #endif 00042 00043 /******************************************************************************* 00044 ** Constants 00045 ******************************************************************************** 00046 */ 00047 00048 /******************************************************************************* 00049 ** Typedefs 00050 ******************************************************************************** 00051 */ 00052 00053 /******************************************************************************* 00054 ** Private Globals 00055 ******************************************************************************** 00056 */ 00057 /*------------------------------------------------------------------------------ 00058 ** Forward declarations 00059 **------------------------------------------------------------------------------ 00060 */ 00061 static void SetAdi10Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); 00062 static void GetAdi11Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); 00063 00064 /*------------------------------------------------------------------------------ 00065 ** Data holder for the ADI instances 00066 **------------------------------------------------------------------------------ 00067 */ 00068 static UINT16 appl_aiUint16_10[ 32 ]; 00069 static UINT16 appl_aiUint16_11[ 32 ]; 00070 static UINT16 appl_Uint16_12 = 0; 00071 /******************************************************************************* 00072 ** Public Globals 00073 ******************************************************************************** 00074 */ 00075 00076 /*------------------------------------------------------------------------------ 00077 ** 32 16-bit values individually 00078 ** See abcc_ad_if.h for a more detailed description. 00079 **------------------------------------------------------------------------------ 00080 */ 00081 /*----------------------------------------------------------------------------------------------------------------------- 00082 ** iInstance | pabName | bDataType | bNumOfElements | bDesc | pxValuePtr | pxValuePropPtr| pnGetAdiValue | pnSetAdiValue 00083 **----------------------------------------------------------------------------------------------------------------------- 00084 */ 00085 const AD_AdiEntryType APPL_asAdiEntryList[] = 00086 { 00087 { 10, "ABP_UINT16_SET", ABP_UINT16, 32, APPL_READ_MAP_WRITE_ACCESS_DESC, { { appl_aiUint16_10 ,NULL } }, NULL, SetAdi10Value }, 00088 { 11, "ABP_UINT16_GET", ABP_UINT16, 32, APPL_WRITE_MAP_READ_ACCESS_DESC, { { appl_aiUint16_11 ,NULL } }, GetAdi11Value, NULL }, 00089 { 12, "ABP_UINT16_COUNTER", ABP_UINT16, 1, APPL_NOT_MAP_WRITE_ACCESS_DESC, { { &appl_Uint16_12 ,NULL } }, NULL, NULL }, 00090 }; 00091 00092 /* 00093 **------------------------------------------------------------------------------ 00094 ** Map all adi:s in both directions 00095 ** See abcc_ad_if.h for a more detailed description. 00096 **------------------------------------------------------------------------------ 00097 ** 1. AD instance | 2. Direction | 3. Num elements | 4. Start index | 00098 **------------------------------------------------------------------------------ 00099 */ 00100 const AD_DefaultMapType APPL_asAdObjDefaultMap[] = 00101 { 00102 { 10, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 }, 00103 { 11, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 }, 00104 { AD_DEFAULT_MAP_END_ENTRY } 00105 }; 00106 /******************************************************************************* 00107 ** Private Services 00108 ******************************************************************************** 00109 */ 00110 /*------------------------------------------------------------------------------ 00111 ** Callback of type ABCC_GetAdiValueFuncType. The function will be called when 00112 ** the network reads ADI #11. It will increment the value of ADI#12 every time 00113 ** this is done. 00114 ** 00115 ** ABCC_GetAdiValueFuncType is declared in abcc_ad_if.h 00116 **------------------------------------------------------------------------------ 00117 */ 00118 static void GetAdi11Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) 00119 { 00120 appl_Uint16_12++; 00121 } 00122 /*------------------------------------------------------------------------------ 00123 ** Callback of type ABCC_SetAdiValueFuncType. The function will be called when 00124 ** the network writes to ADI#10. It copies the changed values from ADI#10 to ADI#11. 00125 ** 00126 ** ABCC_SetAdiValueFuncType is declared in abcc_ad_if.h 00127 **------------------------------------------------------------------------------ 00128 */ 00129 static void SetAdi10Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) 00130 { 00131 UINT8 index; 00132 for( index = bStartIndex ; index < bStartIndex+bNumElements ; index++ ) 00133 { 00134 appl_aiUint16_11[ index ] = appl_aiUint16_10[ index ]; 00135 } 00136 } 00137 /******************************************************************************* 00138 ** Public Services 00139 ******************************************************************************** 00140 */ 00141 UINT16 APPL_GetNumAdi( void ) 00142 { 00143 return( sizeof( APPL_asAdiEntryList ) / sizeof( AD_AdiEntryType ) ); 00144 } 00145 /******************************************************************************* 00146 ** Tasks 00147 ******************************************************************************** 00148 */ 00149 #endif 00150
Generated on Tue Jul 12 2022 15:51:57 by
