app_gsdml.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*********************************************************************
  2. * _ _ _
  3. * _ __ | |_ _ | | __ _ | |__ ___
  4. * | '__|| __|(_)| | / _` || '_ \ / __|
  5. * | | | |_ _ | || (_| || |_) |\__ \
  6. * |_| \__|(_)|_| \__,_||_.__/ |___/
  7. *
  8. * www.rt-labs.com
  9. * Copyright 2021 rt-labs AB, Sweden.
  10. *
  11. * This software is dual-licensed under GPLv3 and a commercial
  12. * license. See the file LICENSE.md distributed with this software for
  13. * full license information.
  14. ********************************************************************/
  15. #ifndef APP_GSDML_H
  16. #define APP_GSDML_H
  17. /**
  18. * @file
  19. * @brief Device properties defined by the GSDML device definition
  20. *
  21. * Functions for getting module, submodule and parameter
  22. * configurations using their ids.
  23. *
  24. * Important:
  25. * Any change in this file may require an update of the GSDML file.
  26. * Note that when the GSDML file is updated it has to be reloaded
  27. * in your Profinet engineering tool. PLC applications may be affected.
  28. *
  29. * Design requires unique submodule IDs and unique parameter indexes.
  30. */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #include <pnet_api.h>
  35. #define APP_GSDML_API 0
  36. #define APP_GSDML_DEFAULT_STATION_NAME "lan9662-dev"
  37. /* GSDML tag: VendorID */
  38. #define APP_GSDML_VENDOR_ID 0x0493
  39. /* GSDML tag: DeviceID */
  40. #define APP_GSDML_DEVICE_ID 0x9662
  41. /* Used in DCP communication */
  42. #define APP_GSDML_OEM_VENDOR_ID 0xcafe
  43. #define APP_GSDML_OEM_DEVICE_ID 0xee02
  44. /* Used in I&M0 */
  45. #define APP_GSDML_IM_HARDWARE_REVISION 3
  46. #define APP_GSDML_IM_VERSION_MAJOR 1
  47. #define APP_GSDML_IM_VERSION_MINOR 2
  48. /* Allowed: 'V', 'R', 'P', 'U', 'T' */
  49. #define APP_GSDML_SW_REV_PREFIX 'V'
  50. #define APP_GSDML_PROFILE_ID 0x1234
  51. #define APP_GSDML_PROFILE_SPEC_TYPE 0x5678
  52. #define APP_GSDML_IM_REVISION_COUNTER 0 /* Typically 0 */
  53. /* Note: You need to read out the actual hardware serial number instead */
  54. #define APP_GSDML_EXAMPLE_SERIAL_NUMBER "007"
  55. /* Initial values. Can be overwritten by PLC */
  56. #define APP_GSDML_TAG_FUNCTION "my function"
  57. #define APP_GSDML_TAG_LOCATION "my location"
  58. #define APP_GSDML_IM_DATE "2022-03-01 10:03"
  59. #define APP_GSDML_DESCRIPTOR "my descriptor"
  60. #define APP_GSDML_SIGNATURE ""
  61. /* GSDML tag: Writeable_IM_Records */
  62. #define APP_GSDML_IM_SUPPORTED \
  63. (PNET_SUPPORTED_IM1 | PNET_SUPPORTED_IM2 | PNET_SUPPORTED_IM3)
  64. /* GSDML tag: OrderNumber */
  65. #define APP_GSDML_ORDER_ID "12345 Abcdefghijk"
  66. /* GSDML tag: ModuleInfo / Name */
  67. #define APP_GSDML_PRODUCT_NAME "P-Net LAN9662 Sample"
  68. /* GSDML tag: MinDeviceInterval */
  69. #define APP_GSDML_MIN_DEVICE_INTERVAL 32 /* 1ms */
  70. #define APP_GSDML_DIAG_CUSTOM_USI 0x1234
  71. /* See "Specification for GSDML" 8.26 LogBookEntryItem for allowed values */
  72. #define APP_GSDML_LOGBOOK_ERROR_CODE 0x20 /* Manufacturer specific */
  73. #define APP_GSDML_LOGBOOK_ERROR_DECODE 0x82 /* Manufacturer specific */
  74. #define APP_GSDML_LOGBOOK_ERROR_CODE_1 PNET_ERROR_CODE_1_FSPM
  75. #define APP_GSDML_LOGBOOK_ERROR_CODE_2 0x00 /* Manufacturer specific */
  76. #define APP_GSDML_LOGBOOK_ENTRY_DETAIL 0xFEE1DEAD /* Manufacturer specific */
  77. #define APP_GSDML_MAX_SUBMODULES 20
  78. #define APP_GSDML_DEFAULT_MAUTYPE 0x10 /* Copper 100 Mbit/s Full duplex */
  79. #define APP_GSDML_ALARM_PAYLOAD_SIZE 1 /* bytes */
  80. #define APP_GSDML_MOD_ID_DIGITAL_IN_1x8 0x00001001
  81. #define APP_GSDML_MOD_ID_DIGITAL_OUT_1x8 0x00001002
  82. #define APP_GSDML_MOD_ID_DIGITAL_IN_1x64 0x00001003
  83. #define APP_GSDML_MOD_ID_DIGITAL_IN_2x32a 0x00001004
  84. #define APP_GSDML_MOD_ID_DIGITAL_IN_2x32b 0x00001005
  85. #define APP_GSDML_MOD_ID_DIGITAL_IN_1x800 0x00001006
  86. #define APP_GSDML_MOD_ID_DIGITAL_OUT_1x64 0x00001007
  87. #define APP_GSDML_MOD_ID_DIGITAL_OUT_2x32a 0x00001008
  88. #define APP_GSDML_MOD_ID_DIGITAL_OUT_2x32b 0x00001009
  89. #define APP_GSDML_MOD_ID_DIGITAL_OUT_1x800 0x0000100A
  90. #define APP_GSDML_MOD_ID_DIGITAL_IN_PORT_A 0x0000100B
  91. #define APP_GSDML_MOD_ID_DIGITAL_OUT_PORT_A 0x0000100C
  92. #define APP_GSDML_SUBMOD_ID_DIGITAL_IN_1x8 0x00002001
  93. #define APP_GSDML_SUBMOD_ID_DIGITAL_OUT_1x8 0x00002002
  94. #define APP_GSDML_SUBMOD_ID_DIGITAL_IN_1x64 0x00002003
  95. #define APP_GSDML_SUBMOD_ID_DIGITAL_IN_2x32a 0x00002004
  96. #define APP_GSDML_SUBMOD_ID_DIGITAL_IN_2x32b 0x00002005
  97. #define APP_GSDML_SUBMOD_ID_DIGITAL_IN_1x800 0x00002006
  98. #define APP_GSDML_SUBMOD_ID_DIGITAL_OUT_1x64 0x00002007
  99. #define APP_GSDML_SUBMOD_ID_DIGITAL_OUT_2x32a 0x00002008
  100. #define APP_GSDML_SUBMOD_ID_DIGITAL_OUT_2x32b 0x00002009
  101. #define APP_GSDML_SUBMOD_ID_DIGITAL_OUT_1x800 0x0000200A
  102. #define APP_GSDML_SUBMOD_ID_DIGITAL_IN_PORT_A 0x0000200B
  103. #define APP_GSDML_SUBMOD_ID_DIGITAL_OUT_PORT_A 0x0000200C
  104. #define APP_GSDML_SIZE_DIGITAL_IN_1x8 1
  105. #define APP_GSDML_SIZE_DIGITAL_OUT_1x8 1
  106. #define APP_GSDML_SIZE_DIGITAL_IN_1x64 8
  107. #define APP_GSDML_SIZE_DIGITAL_IN_2x32a 8
  108. #define APP_GSDML_SIZE_DIGITAL_IN_2x32b 8
  109. #define APP_GSDML_SIZE_DIGITAL_IN_1x800 100
  110. #define APP_GSDML_SIZE_DIGITAL_OUT_1x64 8
  111. #define APP_GSDML_SIZE_DIGITAL_OUT_2x32a 8
  112. #define APP_GSDML_SIZE_DIGITAL_OUT_2x32b 8
  113. #define APP_GSDML_SIZE_DIGITAL_OUT_1x800 100
  114. #define APP_GSDML_SIZE_DIGITAL_IN_PORT_A 4
  115. #define APP_GSDML_SIZE_DIGITAL_OUT_PORT_A 4
  116. #define APP_GSDML_MAX_SUBMODULE_DATA_SIZE 100
  117. /* TODO support virtual and pluggable submodules. */
  118. typedef struct cfg_module
  119. {
  120. uint32_t id;
  121. const char * name;
  122. uint32_t fixed_slot; /* Set to UINT32_MAX if not fixed */
  123. uint32_t submodules[]; /* Variable length, ends with 0*/
  124. } app_gsdml_module_t;
  125. typedef struct app_gsdml_submodule
  126. {
  127. uint32_t id;
  128. const char * name;
  129. uint32_t api;
  130. uint32_t fixed_subslot; /* Set to UINT32_MAX if not fixed */
  131. pnet_submodule_dir_t data_dir;
  132. uint16_t insize;
  133. uint16_t outsize;
  134. uint16_t parameters[]; /* Variable length, ends with 0 */
  135. } app_gsdml_submodule_t;
  136. typedef struct app_gsdml_param
  137. {
  138. uint32_t index;
  139. const char * name;
  140. uint16_t length;
  141. } app_gsdml_param_t;
  142. /**
  143. * Get array of supported modules
  144. * @param array_len Out: Length of array
  145. * @return Modules array
  146. */
  147. const app_gsdml_module_t ** app_gsdml_get_modules (uint32_t * array_len);
  148. /**
  149. * Get array of supported submodules
  150. * @param array_len Out: Length of array
  151. * @return Submodules array
  152. */
  153. const app_gsdml_submodule_t ** app_gsdml_get_submodules (uint32_t * array_len);
  154. /**
  155. * Get array of supported parameters
  156. * @param array_len Out: Length of array
  157. * @return Parameters array
  158. */
  159. const app_gsdml_param_t ** app_gsdml_get_parameters (uint32_t * array_len);
  160. /**
  161. * Get module configuration from module id
  162. * @param module_id In: Module id
  163. * @return Module configuration, NULL if not found
  164. */
  165. const app_gsdml_module_t * app_gsdml_get_module_cfg (uint32_t module_id);
  166. /**
  167. * Get submodule module configuration from submodule id
  168. * @param submodule_id In: Submodule id
  169. * @return Submodule configuration, NULL if not found
  170. */
  171. const app_gsdml_submodule_t * app_gsdml_get_submodule_cfg (
  172. uint32_t submodule_id);
  173. /**
  174. * Get parameter configuration from parameter index
  175. * @param submodule_id In: Submodule id
  176. * @param index In: Parameters index
  177. * @return Parameter configuration, NULL if not found
  178. */
  179. const app_gsdml_param_t * app_gsdml_get_parameter_cfg (
  180. uint32_t submodule_id,
  181. uint32_t index);
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif /* APP_GSDML_H */