CO_config.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. /**
  2. * Configuration macros for CANopenNode.
  3. *
  4. * @file CO_config.h
  5. * @ingroup CO_driver
  6. * @author Janez Paternoster
  7. * @copyright 2020 Janez Paternoster
  8. *
  9. * This file is part of CANopenNode, an opensource CANopen Stack.
  10. * Project home page is <https://github.com/CANopenNode/CANopenNode>.
  11. * For more information on CANopen see <http://www.can-cia.org/>.
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License");
  14. * you may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. #ifndef CO_CONFIG_FLAGS_H
  26. #define CO_CONFIG_FLAGS_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * @defgroup CO_STACK_CONFIG Stack configuration
  32. * @ingroup CO_driver
  33. *
  34. * Stack configuration macros specify, which parts of the stack will be enabled.
  35. *
  36. * Default values for stack configuration macros are set in corresponding
  37. * header files. The same default values are also provided in this file, but
  38. * only for documentation generator. Default values can be overridden by
  39. * CO_driver_target.h file. If specified so, they can further be overridden by
  40. * CO_driver_custom.h file.
  41. *
  42. * Stack configuration macro is specified as bits, where each bit
  43. * enables/disables some part of the configurable CANopenNode object. Flags are
  44. * used for enabling or checking specific bit. Multiple flags can be ORed
  45. * together.
  46. *
  47. * Some functionalities of CANopenNode objects, enabled by configuration macros,
  48. * requires some objects from Object Dictionary to exist. Object Dictionary
  49. * configuration must match @ref CO_STACK_CONFIG.
  50. * @{
  51. */
  52. /**
  53. * @defgroup CO_STACK_CONFIG_COMMON Common definitions
  54. * @{
  55. */
  56. /**
  57. * Enable custom callback after CAN receive
  58. *
  59. * Flag enables optional callback functions, which are part of some CANopenNode
  60. * objects. Callbacks can optionally be registered by application, which
  61. * configures threads in operating system. Callbacks are called after something
  62. * has been preprocessed by higher priority thread and must be further
  63. * processed by lower priority thread. For example when CAN message is received
  64. * and preprocessed, callback should wake up mainline processing function.
  65. * See also @ref CO_process() function.
  66. *
  67. * If callback functions are used, they must be initialized separately, after
  68. * the object initialization.
  69. *
  70. * This flag is common to multiple configuration macros.
  71. */
  72. #define CO_CONFIG_FLAG_CALLBACK_PRE 0x1000
  73. /**
  74. * Enable calculation of timerNext_us variable.
  75. *
  76. * Calculation of the timerNext_us variable is useful for smooth operation on
  77. * operating system. See also @ref CO_process() function.
  78. *
  79. * This flag is common to multiple configuration macros.
  80. */
  81. #define CO_CONFIG_FLAG_TIMERNEXT 0x2000
  82. /**
  83. * Enable dynamic behaviour of Object Dictionary variables
  84. *
  85. * Some CANopen objects uses Object Dictionary variables as arguments to
  86. * initialization functions, which are processed in communication reset section.
  87. * If this flag is set, then writing to OD variable will reconfigure
  88. * corresponding CANopen object also during CANopen normal operation.
  89. *
  90. * This flag is common to multiple configuration macros.
  91. */
  92. #define CO_CONFIG_FLAG_OD_DYNAMIC 0x4000
  93. /** @} */ /* CO_STACK_CONFIG_COMMON */
  94. /**
  95. * @defgroup CO_STACK_CONFIG_NMT_HB NMT master/slave and HB producer/consumer
  96. * @{
  97. */
  98. /**
  99. * Configuration of @ref CO_NMT_Heartbeat.
  100. *
  101. * Possible flags, can be ORed:
  102. * - CO_CONFIG_NMT_CALLBACK_CHANGE - Enable custom callback after NMT
  103. * state changes. Callback is configured by
  104. * CO_NMT_initCallbackChanged().
  105. * - CO_CONFIG_NMT_MASTER - Enable simple NMT master
  106. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  107. * received NMT CAN message.
  108. * Callback is configured by CO_NMT_initCallbackPre().
  109. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  110. * inside CO_NMT_process().
  111. */
  112. #ifdef CO_DOXYGEN
  113. #define CO_CONFIG_NMT (0)
  114. #endif
  115. #define CO_CONFIG_NMT_CALLBACK_CHANGE 0x01
  116. #define CO_CONFIG_NMT_MASTER 0x02
  117. /**
  118. * Configuration of @ref CO_HBconsumer
  119. *
  120. * Possible flags, can be ORed:
  121. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  122. * received heartbeat CAN message.
  123. * Callback is configured by CO_HBconsumer_initCallbackPre().
  124. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  125. * inside CO_HBconsumer_process().
  126. * - CO_CONFIG_HB_CONS_ENABLE - Enable heartbeat consumer.
  127. * - CO_CONFIG_HB_CONS_CALLBACK_CHANGE - Enable custom common callback after NMT
  128. * state of the monitored node changes. Callback is configured by
  129. * CO_HBconsumer_initCallbackNmtChanged().
  130. * - CO_CONFIG_HB_CONS_CALLBACK_MULTI - Enable multiple custom callbacks, which
  131. * can be configured individually for each monitored node. Callbacks are
  132. * configured by CO_HBconsumer_initCallbackNmtChanged(),
  133. * CO_HBconsumer_initCallbackHeartbeatStarted(),
  134. * CO_HBconsumer_initCallbackTimeout() and
  135. * CO_HBconsumer_initCallbackRemoteReset() functions.
  136. * - CO_CONFIG_HB_CONS_QUERY_FUNCT - Enable functions for query HB state or
  137. * NMT state of the specific monitored node.
  138. * Note that CO_CONFIG_HB_CONS_CALLBACK_CHANGE and
  139. * CO_CONFIG_HB_CONS_CALLBACK_MULTI cannot be set simultaneously.
  140. */
  141. #ifdef CO_DOXYGEN
  142. #define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE)
  143. #endif
  144. #define CO_CONFIG_HB_CONS_ENABLE 0x01
  145. #define CO_CONFIG_HB_CONS_CALLBACK_CHANGE 0x02
  146. #define CO_CONFIG_HB_CONS_CALLBACK_MULTI 0x04
  147. #define CO_CONFIG_HB_CONS_QUERY_FUNCT 0x08
  148. /**
  149. * Number of heartbeat consumer objects, where each object corresponds to one
  150. * sub-index in OD object 0x1016, "Consumer heartbeat time".
  151. *
  152. * If heartbeat consumer is enabled, then valid values are 1 to 127.
  153. */
  154. #ifdef CO_DOXYGEN
  155. #define CO_CONFIG_HB_CONS_SIZE 8
  156. #endif
  157. /** @} */ /* CO_STACK_CONFIG_NMT_HB */
  158. /**
  159. * @defgroup CO_STACK_CONFIG_EMERGENCY Emergency producer/consumer
  160. * @{
  161. */
  162. /**
  163. * Configuration of @ref CO_Emergency
  164. *
  165. * Possible flags, can be ORed:
  166. * - CO_CONFIG_EM_PRODUCER - Enable emergency producer.
  167. * - CO_CONFIG_EM_PROD_CONFIGURABLE - Emergency producer COB-ID is configurable,
  168. * OD object 0x1014. If not configurable, then 0x1014 is read-only, COB_ID
  169. * is set to CO_CAN_ID_EMERGENCY + nodeId and write is not verified.
  170. * - CO_CONFIG_EM_PROD_INHIBIT - Enable inhibit timer on emergency producer,
  171. * OD object 0x1015.
  172. * - CO_CONFIG_EM_HISTORY - Enable error history, OD object 0x1003,
  173. * "Pre-defined error field"
  174. * - CO_CONFIG_EM_CONSUMER - Enable simple emergency consumer with callback.
  175. * - CO_CONFIG_EM_STATUS_BITS - Access @ref CO_EM_errorStatusBits_t from OD.
  176. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  177. * emergency condition by CO_errorReport() or CO_errorReset() call.
  178. * Callback is configured by CO_EM_initCallbackPre().
  179. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  180. * inside CO_EM_process().
  181. */
  182. #ifdef CO_DOXYGEN
  183. #define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)
  184. #endif
  185. #define CO_CONFIG_EM_PRODUCER 0x01
  186. #define CO_CONFIG_EM_PROD_CONFIGURABLE 0x02
  187. #define CO_CONFIG_EM_PROD_INHIBIT 0x04
  188. #define CO_CONFIG_EM_HISTORY 0x08
  189. #define CO_CONFIG_EM_STATUS_BITS 0x10
  190. #define CO_CONFIG_EM_CONSUMER 0x20
  191. /**
  192. * Maximum number of @ref CO_EM_errorStatusBits_t
  193. *
  194. * Stack uses 6*8 = 48 @ref CO_EM_errorStatusBits_t, others are free to use by
  195. * manufacturer. Allowable value range is from 48 to 256 bits in steps of 8.
  196. * Default is 80.
  197. */
  198. #ifdef CO_DOXYGEN
  199. #define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10*8)
  200. #endif
  201. /**
  202. * Size of the internal buffer, where emergencies are stored after error
  203. * indication with @ref CO_error() function. Each emergency has to be post-
  204. * processed by the @ref CO_EM_process() function. In case of overflow, error is
  205. * indicated but emergency message is not sent.
  206. *
  207. * The same buffer is also used for OD object 0x1003, "Pre-defined error field".
  208. *
  209. * Each buffer element consumes 8 bytes. Valid values are 1 to 254.
  210. */
  211. #ifdef CO_DOXYGEN
  212. #define CO_CONFIG_EM_BUFFER_SIZE 16
  213. #endif
  214. /**
  215. * Condition for calculating CANopen Error register, "generic" error bit.
  216. *
  217. * Condition must observe suitable @ref CO_EM_errorStatusBits_t and use
  218. * corresponding member of errorStatusBits array from CO_EM_t to calculate the
  219. * condition. See also @ref CO_errorRegister_t.
  220. *
  221. * @warning Size of @ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT must be large
  222. * enough. (CO_CONFIG_EM_ERR_STATUS_BITS_COUNT/8) must be larger than index of
  223. * array member in em->errorStatusBits[index].
  224. *
  225. * em->errorStatusBits[5] should be included in the condition, because they are
  226. * used by the stack.
  227. */
  228. #ifdef CO_DOXYGEN
  229. #define CO_CONFIG_ERR_CONDITION_GENERIC (em->errorStatusBits[5] != 0)
  230. #endif
  231. /**
  232. * Condition for calculating CANopen Error register, "current" error bit.
  233. * See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
  234. * Macro is not defined by default, so no error is verified.
  235. */
  236. #ifdef CO_DOXYGEN
  237. #define CO_CONFIG_ERR_CONDITION_CURRENT
  238. #endif
  239. /**
  240. * Condition for calculating CANopen Error register, "voltage" error bit.
  241. * See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
  242. * Macro is not defined by default, so no error is verified.
  243. */
  244. #ifdef CO_DOXYGEN
  245. #define CO_CONFIG_ERR_CONDITION_VOLTAGE
  246. #endif
  247. /**
  248. * Condition for calculating CANopen Error register, "temperature" error bit.
  249. * See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
  250. * Macro is not defined by default, so no error is verified.
  251. */
  252. #ifdef CO_DOXYGEN
  253. #define CO_CONFIG_ERR_CONDITION_TEMPERATURE
  254. #endif
  255. /**
  256. * Condition for calculating CANopen Error register, "communication" error bit.
  257. * See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
  258. *
  259. * em->errorStatusBits[2] and em->errorStatusBits[3] must be included in the
  260. * condition, because they are used by the stack.
  261. */
  262. #ifdef CO_DOXYGEN
  263. #define CO_CONFIG_ERR_CONDITION_COMMUNICATION (em->errorStatusBits[2] || em->errorStatusBits[3])
  264. #endif
  265. /**
  266. * Condition for calculating CANopen Error register, "device profile" error bit.
  267. * See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
  268. * Macro is not defined by default, so no error is verified.
  269. */
  270. #ifdef CO_DOXYGEN
  271. #define CO_CONFIG_ERR_CONDITION_DEV_PROFILE
  272. #endif
  273. /**
  274. * Condition for calculating CANopen Error register, "manufacturer" error bit.
  275. * See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
  276. *
  277. * em->errorStatusBits[8] and em->errorStatusBits[8] are pre-defined, but can
  278. * be changed.
  279. */
  280. #ifdef CO_DOXYGEN
  281. #define CO_CONFIG_ERR_CONDITION_MANUFACTURER (em->errorStatusBits[8] || em->errorStatusBits[9])
  282. #endif
  283. /** @} */ /* CO_STACK_CONFIG_EMERGENCY */
  284. /**
  285. * @defgroup CO_STACK_CONFIG_SDO SDO server/client
  286. * @{
  287. */
  288. /**
  289. * Configuration of @ref CO_SDOserver
  290. *
  291. * Possible flags, can be ORed:
  292. * - CO_CONFIG_SDO_SRV_SEGMENTED - Enable SDO server segmented transfer.
  293. * - CO_CONFIG_SDO_SRV_BLOCK - Enable SDO server block transfer. If set, then
  294. * CO_CONFIG_SDO_SRV_SEGMENTED must also be set.
  295. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  296. * received SDO CAN message.
  297. * Callback is configured by CO_SDOserver_initCallbackPre().
  298. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  299. * inside CO_SDOserver_process().
  300. * - #CO_CONFIG_FLAG_OD_DYNAMIC - Enable dynamic configuration of additional SDO
  301. * servers (Writing to object 0x1201+ re-configures the additional server).
  302. */
  303. #ifdef CO_DOXYGEN
  304. #define CO_CONFIG_SDO_SRV (CO_CONFIG_SDO_SRV_SEGMENTED)
  305. #endif
  306. #define CO_CONFIG_SDO_SRV_SEGMENTED 0x02
  307. #define CO_CONFIG_SDO_SRV_BLOCK 0x04
  308. /**
  309. * Size of the internal data buffer for the SDO server.
  310. *
  311. * If size is less than size of some variables in Object Dictionary, then data
  312. * will be transferred to internal buffer in several segments. Minimum size is
  313. * 8 or 899 (127*7) for block transfer.
  314. */
  315. #ifdef CO_DOXYGEN
  316. #define CO_CONFIG_SDO_SRV_BUFFER_SIZE 32
  317. #endif
  318. /**
  319. * Configuration of @ref CO_SDOclient
  320. *
  321. * Possible flags, can be ORed:
  322. * - CO_CONFIG_SDO_CLI_ENABLE - Enable SDO client.
  323. * - CO_CONFIG_SDO_CLI_SEGMENTED - Enable SDO client segmented transfer.
  324. * - CO_CONFIG_SDO_CLI_BLOCK - Enable SDO client block transfer. If set, then
  325. * CO_CONFIG_SDO_CLI_SEGMENTED, CO_CONFIG_FIFO_ALT_READ and
  326. * CO_CONFIG_FIFO_CRC16_CCITT must also be set.
  327. * - CO_CONFIG_SDO_CLI_LOCAL - Enable local transfer, if Node-ID of the SDO
  328. * server is the same as node-ID of the SDO client. (SDO client is the same
  329. * device as SDO server.) Transfer data directly without communication on CAN.
  330. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  331. * received SDO CAN message.
  332. * Callback is configured by CO_SDOclient_initCallbackPre().
  333. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  334. * inside CO_SDOclientDownloadInitiate(), CO_SDOclientDownload(),
  335. * CO_SDOclientUploadInitiate(), CO_SDOclientUpload().
  336. * - #CO_CONFIG_FLAG_OD_DYNAMIC - Enable dynamic configuration of SDO clients
  337. * (Writing to object 0x1280+ re-configures the client).
  338. */
  339. #ifdef CO_DOXYGEN
  340. #define CO_CONFIG_SDO_CLI (0)
  341. #endif
  342. #define CO_CONFIG_SDO_CLI_ENABLE 0x01
  343. #define CO_CONFIG_SDO_CLI_SEGMENTED 0x02
  344. #define CO_CONFIG_SDO_CLI_BLOCK 0x04
  345. #define CO_CONFIG_SDO_CLI_LOCAL 0x08
  346. /**
  347. * Size of the internal data buffer for the SDO client.
  348. *
  349. * Circular buffer is used for SDO communication. It can be read or written
  350. * between successive SDO calls. So size of the buffer can be lower than size of
  351. * the actual size of data transferred. If only segmented transfer is used, then
  352. * buffer size can be as low as 7 bytes, if data are read/written each cycle. If
  353. * block transfer is used, buffer size should be set to at least 1000 bytes, so
  354. * maximum blksize can be used (blksize is calculated from free buffer space).
  355. * Default value for block transfer is 1000, otherwise 32.
  356. */
  357. #ifdef CO_DOXYGEN
  358. #define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32
  359. #endif
  360. /** @} */ /* CO_STACK_CONFIG_SDO */
  361. /**
  362. * @defgroup CO_STACK_CONFIG_TIME Time producer/consumer
  363. * @{
  364. */
  365. /**
  366. * Configuration of @ref CO_TIME
  367. *
  368. * Possible flags, can be ORed:
  369. * - CO_CONFIG_TIME_ENABLE - Enable TIME object and TIME consumer.
  370. * - CO_CONFIG_TIME_PRODUCER - Enable TIME producer.
  371. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  372. * received TIME CAN message.
  373. * Callback is configured by CO_TIME_initCallbackPre().
  374. */
  375. #ifdef CO_DOXYGEN
  376. #define CO_CONFIG_TIME (0)
  377. #endif
  378. #define CO_CONFIG_TIME_ENABLE 0x01
  379. #define CO_CONFIG_TIME_PRODUCER 0x02
  380. /** @} */ /* CO_STACK_CONFIG_TIME */
  381. /**
  382. * @defgroup CO_STACK_CONFIG_SYNC_PDO SYNC and PDO producer/consumer
  383. * @{
  384. */
  385. /**
  386. * Configuration of @ref CO_SYNC
  387. *
  388. * Possible flags, can be ORed:
  389. * - CO_CONFIG_SYNC_ENABLE - Enable SYNC object and SYNC consumer.
  390. * - CO_CONFIG_SYNC_PRODUCER - Enable SYNC producer.
  391. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  392. * received SYNC CAN message.
  393. * Callback is configured by CO_SYNC_initCallbackPre().
  394. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  395. * inside CO_SYNC_process().
  396. */
  397. #ifdef CO_DOXYGEN
  398. #define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | CO_CONFIG_SYNC_PRODUCER)
  399. #endif
  400. #define CO_CONFIG_SYNC_ENABLE 0x01
  401. #define CO_CONFIG_SYNC_PRODUCER 0x02
  402. /**
  403. * Configuration of @ref CO_PDO
  404. *
  405. * Possible flags, can be ORed:
  406. * - CO_CONFIG_RPDO_ENABLE - Enable receive PDO objects.
  407. * - CO_CONFIG_TPDO_ENABLE - Enable transmit PDO objects.
  408. * - CO_CONFIG_PDO_SYNC_ENABLE - Enable SYNC in PDO objects.
  409. * - CO_CONFIG_RPDO_CALLS_EXTENSION - Enable calling configured extension
  410. * callbacks when received RPDO CAN message modifies OD entries.
  411. * - CO_CONFIG_TPDO_CALLS_EXTENSION - Enable calling configured extension
  412. * callbacks before TPDO CAN message is sent.
  413. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  414. * received RPDO CAN message.
  415. * Callback is configured by CO_RPDO_initCallbackPre().
  416. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  417. * inside CO_TPDO_process().
  418. */
  419. #ifdef CO_DOXYGEN
  420. #define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE | CO_CONFIG_PDO_SYNC_ENABLE)
  421. #endif
  422. #define CO_CONFIG_RPDO_ENABLE 0x01
  423. #define CO_CONFIG_TPDO_ENABLE 0x02
  424. #define CO_CONFIG_PDO_SYNC_ENABLE 0x04
  425. #define CO_CONFIG_RPDO_CALLS_EXTENSION 0x08
  426. #define CO_CONFIG_TPDO_CALLS_EXTENSION 0x10
  427. /** @} */ /* CO_STACK_CONFIG_SYNC_PDO */
  428. /**
  429. * @defgroup CO_STACK_CONFIG_LEDS CANopen LED diodes
  430. * Specified in standard CiA 303-3
  431. * @{
  432. */
  433. /**
  434. * Configuration of @ref CO_LEDs
  435. *
  436. * Possible flags, can be ORed:
  437. * - CO_CONFIG_LEDS_ENABLE - Enable calculation of the CANopen LED indicators.
  438. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  439. * inside CO_NMT_process().
  440. */
  441. #ifdef CO_DOXYGEN
  442. #define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE)
  443. #endif
  444. #define CO_CONFIG_LEDS_ENABLE 0x01
  445. /** @} */ /* CO_STACK_CONFIG_LEDS */
  446. /**
  447. * @defgroup CO_STACK_CONFIG_SRDO Safety Related Data Objects (SRDO)
  448. * Specified in standard EN 50325-5 (CiA 304)
  449. * @{
  450. */
  451. /**
  452. * Configuration of @ref CO_GFC
  453. *
  454. * Possible flags, can be ORed:
  455. * - CO_CONFIG_GFC_ENABLE - Enable the GFC object
  456. * - CO_CONFIG_GFC_CONSUMER - Enable the GFC consumer
  457. * - CO_CONFIG_GFC_PRODUCER - Enable the GFC producer
  458. */
  459. #ifdef CO_DOXYGEN
  460. #define CO_CONFIG_GFC (0)
  461. #endif
  462. #define CO_CONFIG_GFC_ENABLE 0x01
  463. #define CO_CONFIG_GFC_CONSUMER 0x02
  464. #define CO_CONFIG_GFC_PRODUCER 0x04
  465. /**
  466. * Configuration of @ref CO_SRDO
  467. *
  468. * Possible flags, can be ORed:
  469. * - CO_CONFIG_SRDO_ENABLE - Enable the SRDO object.
  470. * - CO_CONFIG_SRDO_CHECK_TX - Enable checking data before sending.
  471. * - CO_CONFIG_RSRDO_CALLS_EXTENSION - Enable calling configured extension
  472. * callbacks when received RSRDO CAN message modifies OD entries.
  473. * - CO_CONFIG_TRSRDO_CALLS_EXTENSION - Enable calling configured extension
  474. * callbacks before TSRDO CAN message is sent.
  475. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  476. * received RSRDO CAN message.
  477. * Callback is configured by CO_SRDO_initCallbackPre().
  478. * - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
  479. * inside CO_SRDO_process() (Tx SRDO only).
  480. */
  481. #ifdef CO_DOXYGEN
  482. #define CO_CONFIG_SRDO (0)
  483. #endif
  484. #define CO_CONFIG_SRDO_ENABLE 0x01
  485. #define CO_CONFIG_SRDO_CHECK_TX 0x02
  486. #define CO_CONFIG_RSRDO_CALLS_EXTENSION 0x04
  487. #define CO_CONFIG_TSRDO_CALLS_EXTENSION 0x08
  488. /**
  489. * SRDO Tx time delay
  490. *
  491. * minimum time between the first and second SRDO (Tx) message
  492. * in us
  493. */
  494. #ifdef CO_DOXYGEN
  495. #define CO_CONFIG_SRDO_MINIMUM_DELAY 0
  496. #endif
  497. /** @} */ /* CO_STACK_CONFIG_SRDO */
  498. /**
  499. * @defgroup CO_STACK_CONFIG_LSS LSS master/slave
  500. * Specified in standard CiA 305
  501. * @{
  502. */
  503. /**
  504. * Configuration of @ref CO_LSS
  505. *
  506. * Possible flags, can be ORed:
  507. * - CO_CONFIG_LSS_SLAVE - Enable LSS slave
  508. * - CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND - Send LSS fastscan respond
  509. * directly from CO_LSSslave_receive() function.
  510. * - CO_CONFIG_LSS_MASTER - Enable LSS master
  511. * - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
  512. * received CAN message.
  513. * Callback is configured by CO_LSSmaster_initCallbackPre().
  514. */
  515. #ifdef CO_DOXYGEN
  516. #define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE)
  517. #endif
  518. #define CO_CONFIG_LSS_SLAVE 0x01
  519. #define CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND 0x02
  520. #define CO_CONFIG_LSS_MASTER 0x10
  521. /** @} */ /* CO_STACK_CONFIG_LSS */
  522. /**
  523. * @defgroup CO_STACK_CONFIG_GATEWAY CANopen gateway
  524. * Specified in standard CiA 309
  525. * @{
  526. */
  527. /**
  528. * Configuration of @ref CO_CANopen_309_3
  529. *
  530. * Gateway object is covered by standard CiA 309 - CANopen access from other
  531. * networks. It enables usage of the NMT master, SDO client and LSS master as a
  532. * gateway device.
  533. *
  534. * Possible flags, can be ORed:
  535. * - CO_CONFIG_GTW_MULTI_NET - Enable multiple network interfaces in gateway
  536. * device. This functionality is currently not implemented.
  537. * - CO_CONFIG_GTW_ASCII - Enable gateway device with ASCII mapping (CiA 309-3)
  538. * If set, then CO_CONFIG_FIFO_ASCII_COMMANDS must also be set.
  539. * - CO_CONFIG_GTW_ASCII_SDO - Enable SDO client. If set, then
  540. * CO_CONFIG_FIFO_ASCII_DATATYPES must also be set.
  541. * - CO_CONFIG_GTW_ASCII_NMT - Enable NMT master
  542. * - CO_CONFIG_GTW_ASCII_LSS - Enable LSS master
  543. * - CO_CONFIG_GTW_ASCII_LOG - Enable non-standard message log read
  544. * - CO_CONFIG_GTW_ASCII_ERROR_DESC - Print error description as additional
  545. * comments in gateway-ascii device for SDO and gateway errors.
  546. * - CO_CONFIG_GTW_ASCII_PRINT_HELP - use non-standard command "help" to print
  547. * help usage.
  548. * - CO_CONFIG_GTW_ASCII_PRINT_LEDS - Display "red" and "green" CANopen status
  549. * LED diodes on terminal.
  550. */
  551. #ifdef CO_DOXYGEN
  552. #define CO_CONFIG_GTW (0)
  553. #endif
  554. #define CO_CONFIG_GTW_MULTI_NET 0x01
  555. #define CO_CONFIG_GTW_ASCII 0x02
  556. #define CO_CONFIG_GTW_ASCII_SDO 0x04
  557. #define CO_CONFIG_GTW_ASCII_NMT 0x08
  558. #define CO_CONFIG_GTW_ASCII_LSS 0x10
  559. #define CO_CONFIG_GTW_ASCII_LOG 0x20
  560. #define CO_CONFIG_GTW_ASCII_ERROR_DESC 0x40
  561. #define CO_CONFIG_GTW_ASCII_PRINT_HELP 0x80
  562. #define CO_CONFIG_GTW_ASCII_PRINT_LEDS 0x100
  563. /**
  564. * Number of loops of #CO_SDOclientDownload() in case of block download
  565. *
  566. * If SDO clint has block download in progress and OS has buffer for CAN tx
  567. * messages, then #CO_SDOclientDownload() functionion can be called multiple
  568. * times within own loop (up to 127). This can speed-up SDO block transfer.
  569. */
  570. #ifdef CO_DOXYGEN
  571. #define CO_CONFIG_GTW_BLOCK_DL_LOOP 1
  572. #endif
  573. /**
  574. * Size of command buffer in ASCII gateway object.
  575. *
  576. * If large amount of data is transferred (block transfer), then this should be
  577. * increased to 1000 or more. Buffer may be refilled between the block transfer.
  578. */
  579. #ifdef CO_DOXYGEN
  580. #define CO_CONFIG_GTWA_COMM_BUF_SIZE 200
  581. #endif
  582. /**
  583. * Size of message log buffer in ASCII gateway object.
  584. */
  585. #ifdef CO_DOXYGEN
  586. #define CO_CONFIG_GTWA_LOG_BUF_SIZE 2000
  587. #endif
  588. /** @} */ /* CO_STACK_CONFIG_GATEWAY */
  589. /**
  590. * @defgroup CO_STACK_CONFIG_CRC16 CRC 16 calculation
  591. * Helper object
  592. * @{
  593. */
  594. /**
  595. * Configuration of @ref CO_crc16_ccitt calculation
  596. *
  597. * Possible flags, can be ORed:
  598. * - CO_CONFIG_CRC16_ENABLE - Enable CRC16 calculation
  599. * - CO_CONFIG_CRC16_EXTERNAL - CRC functions are defined externally
  600. */
  601. #ifdef CO_DOXYGEN
  602. #define CO_CONFIG_CRC16 (0)
  603. #endif
  604. #define CO_CONFIG_CRC16_ENABLE 0x01
  605. #define CO_CONFIG_CRC16_EXTERNAL 0x02
  606. /** @} */ /* CO_STACK_CONFIG_CRC16 */
  607. /**
  608. * @defgroup CO_STACK_CONFIG_FIFO FIFO buffer
  609. * Helper object
  610. * @{
  611. */
  612. /**
  613. * Configuration of @ref CO_CANopen_301_fifo
  614. *
  615. * FIFO buffer is basically a simple first-in first-out circular data buffer. It
  616. * is used by the SDO client and by the CANopen gateway. It has additional
  617. * advanced functions for data passed to FIFO.
  618. *
  619. *
  620. * Possible flags, can be ORed:
  621. * - CO_CONFIG_FIFO_ENABLE - Enable FIFO buffer
  622. * - CO_CONFIG_FIFO_ALT_READ - This must be enabled, when SDO client has
  623. * CO_CONFIG_SDO_CLI_BLOCK enabled. See @ref CO_fifo_altRead().
  624. * - CO_CONFIG_FIFO_CRC16_CCITT - This must be enabled, when SDO client has
  625. * CO_CONFIG_SDO_CLI_BLOCK enabled. It enables CRC calculation on data.
  626. * - CO_CONFIG_FIFO_ASCII_COMMANDS - This must be enabled, when CANopen gateway
  627. * has CO_CONFIG_GTW_ASCII enabled. It adds command handling functions.
  628. * - CO_CONFIG_FIFO_ASCII_DATATYPES - This must be enabled, when CANopen gateway
  629. * has CO_CONFIG_GTW_ASCII and CO_CONFIG_GTW_ASCII_SDO enabled. It adds
  630. * datatype transform functions between binary and ascii, which are necessary
  631. * for SDO client.
  632. */
  633. #ifdef CO_DOXYGEN
  634. #define CO_CONFIG_FIFO (0)
  635. #endif
  636. #define CO_CONFIG_FIFO_ENABLE 0x01
  637. #define CO_CONFIG_FIFO_ALT_READ 0x02
  638. #define CO_CONFIG_FIFO_CRC16_CCITT 0x04
  639. #define CO_CONFIG_FIFO_ASCII_COMMANDS 0x08
  640. #define CO_CONFIG_FIFO_ASCII_DATATYPES 0x10
  641. /** @} */ /* CO_STACK_CONFIG_FIFO */
  642. /**
  643. * @defgroup CO_STACK_CONFIG_TRACE Trace recorder
  644. * Non standard object
  645. * @{
  646. */
  647. /**
  648. * Configuration of @ref CO_trace for recording variables over time.
  649. *
  650. * Possible flags, can be ORed:
  651. * - CO_CONFIG_TRACE_ENABLE - Enable Trace recorder
  652. * - CO_CONFIG_TRACE_OWN_INTTYPES - If set, then macros PRIu32("u" or "lu")
  653. * and PRId32("d" or "ld") must be set. (File inttypes.h can not be included).
  654. */
  655. #ifdef CO_DOXYGEN
  656. #define CO_CONFIG_TRACE (0)
  657. #endif
  658. #define CO_CONFIG_TRACE_ENABLE 0x01
  659. #define CO_CONFIG_TRACE_OWN_INTTYPES 0x02
  660. /** @} */ /* CO_STACK_CONFIG_TRACE */
  661. /**
  662. * @defgroup CO_STACK_CONFIG_DEBUG Debug messages
  663. * Messages from different parts of the stack.
  664. * @{
  665. */
  666. /**
  667. * Configuration of debug messages from different parts of the stack, which can
  668. * be logged according to target specific function.
  669. *
  670. * Possible flags, can be ORed:
  671. * - CO_CONFIG_DEBUG_COMMON - Define default CO_DEBUG_COMMON(msg) macro. This
  672. * macro is target specific. This macro is then used as default macro in all
  673. * other defined CO_DEBUG_XXX(msg) macros.
  674. * - CO_CONFIG_DEBUG_SDO_CLIENT - Define default CO_DEBUG_SDO_CLIENT(msg) macro.
  675. * - CO_CONFIG_DEBUG_SDO_SERVER - Define default CO_DEBUG_SDO_SERVER(msg) macro.
  676. */
  677. #ifdef CO_DOXYGEN
  678. #define CO_CONFIG_DEBUG (0)
  679. #endif
  680. #define CO_CONFIG_DEBUG_COMMON 0x01
  681. #define CO_CONFIG_DEBUG_SDO_CLIENT 0x02
  682. #define CO_CONFIG_DEBUG_SDO_SERVER 0x04
  683. /** @} */ /* CO_STACK_CONFIG_DEBUG */
  684. /** @} */ /* CO_STACK_CONFIG */
  685. #ifdef __cplusplus
  686. }
  687. #endif /* __cplusplus */
  688. #endif /* CO_CONFIG_FLAGS_H */