Better organised configuration macros (CO_config.h):
- rearranged and better documented - default values moved from CO_driver.h into appropriate files - rearranged also in CO_driver_target.h files - parts of the stack or whole objects can be disabled. - configuration is verified for depencies Additional: - renamed some members of CO_Default_CAN_ID_t - moved helpers CO_setUint32() etc from CO_SDOserver.h into CO_driver.h. - change wrong CO_ERROR_PARAMETERS to CO_ERROR_ILLEGAL_ARGUMENT. - renamed CO_ERROR_PARAMETERS to CO_ERROR_OD_PARAMETERS
This commit is contained in:
parent
7b66b10dff
commit
a528eb1669
40 changed files with 1007 additions and 592 deletions
|
|
@ -23,13 +23,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_Emergency.h"
|
||||
|
||||
/* verify configuration */
|
||||
#if CO_CONFIG_EM_ERR_STATUS_BITS_COUNT < (6*8) \
|
||||
|| CO_CONFIG_EM_ERR_STATUS_BITS_COUNT > 256
|
||||
#error CO_CONFIG_EM_ERR_STATUS_BITS_COUNT is not correct
|
||||
#endif
|
||||
|
||||
#if (CO_CONFIG_EM) & CO_CONFIG_EM_CONSUMER
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -23,10 +23,30 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_EMERGENCY_H
|
||||
#define CO_EMERGENCY_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_EM
|
||||
#define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER)
|
||||
#endif
|
||||
#ifndef CO_CONFIG_EM_ERR_STATUS_BITS_COUNT
|
||||
#define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10*8)
|
||||
#endif
|
||||
#ifndef CO_CONFIG_ERR_CONDITION_GENERIC
|
||||
#define CO_CONFIG_ERR_CONDITION_GENERIC (em->errorStatusBits[5] != 0)
|
||||
#endif
|
||||
#ifndef CO_CONFIG_ERR_CONDITION_COMMUNICATION
|
||||
#define CO_CONFIG_ERR_CONDITION_COMMUNICATION (em->errorStatusBits[2] \
|
||||
|| em->errorStatusBits[3])
|
||||
#endif
|
||||
#ifndef CO_CONFIG_ERR_CONDITION_MANUFACTURER
|
||||
#define CO_CONFIG_ERR_CONDITION_MANUFACTURER (em->errorStatusBits[8] \
|
||||
|| em->errorStatusBits[9])
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -462,9 +482,10 @@ void CO_EM_process(
|
|||
|
||||
#endif
|
||||
|
||||
/** @} */ /* CO_Emergency */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* CO_EMERGENCY_H */
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#include "301/CO_NMT_Heartbeat.h"
|
||||
#include "301/CO_HBconsumer.h"
|
||||
|
||||
#if (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE
|
||||
|
||||
/*
|
||||
* Read received message from CAN module.
|
||||
*
|
||||
|
|
@ -513,3 +515,5 @@ int8_t CO_HBconsumer_getNmtState(
|
|||
return -1;
|
||||
}
|
||||
#endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_QUERY_FUNCT */
|
||||
|
||||
#endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE */
|
||||
|
|
|
|||
|
|
@ -23,10 +23,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_HB_CONS_H
|
||||
#define CO_HB_CONS_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_HB_CONS
|
||||
#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -338,11 +346,15 @@ int8_t CO_HBconsumer_getNmtState(
|
|||
CO_HBconsumer_t *HBcons,
|
||||
uint8_t idx,
|
||||
CO_NMT_internalState_t *nmtState);
|
||||
|
||||
#endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_QUERY_FUNCT */
|
||||
|
||||
/** @} */ /* CO_HBconsumer */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE */
|
||||
|
||||
#endif /* CO_HB_CONS_H */
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_NMT_HEARTBEAT_H
|
||||
#define CO_NMT_HEARTBEAT_H
|
||||
|
||||
|
|
@ -31,6 +30,11 @@
|
|||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_Emergency.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_NMT
|
||||
#define CO_CONFIG_NMT (0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -270,12 +274,13 @@ static inline CO_NMT_internalState_t CO_NMT_getInternalState(CO_NMT_t *NMT) {
|
|||
CO_ReturnError_t CO_NMT_sendCommand(CO_NMT_t *NMT,
|
||||
CO_NMT_command_t command,
|
||||
uint8_t nodeID);
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* (CO_CONFIG_NMT) & CO_CONFIG_NMT_MASTER */
|
||||
|
||||
/** @} */ /* CO_NMT_Heartbeat */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif
|
||||
#endif /* CO_NMT_HEARTBEAT_H */
|
||||
|
|
|
|||
19
301/CO_PDO.h
19
301/CO_PDO.h
|
|
@ -23,18 +23,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CO_PDO_H
|
||||
#define CO_PDO_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_Emergency.h"
|
||||
#include "301/CO_NMT_Heartbeat.h"
|
||||
#if (CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE
|
||||
#include "301/CO_SYNC.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_PDO
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | \
|
||||
CO_CONFIG_TPDO_ENABLE | \
|
||||
CO_CONFIG_PDO_SYNC_ENABLE)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef CO_PDO_H
|
||||
#define CO_PDO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -426,9 +430,10 @@ void CO_TPDO_process(
|
|||
uint32_t timeDifference_us,
|
||||
uint32_t *timerNext_us);
|
||||
|
||||
/** @} */ /* CO_PDO */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* CO_PDO_H */
|
||||
|
|
|
|||
|
|
@ -24,19 +24,28 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "301/CO_SDOclient.h"
|
||||
|
||||
#if (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE
|
||||
|
||||
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK) && \
|
||||
!((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_SEGMENTED)
|
||||
#error If CO_CONFIG_SDO_CLI_BLOCK is enabled, then CO_CONFIG_SDO_CLI_SEGMENTED \
|
||||
must be enabled also!
|
||||
#endif
|
||||
/* verify configuration */
|
||||
#if CO_CONFIG_SDO_CLI_BUFFER_SIZE < 7
|
||||
#error CO_CONFIG_SDO_CLI_BUFFER_SIZE must be set to 7 or more!
|
||||
#error CO_CONFIG_SDO_CLI_BUFFER_SIZE must be set to 7 or more.
|
||||
#endif
|
||||
#if !((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ENABLE)
|
||||
#error CO_CONFIG_FIFO_ENABLE must be enabled.
|
||||
#endif
|
||||
#if (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK
|
||||
#if !((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_SEGMENTED)
|
||||
#error CO_CONFIG_SDO_CLI_SEGMENTED must be enabled.
|
||||
#endif
|
||||
#if !((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ)
|
||||
#error CO_CONFIG_FIFO_ALT_READ must be enabled.
|
||||
#endif
|
||||
#if !((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_CRC16_CCITT)
|
||||
#error CO_CONFIG_FIFO_CRC16_CCITT must be enabled.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* default 'protocol switch threshold' size for block transfer */
|
||||
#ifndef CO_CONFIG_SDO_CLI_PST
|
||||
|
|
@ -1481,3 +1490,5 @@ void CO_SDOclientClose(CO_SDOclient_t *SDO_C) {
|
|||
SDO_C->state = CO_SDO_ST_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE */
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_SDO_CLIENT_H
|
||||
#define CO_SDO_CLIENT_H
|
||||
|
||||
|
|
@ -32,6 +31,16 @@
|
|||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_fifo.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_SDO_CLI
|
||||
#define CO_CONFIG_SDO_CLI (0)
|
||||
#endif
|
||||
#ifndef CO_CONFIG_SDO_CLI_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -426,9 +435,12 @@ size_t CO_SDOclientUploadBufRead(CO_SDOclient_t *SDO_C,
|
|||
*/
|
||||
void CO_SDOclientClose(CO_SDOclient_t *SDO_C);
|
||||
|
||||
/** @} */ /* CO_SDOclient */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE */
|
||||
|
||||
#endif /* CO_SDO_CLIENT_H */
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@
|
|||
#if CO_CONFIG_SDO_BUFFER_SIZE < 7
|
||||
#error CO_CONFIG_SDO_BUFFER_SIZE must be greater than 7
|
||||
#endif
|
||||
#if ((CO_CONFIG_SDO) & CO_CONFIG_SDO_BLOCK) && !((CO_CONFIG_SDO) & CO_CONFIG_SDO_SEGMENTED)
|
||||
#error CO_CONFIG_SDO_BLOCK is enabled, CO_CONFIG_SDO_SEGMENTED must be enabled also.
|
||||
#endif
|
||||
|
||||
static void CO_SDO_receive_done(CO_SDO_t *SDO){
|
||||
#if CO_SDO_RX_DATA_SIZE > 1
|
||||
|
|
|
|||
|
|
@ -29,6 +29,20 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_SDO_SRV
|
||||
#define CO_CONFIG_SDO_SRV (CO_CONFIG_SDO_SRV_SEGMENTED)
|
||||
#endif
|
||||
#ifndef CO_CONFIG_SDO_SRV_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_SRV_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
#define CO_CONFIG_SDO CO_CONFIG_SDO_SRV
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE CO_CONFIG_SDO_SRV_BUFFER_SIZE
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -849,54 +863,6 @@ typedef struct{
|
|||
}CO_SDO_t;
|
||||
|
||||
|
||||
/**
|
||||
* Helper function returns uint16 from byte array.
|
||||
*
|
||||
* @param data Location of source data.
|
||||
* @return Variable of type uint16_t.
|
||||
*/
|
||||
static inline uint16_t CO_getUint16(const uint8_t data[]){
|
||||
uint16_t value;
|
||||
memcpy(&value, data, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function returns uint32 from byte array.
|
||||
*
|
||||
* @param data Location of source data.
|
||||
* @return Variable of type uint32_t.
|
||||
*/
|
||||
static inline uint32_t CO_getUint32(const uint8_t data[]){
|
||||
uint32_t value;
|
||||
memcpy(&value, data, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function writes uint16 to byte array.
|
||||
*
|
||||
* @param data Location of destination data.
|
||||
* @param value Variable of type uint16_t to be written into data.
|
||||
*/
|
||||
static inline void CO_setUint16(uint8_t data[], const uint16_t value){
|
||||
memcpy(data, &value, sizeof(value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function writes uint32 to byte array.
|
||||
*
|
||||
* @param data Location of destination data.
|
||||
* @param value Variable of type uint32_t to be written into data.
|
||||
*/
|
||||
static inline void CO_setUint32(uint8_t data[], const uint32_t value){
|
||||
memcpy(data, &value, sizeof(value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy 2 data bytes from source to destination. Swap bytes if
|
||||
* microcontroller is big-endian.
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_Emergency.h"
|
||||
#include "301/CO_NMT_Heartbeat.h"
|
||||
#include "301/CO_SYNC.h"
|
||||
|
||||
#if (CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE
|
||||
|
||||
/*
|
||||
* Read received message from CAN module.
|
||||
*
|
||||
|
|
@ -434,3 +435,5 @@ CO_SYNC_status_t CO_SYNC_process(
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* (CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE */
|
||||
|
|
|
|||
|
|
@ -23,10 +23,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_SYNC_H
|
||||
#define CO_SYNC_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | CO_CONFIG_SYNC_PRODUCER)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -189,9 +197,12 @@ CO_SYNC_status_t CO_SYNC_process(
|
|||
uint32_t ObjDict_synchronousWindowLength,
|
||||
uint32_t *timerNext_us);
|
||||
|
||||
/** @} */ /* CO_SYNC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE */
|
||||
|
||||
#endif /* CO_SYNC_H */
|
||||
|
|
|
|||
|
|
@ -23,12 +23,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_TIME_H
|
||||
#define CO_TIME_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "CO_OD.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_TIME
|
||||
#define CO_CONFIG_TIME (0)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_TIME) & CO_CONFIG_TIME_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -176,10 +182,12 @@ uint8_t CO_TIME_process(
|
|||
CO_TIME_t *TIME,
|
||||
uint32_t timeDifference_us);
|
||||
|
||||
/** @} */
|
||||
/** @} */ /* CO_TIME */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_TIME) & CO_CONFIG_TIME_ENABLE */
|
||||
|
||||
#endif /* CO_TIME_H */
|
||||
|
|
|
|||
555
301/CO_config.h
555
301/CO_config.h
|
|
@ -37,23 +37,28 @@ extern "C" {
|
|||
*
|
||||
* Stack configuration macros specify, which parts of the stack will be enabled.
|
||||
*
|
||||
* Default values for stack configuration macros are set in CO_driver.h file.
|
||||
* They can be overridden by CO_driver_target.h file. If specified so, they can
|
||||
* further be overridden by CO_driver_custom.h file.
|
||||
* Default values for stack configuration macros are set in corresponding
|
||||
* header files. The same default values are also provided in this file, but
|
||||
* only for documentation generator. Default values can be overridden by
|
||||
* CO_driver_target.h file. If specified so, they can further be overridden by
|
||||
* CO_driver_custom.h file.
|
||||
*
|
||||
* Stack configuration macro is specified as bits, where each bit
|
||||
* enables/disables some part of the configurable CANopenNode object. Flags are
|
||||
* used for enabling or checking specific bit. Multiple flags can be ORed
|
||||
* together.
|
||||
*
|
||||
* Configuration macros may be in relation with @ref CO_NO_OBJ macros from
|
||||
* CANopen.h file. Former enables/disables stack functionalities, latter
|
||||
* enables/disables objects in object dictionary. Note that some objects in
|
||||
* object dictionary may need some configuration macros to be enabled.
|
||||
* Some functionalities of CANopenNode objects, enabled by configuration macros,
|
||||
* requires some objects from Object Dictionary to exist. Object Dictionary
|
||||
* configuration must match @ref CO_STACK_CONFIG.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_COMMON Common definitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Enable custom callback after CAN receive
|
||||
*
|
||||
|
|
@ -72,7 +77,6 @@ extern "C" {
|
|||
*/
|
||||
#define CO_CONFIG_FLAG_CALLBACK_PRE 0x1000
|
||||
|
||||
|
||||
/**
|
||||
* Enable calculation of timerNext_us variable.
|
||||
*
|
||||
|
|
@ -83,83 +87,46 @@ extern "C" {
|
|||
*/
|
||||
#define CO_CONFIG_FLAG_TIMERNEXT 0x2000
|
||||
|
||||
/**
|
||||
* Enable dynamic behaviour of Object Dictionary variables
|
||||
*
|
||||
* Some CANopen objects uses Object Dictionary variables as arguments to
|
||||
* initialization functions, which are processed in communication reset section.
|
||||
* If this flag is set, then writing to OD variable will reconfigure
|
||||
* corresponding CANopen object also during CANopen normal operation.
|
||||
*
|
||||
* This flag is common to multiple configuration macros.
|
||||
*/
|
||||
#define CO_CONFIG_FLAG_OD_DYNAMIC 0x4000
|
||||
/** @} */ /* CO_STACK_CONFIG_COMMON */
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of NMT_Heartbeat object
|
||||
* @defgroup CO_STACK_CONFIG_NMT_HB NMT master/slave and HB producer/consumer
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_NMT_Heartbeat.
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_NMT_CALLBACK_CHANGE - Enable custom callback after NMT
|
||||
* state changes. Callback is configured by
|
||||
* CO_NMT_initCallbackChanged().
|
||||
* - CO_CONFIG_NMT_MASTER - Enable simple NMT master
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received NMT CAN message.
|
||||
* Callback is configured by CO_NMT_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_NMT_process().
|
||||
* - CO_CONFIG_NMT_CALLBACK_CHANGE - Enable custom callback after NMT
|
||||
* state changes. Callback is configured by
|
||||
* CO_NMT_initCallbackChanged().
|
||||
* - CO_CONFIG_NMT_MASTER - Enable simple NMT master
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_NMT (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_NMT_CALLBACK_CHANGE | CO_CONFIG_NMT_MASTER0)
|
||||
#define CO_CONFIG_NMT (0)
|
||||
#endif
|
||||
#define CO_CONFIG_NMT_CALLBACK_CHANGE 0x01
|
||||
#define CO_CONFIG_NMT_MASTER 0x02
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of SDO server object
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received SDO CAN message.
|
||||
* Callback is configured by CO_SDO_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_SDO_process().
|
||||
* - CO_CONFIG_SDO_SEGMENTED - Enable SDO server segmented transfer.
|
||||
* - CO_CONFIG_SDO_BLOCK - Enable SDO server block transfer. If set, then
|
||||
* CO_CONFIG_SDO_SEGMENTED must also be set.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SDO (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_SDO_SEGMENTED | CO_CONFIG_SDO_BLOCK)
|
||||
#endif
|
||||
/* TODO with new OD */
|
||||
#define CO_CONFIG_SDO_SEGMENTED 0x01
|
||||
#define CO_CONFIG_SDO_BLOCK 0x02
|
||||
|
||||
|
||||
/**
|
||||
* Size of the internal data buffer for the SDO server.
|
||||
*
|
||||
* Size must be at least equal to size of largest variable in
|
||||
* @ref CO_SDO_objectDictionary. If data type is domain, data length is not
|
||||
* limited to SDO buffer size. If block transfer is implemented, value should be
|
||||
* set to 889.
|
||||
*
|
||||
* Value can be in range from 7 to 889 bytes.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of Emergency object
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* emergency condition by CO_errorReport() or CO_errorReset() call.
|
||||
* Callback is configured by CO_EM_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_EM_process().
|
||||
* - CO_CONFIG_EM_CONSUMER - Enable emergency consumer.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_EM (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_EM_CONSUMER)
|
||||
#endif
|
||||
#define CO_CONFIG_EM_CONSUMER 0x01
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of Heartbeat Consumer
|
||||
* Configuration of @ref CO_HBconsumer
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
|
|
@ -167,6 +134,7 @@ extern "C" {
|
|||
* Callback is configured by CO_HBconsumer_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_HBconsumer_process().
|
||||
* - CO_CONFIG_HB_CONS_ENABLE - Enable heartbeat consumer.
|
||||
* - CO_CONFIG_HB_CONS_CALLBACK_CHANGE - Enable custom callback after NMT
|
||||
* state of the monitored node changes. Callback is configured by
|
||||
* CO_HBconsumer_initCallbackNmtChanged().
|
||||
|
|
@ -179,118 +147,194 @@ extern "C" {
|
|||
* NMT state of the specific monitored node.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_HB_CONS (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_HB_CONS_CALLBACK_CHANGE | CO_CONFIG_HB_CONS_CALLBACK_MULTI | CO_CONFIG_HB_CONS_QUERY_FUNCT)
|
||||
#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE)
|
||||
#endif
|
||||
#define CO_CONFIG_HB_CONS_CALLBACK_CHANGE 0x01
|
||||
#define CO_CONFIG_HB_CONS_CALLBACK_MULTI 0x02
|
||||
#define CO_CONFIG_HB_CONS_QUERY_FUNCT 0x04
|
||||
#define CO_CONFIG_HB_CONS_ENABLE 0x01
|
||||
#define CO_CONFIG_HB_CONS_CALLBACK_CHANGE 0x02
|
||||
#define CO_CONFIG_HB_CONS_CALLBACK_MULTI 0x04
|
||||
#define CO_CONFIG_HB_CONS_QUERY_FUNCT 0x08
|
||||
/** @} */ /* CO_STACK_CONFIG_NMT_HB */
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of GFC
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_GFC_CONSUMER - Enable the GFC consumer
|
||||
* - CO_CONFIG_GFC_PRODUCER - Enable the GFC producer
|
||||
* @defgroup CO_STACK_CONFIG_EMERGENCY Emergency producer/consumer
|
||||
* @{
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_GFC (CO_CONFIG_GFC_CONSUMER | CO_CONFIG_GFC_PRODUCER)
|
||||
#endif
|
||||
#define CO_CONFIG_GFC_CONSUMER 0x01
|
||||
#define CO_CONFIG_GFC_PRODUCER 0x02
|
||||
|
||||
/**
|
||||
* Configuration of SRDO
|
||||
* Configuration of @ref CO_Emergency
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_EM_PRODUCER - Enable emergency producer.
|
||||
* - CO_CONFIG_EM_HISTORY - Enable error history - OD object 0x1003,
|
||||
* "Pre-defined error field"
|
||||
* - CO_CONFIG_EM_CONSUMER - Enable emergency consumer.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received RSRDO CAN message.
|
||||
* Callback is configured by CO_SRDO_initCallbackPre().
|
||||
* emergency condition by CO_errorReport() or CO_errorReset() call.
|
||||
* Callback is configured by CO_EM_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_SRDO_process() (Tx SRDO only).
|
||||
* - CO_CONFIG_RSRDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks when received RSRDO CAN message modifies OD entries.
|
||||
* - CO_CONFIG_TRSRDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks before TSRDO CAN message is sent.
|
||||
* inside CO_EM_process().
|
||||
* - #CO_CONFIG_FLAG_OD_DYNAMIC - Enable dynamic configuration of Emergency
|
||||
* (Writing to object 0x1014 or 0x1015 re-configures the object).
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SRDO (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_SRDO_CHECK_TX | CO_CONFIG_RSRDO_CALLS_EXTENSION | CO_CONFIG_TSRDO_CALLS_EXTENSION)
|
||||
#define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER)
|
||||
#endif
|
||||
#define CO_CONFIG_SRDO_CHECK_TX 0x01
|
||||
#define CO_CONFIG_RSRDO_CALLS_EXTENSION 0x02
|
||||
#define CO_CONFIG_TSRDO_CALLS_EXTENSION 0x04
|
||||
#define CO_CONFIG_EM_PRODUCER 0x01
|
||||
#define CO_CONFIG_EM_HISTORY 0x02
|
||||
#define CO_CONFIG_EM_CONSUMER 0x04
|
||||
|
||||
/**
|
||||
* SRDO Tx time delay
|
||||
*
|
||||
* minimum time between the first and second SRDO (Tx) message
|
||||
* in us
|
||||
* Maximum number of @ref CO_EM_errorStatusBits
|
||||
*
|
||||
* Stack uses 6*8 = 48 @ref CO_EM_errorStatusBits others are free to use by
|
||||
* manufacturer. Allowable value range is from 48 to 256 bits. Default is 80.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SRDO_MINIMUM_DELAY 0
|
||||
#define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10*8)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Configuration of PDO
|
||||
* Condition for calculating CANopen Error register, "generic" error bit.
|
||||
*
|
||||
* Condition must observe suitable @ref CO_EM_errorStatusBits and use
|
||||
* corresponding member of errorStatusBits array from CO_EM_t to calculate the
|
||||
* condition. See also @ref CO_errorRegister_t.
|
||||
*
|
||||
* @warning Size of @ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT must be large
|
||||
* enough. (CO_CONFIG_EM_ERR_STATUS_BITS_COUNT/8) must be larger than index of
|
||||
* array member in em->errorStatusBits[index].
|
||||
*
|
||||
* em->errorStatusBits[5] should be included in the condition, because they are
|
||||
* used by the stack.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_ERR_CONDITION_GENERIC (em->errorStatusBits[5] != 0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Condition for calculating CANopen Error register, "communication" error bit.
|
||||
* See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
|
||||
*
|
||||
* em->errorStatusBits[2] and em->errorStatusBits[3] must be included in the
|
||||
* condition, because they are used by the stack.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_ERR_CONDITION_COMMUNICATION (em->errorStatusBits[2] || em->errorStatusBits[3])
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Condition for calculating CANopen Error register, "current" error bit.
|
||||
* See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
|
||||
* Macro is not defined by default, so no error is verified.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_ERR_CONDITION_CURRENT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Condition for calculating CANopen Error register, "voltage" error bit.
|
||||
* See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
|
||||
* Macro is not defined by default, so no error is verified.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_ERR_CONDITION_VOLTAGE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Condition for calculating CANopen Error register, "temperature" error bit.
|
||||
* See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
|
||||
* Macro is not defined by default, so no error is verified.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_ERR_CONDITION_TEMPERATURE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Condition for calculating CANopen Error register, "device profile" error bit.
|
||||
* See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
|
||||
* Macro is not defined by default, so no error is verified.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_ERR_CONDITION_DEV_PROFILE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Condition for calculating CANopen Error register, "manufacturer" error bit.
|
||||
* See @ref CO_CONFIG_ERR_CONDITION_GENERIC for description.
|
||||
*
|
||||
* em->errorStatusBits[8] and em->errorStatusBits[8] are pre-defined, but can
|
||||
* be changed.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_ERR_CONDITION_MANUFACTURER (em->errorStatusBits[8] || em->errorStatusBits[9])
|
||||
#endif
|
||||
/** @} */ /* CO_STACK_CONFIG_EMERGENCY */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_SDO SDO server/client
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_SDOserver
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_SDO_SRV_SEGMENTED - Enable SDO server segmented transfer.
|
||||
* - CO_CONFIG_SDO_SRV_BLOCK - Enable SDO server block transfer. If set, then
|
||||
* CO_CONFIG_SDO_SRV_SEGMENTED must also be set.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received RPDO CAN message.
|
||||
* Callback is configured by CO_RPDO_initCallbackPre().
|
||||
* received SDO CAN message.
|
||||
* Callback is configured by CO_SDOserver_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_TPDO_process().
|
||||
* - CO_CONFIG_PDO_SYNC_ENABLE - Enable SYNC object inside PDO objects.
|
||||
* - CO_CONFIG_RPDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks when received RPDO CAN message modifies OD entries.
|
||||
* - CO_CONFIG_TPDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks before TPDO CAN message is sent.
|
||||
* inside CO_SDOserver_process().
|
||||
* - #CO_CONFIG_FLAG_OD_DYNAMIC - Enable dynamic configuration of additional SDO
|
||||
* servers (Writing to object 0x1201+ re-configures the additional server).
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_PDO_SYNC_ENABLE | CO_CONFIG_RPDO_CALLS_EXTENSION | CO_CONFIG_TPDO_CALLS_EXTENSION)
|
||||
#define CO_CONFIG_SDO_SRV (CO_CONFIG_SDO_SRV_SEGMENTED)
|
||||
#endif
|
||||
#define CO_CONFIG_PDO_SYNC_ENABLE 0x01
|
||||
#define CO_CONFIG_RPDO_CALLS_EXTENSION 0x02
|
||||
#define CO_CONFIG_TPDO_CALLS_EXTENSION 0x04
|
||||
|
||||
#define CO_CONFIG_SDO_SRV_SEGMENTED 0x02
|
||||
#define CO_CONFIG_SDO_SRV_BLOCK 0x04
|
||||
|
||||
/**
|
||||
* Configuration of SYNC
|
||||
* Size of the internal data buffer for the SDO server.
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received SYNC CAN message.
|
||||
* Callback is configured by CO_SYNC_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_SYNC_process().
|
||||
* If size is less than size of some variables in Object Dictionary, then data
|
||||
* will be transferred to internal buffer in several segments. Minimum size is
|
||||
* 8 or 899 (127*7) for block transfer.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#define CO_CONFIG_SDO_SRV_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of SDO client object
|
||||
* Configuration of @ref CO_SDOclient
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_SDO_CLI_ENABLE - Enable SDO client.
|
||||
* - CO_CONFIG_SDO_CLI_SEGMENTED - Enable SDO client segmented transfer.
|
||||
* - CO_CONFIG_SDO_CLI_BLOCK - Enable SDO client block transfer. If set, then
|
||||
* CO_CONFIG_SDO_CLI_SEGMENTED, CO_CONFIG_FIFO_ALT_READ and
|
||||
* CO_CONFIG_FIFO_CRC16_CCITT must also be set.
|
||||
* - CO_CONFIG_SDO_CLI_LOCAL - Enable local transfer, if Node-ID of the SDO
|
||||
* server is the same as node-ID of the SDO client. (SDO client is the same
|
||||
* device as SDO server.) Transfer data directly without communication on CAN.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received SDO CAN message.
|
||||
* Callback is configured by CO_SDOclient_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_SDOclientDownloadInitiate(), CO_SDOclientDownload(),
|
||||
* CO_SDOclientUploadInitiate(), CO_SDOclientUpload().
|
||||
* - CO_CONFIG_SDO_CLI_SEGMENTED - Enable SDO client segmented transfer.
|
||||
* - CO_CONFIG_SDO_CLI_BLOCK - Enable SDO client block transfer. If set, then
|
||||
* CO_CONFIG_SDO_CLI_SEGMENTED must also be set.
|
||||
* - CO_CONFIG_SDO_CLI_LOCAL - Enable local transfer, if Node-ID of the SDO
|
||||
* server is the same as node-ID of the SDO client. (SDO client is the same
|
||||
* device as SDO server.) Transfer data directly without communication on CAN.
|
||||
* - #CO_CONFIG_FLAG_OD_DYNAMIC - Enable dynamic configuration of SDO clients
|
||||
* (Writing to object 0x1280+ re-configures the client).
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SDO_CLI (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_SDO_CLI_SEGMENTED | CO_CONFIG_SDO_CLI_BLOCK | CO_CONFIG_SDO_CLI_LOCAL)
|
||||
#define CO_CONFIG_SDO_CLI (0)
|
||||
#endif
|
||||
#define CO_CONFIG_SDO_CLI_SEGMENTED 0x01
|
||||
#define CO_CONFIG_SDO_CLI_BLOCK 0x02
|
||||
#define CO_CONFIG_SDO_CLI_LOCAL 0x04
|
||||
|
||||
#define CO_CONFIG_SDO_CLI_ENABLE 0x01
|
||||
#define CO_CONFIG_SDO_CLI_SEGMENTED 0x02
|
||||
#define CO_CONFIG_SDO_CLI_BLOCK 0x04
|
||||
#define CO_CONFIG_SDO_CLI_LOCAL 0x08
|
||||
|
||||
/**
|
||||
* Size of the internal data buffer for the SDO client.
|
||||
|
|
@ -306,57 +350,187 @@ extern "C" {
|
|||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32
|
||||
#endif
|
||||
/** @} */ /* CO_STACK_CONFIG_SDO */
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of TIME
|
||||
* @defgroup CO_STACK_CONFIG_SYNC_PDO SYNC and PDO producer/consumer
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_SYNC
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_SYNC_ENABLE - Enable SYNC object and SYNC consumer.
|
||||
* - CO_CONFIG_SYNC_PRODUCER - Enable SYNC producer.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received SYNC CAN message.
|
||||
* Callback is configured by CO_SYNC_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_SYNC_process().
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | CO_CONFIG_SYNC_PRODUCER)
|
||||
#endif
|
||||
#define CO_CONFIG_SYNC_ENABLE 0x01
|
||||
#define CO_CONFIG_SYNC_PRODUCER 0x02
|
||||
|
||||
/**
|
||||
* Configuration of @ref CO_PDO
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_RPDO_ENABLE - Enable receive PDO objects.
|
||||
* - CO_CONFIG_TPDO_ENABLE - Enable transmit PDO objects.
|
||||
* - CO_CONFIG_RPDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks when received RPDO CAN message modifies OD entries.
|
||||
* - CO_CONFIG_TPDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks before TPDO CAN message is sent.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received RPDO CAN message.
|
||||
* Callback is configured by CO_RPDO_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_TPDO_process().
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE | CO_CONFIG_PDO_SYNC_ENABLE)
|
||||
#endif
|
||||
#define CO_CONFIG_PDO_SYNC_ENABLE 0x01
|
||||
#define CO_CONFIG_RPDO_CALLS_EXTENSION 0x02
|
||||
#define CO_CONFIG_TPDO_CALLS_EXTENSION 0x04
|
||||
/** @} */ /* CO_STACK_CONFIG_SYNC_PDO */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_TIME Time producer/consumer
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_TIME
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_TIME_ENABLE - Enable TIME object and TIME consumer.
|
||||
* - CO_CONFIG_TIME_PRODUCER - Enable TIME producer.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received TIME CAN message.
|
||||
* Callback is configured by CO_TIME_initCallbackPre().
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#define CO_CONFIG_TIME (0)
|
||||
#endif
|
||||
#define CO_CONFIG_TIME_ENABLE 0x01
|
||||
#define CO_CONFIG_TIME_PRODUCER 0x02
|
||||
/** @} */ /* CO_STACK_CONFIG_TIME */
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of LEDs object
|
||||
* @defgroup CO_STACK_CONFIG_LEDS CANopen LED diodes
|
||||
* Specified in standard CiA 303-3
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_LEDs
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_LEDS_ENABLE - Enable calculation of the CANopen LED indicators.
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_NMT_process().
|
||||
* - CO_CONFIG_LEDS_ENABLE - Enable calculation of the CANopen LED indicators.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_FLAG_TIMERNEXT | CO_CONFIG_LEDS_ENABLE)
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE)
|
||||
#endif
|
||||
#define CO_CONFIG_LEDS_ENABLE 0x01
|
||||
/** @} */ /* CO_STACK_CONFIG_LEDS */
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of LSS objects
|
||||
* @defgroup CO_STACK_CONFIG_SRDO Safety Related Data Objects (SRDO)
|
||||
* Specified in standard EN 50325-5 (CiA 304)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_GFC
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_GFC_ENABLE - Enable the GFC object
|
||||
* - CO_CONFIG_GFC_CONSUMER - Enable the GFC consumer
|
||||
* - CO_CONFIG_GFC_PRODUCER - Enable the GFC producer
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_GFC (0)
|
||||
#endif
|
||||
#define CO_CONFIG_GFC_ENABLE 0x01
|
||||
#define CO_CONFIG_GFC_CONSUMER 0x02
|
||||
#define CO_CONFIG_GFC_PRODUCER 0x04
|
||||
|
||||
/**
|
||||
* Configuration of @ref CO_SRDO
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_SRDO_ENABLE - Enable the SRDO object.
|
||||
* - CO_CONFIG_SRDO_CHECK_TX - Enable checking data before sending.
|
||||
* - CO_CONFIG_RSRDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks when received RSRDO CAN message modifies OD entries.
|
||||
* - CO_CONFIG_TRSRDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks before TSRDO CAN message is sent.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received CAN message.
|
||||
* Callback is configured by CO_LSSmaster_initCallbackPre().
|
||||
* received RSRDO CAN message.
|
||||
* Callback is configured by CO_SRDO_initCallbackPre().
|
||||
* - #CO_CONFIG_FLAG_TIMERNEXT - Enable calculation of timerNext_us variable
|
||||
* inside CO_SRDO_process() (Tx SRDO only).
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SRDO (0)
|
||||
#endif
|
||||
#define CO_CONFIG_SRDO_ENABLE 0x01
|
||||
#define CO_CONFIG_SRDO_CHECK_TX 0x02
|
||||
#define CO_CONFIG_RSRDO_CALLS_EXTENSION 0x04
|
||||
#define CO_CONFIG_TSRDO_CALLS_EXTENSION 0x08
|
||||
|
||||
/**
|
||||
* SRDO Tx time delay
|
||||
*
|
||||
* minimum time between the first and second SRDO (Tx) message
|
||||
* in us
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_SRDO_MINIMUM_DELAY 0
|
||||
#endif
|
||||
/** @} */ /* CO_STACK_CONFIG_SRDO */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_LSS LSS master/slave
|
||||
* Specified in standard CiA 305
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_LSS
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_LSS_SLAVE - Enable LSS slave
|
||||
* - CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND - Send LSS fastscan respond
|
||||
* directly from CO_LSSslave_receive() function.
|
||||
* - CO_CONFIG_LSS_MASTER - Enable LSS master
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received CAN message.
|
||||
* Callback is configured by CO_LSSmaster_initCallbackPre().
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_LSS_SLAVE | CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND | CO_CONFIG_LSS_MASTER )
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE)
|
||||
#endif
|
||||
#define CO_CONFIG_LSS_SLAVE 0x01
|
||||
#define CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND 0x02
|
||||
#define CO_CONFIG_LSS_MASTER 0x10
|
||||
/** @} */ /* CO_STACK_CONFIG_LSS */
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of gateway object usage.
|
||||
* @defgroup CO_STACK_CONFIG_GATEWAY CANopen gateway
|
||||
* Specified in standard CiA 309
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_CANopen_309_3
|
||||
*
|
||||
* Gateway object is covered by standard CiA 309 - CANopen access from other
|
||||
* networks. It enables usage of the NMT master, SDO client and LSS master as a
|
||||
|
|
@ -366,7 +540,9 @@ extern "C" {
|
|||
* - CO_CONFIG_GTW_MULTI_NET - Enable multiple network interfaces in gateway
|
||||
* device. This functionality is currently not implemented.
|
||||
* - CO_CONFIG_GTW_ASCII - Enable gateway device with ASCII mapping (CiA 309-3)
|
||||
* - CO_CONFIG_GTW_ASCII_SDO - Enable SDO client
|
||||
* If set, then CO_CONFIG_FIFO_ASCII_COMMANDS must also be set.
|
||||
* - CO_CONFIG_GTW_ASCII_SDO - Enable SDO client. If set, then
|
||||
* CO_CONFIG_FIFO_ASCII_DATATYPES must also be set.
|
||||
* - CO_CONFIG_GTW_ASCII_NMT - Enable NMT master
|
||||
* - CO_CONFIG_GTW_ASCII_LSS - Enable LSS master
|
||||
* - CO_CONFIG_GTW_ASCII_LOG - Enable non-standard message log read
|
||||
|
|
@ -378,7 +554,7 @@ extern "C" {
|
|||
* LED diodes on terminal.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_GTW (CO_CONFIG_GTW_MULTI_NET | CO_CONFIG_GTW_ASCII | CO_CONFIG_GTW_ASCII_SDO | CO_CONFIG_GTW_ASCII_NMT | CO_CONFIG_GTW_ASCII_LSS | CO_CONFIG_GTW_ASCII_LOG | CO_CONFIG_GTW_ASCII_ERROR_DESC | CO_CONFIG_GTW_ASCII_PRINT_HELP | CO_CONFIG_GTW_ASCII_PRINT_LEDS)
|
||||
#define CO_CONFIG_GTW (0)
|
||||
#endif
|
||||
#define CO_CONFIG_GTW_MULTI_NET 0x01
|
||||
#define CO_CONFIG_GTW_ASCII 0x02
|
||||
|
|
@ -390,7 +566,6 @@ extern "C" {
|
|||
#define CO_CONFIG_GTW_ASCII_PRINT_HELP 0x80
|
||||
#define CO_CONFIG_GTW_ASCII_PRINT_LEDS 0x100
|
||||
|
||||
|
||||
/**
|
||||
* Number of loops of #CO_SDOclientDownload() in case of block download
|
||||
*
|
||||
|
|
@ -402,7 +577,6 @@ extern "C" {
|
|||
#define CO_CONFIG_GTW_BLOCK_DL_LOOP 1
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Size of command buffer in ASCII gateway object.
|
||||
*
|
||||
|
|
@ -413,16 +587,93 @@ extern "C" {
|
|||
#define CO_CONFIG_GTWA_COMM_BUF_SIZE 200
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Size of message log buffer in ASCII gateway object.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_GTWA_LOG_BUF_SIZE 2000
|
||||
#endif
|
||||
/** @} */ /* CO_STACK_CONFIG_GATEWAY */
|
||||
|
||||
|
||||
/** @} */
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_CRC16 CRC 16 calculation
|
||||
* Helper object
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_crc16_ccitt calculation
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_CRC16_ENABLE - Enable CRC16 calculation
|
||||
* - CO_CONFIG_CRC16_EXTERNAL - CRC functions are defined externally
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_CRC16 (0)
|
||||
#endif
|
||||
#define CO_CONFIG_CRC16_ENABLE 0x01
|
||||
#define CO_CONFIG_CRC16_EXTERNAL 0x02
|
||||
/** @} */ /* CO_STACK_CONFIG_CRC16 */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_FIFO FIFO buffer
|
||||
* Helper object
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_CANopen_301_fifo
|
||||
*
|
||||
* FIFO buffer is basically a simple first-in first-out circular data buffer. It
|
||||
* is used by the SDO client and by the CANopen gateway. It has additional
|
||||
* advanced functions for data passed to FIFO.
|
||||
*
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_FIFO_ENABLE - Enable FIFO buffer
|
||||
* - CO_CONFIG_FIFO_ALT_READ - This must be enabled, when SDO client has
|
||||
* CO_CONFIG_SDO_CLI_BLOCK enabled. See @ref CO_fifo_altRead().
|
||||
* - CO_CONFIG_FIFO_CRC16_CCITT - This must be enabled, when SDO client has
|
||||
* CO_CONFIG_SDO_CLI_BLOCK enabled. It enables CRC calculation on data.
|
||||
* - CO_CONFIG_FIFO_ASCII_COMMANDS - This must be enabled, when CANopen gateway
|
||||
* has CO_CONFIG_GTW_ASCII enabled. It adds command handling functions.
|
||||
* - CO_CONFIG_FIFO_ASCII_DATATYPES - This must be enabled, when CANopen gateway
|
||||
* has CO_CONFIG_GTW_ASCII and CO_CONFIG_GTW_ASCII_SDO enabled. It adds
|
||||
* datatype transform functions between binary and ascii, which are necessary
|
||||
* for SDO client.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_FIFO (0)
|
||||
#endif
|
||||
#define CO_CONFIG_FIFO_ENABLE 0x01
|
||||
#define CO_CONFIG_FIFO_ALT_READ 0x02
|
||||
#define CO_CONFIG_FIFO_CRC16_CCITT 0x04
|
||||
#define CO_CONFIG_FIFO_ASCII_COMMANDS 0x08
|
||||
#define CO_CONFIG_FIFO_ASCII_DATATYPES 0x10
|
||||
/** @} */ /* CO_STACK_CONFIG_FIFO */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_TRACE Trace recorder
|
||||
* Non standard object
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_trace for recording variables over time.
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_TRACE_ENABLE - Enable Trace recorder
|
||||
* - CO_CONFIG_TRACE_OWN_INTTYPES - If set, then macros PRIu32("u" or "lu")
|
||||
* and PRId32("d" or "ld") must be set. (File inttypes.h can not be included).
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_TRACE (0)
|
||||
#endif
|
||||
#define CO_CONFIG_TRACE_ENABLE 0x01
|
||||
#define CO_CONFIG_TRACE_OWN_INTTYPES 0x02
|
||||
/** @} */ /* CO_STACK_CONFIG_TRACE */
|
||||
|
||||
/** @} */ /* CO_STACK_CONFIG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
118
301/CO_driver.h
118
301/CO_driver.h
|
|
@ -23,10 +23,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_DRIVER_H
|
||||
#define CO_DRIVER_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "CO_config.h"
|
||||
#include "CO_driver_target.h"
|
||||
|
||||
|
|
@ -34,67 +35,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Default stack configuration for most common configuration, may be overridden
|
||||
* by CO_driver_target.h. For more information see file CO_config.h. */
|
||||
#ifndef CO_CONFIG_NMT
|
||||
#define CO_CONFIG_NMT (0)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO
|
||||
#define CO_CONFIG_SDO (CO_CONFIG_SDO_SEGMENTED)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_EM
|
||||
#define CO_CONFIG_EM (0)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_HB_CONS
|
||||
#define CO_CONFIG_HB_CONS (0)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_GFC
|
||||
#define CO_CONFIG_GFC (0)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SRDO
|
||||
#define CO_CONFIG_SRDO (0)
|
||||
#define CO_CONFIG_SRDO_MINIMUM_DELAY 0
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_PDO
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_PDO_SYNC_ENABLE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (0)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_CLI
|
||||
#define CO_CONFIG_SDO_CLI (CO_CONFIG_SDO_CLI_SEGMENTED | \
|
||||
CO_CONFIG_SDO_CLI_LOCAL)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_CLI_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LSS
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LEDS
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_GTW
|
||||
#define CO_CONFIG_GTW (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup CO_driver Driver
|
||||
* @ingroup CO_CANopen_301
|
||||
|
|
@ -476,11 +416,11 @@ typedef enum {
|
|||
CO_CAN_ID_RPDO_3 = 0x400, /**< 0x400, Default RPDO3 (+nodeID) */
|
||||
CO_CAN_ID_TPDO_4 = 0x480, /**< 0x480, Default TPDO4 (+nodeID) */
|
||||
CO_CAN_ID_RPDO_4 = 0x500, /**< 0x500, Default RPDO5 (+nodeID) */
|
||||
CO_CAN_ID_TSDO = 0x580, /**< 0x580, SDO response from server (+nodeID) */
|
||||
CO_CAN_ID_RSDO = 0x600, /**< 0x600, SDO request from client (+nodeID) */
|
||||
CO_CAN_ID_HEARTBEAT = 0x700, /**< 0x700, Heartbeat message */
|
||||
CO_CAN_ID_LSS_CLI = 0x7E4, /**< 0x7E4, LSS response from server to client */
|
||||
CO_CAN_ID_LSS_SRV = 0x7E5 /**< 0x7E5, LSS request from client to server */
|
||||
CO_CAN_ID_SDO_SRV = 0x580, /**< 0x580, SDO response from server (+nodeID) */
|
||||
CO_CAN_ID_SDO_CLI = 0x600, /**< 0x600, SDO request from client (+nodeID) */
|
||||
CO_CAN_ID_HEARTBEAT = 0x700, /**< 0x700, Heartbeat message */
|
||||
CO_CAN_ID_LSS_SLV = 0x7E4, /**< 0x7E4, LSS response from slave */
|
||||
CO_CAN_ID_LSS_MST = 0x7E5 /**< 0x7E5, LSS request from master */
|
||||
} CO_Default_CAN_ID_t;
|
||||
|
||||
|
||||
|
|
@ -529,7 +469,7 @@ typedef enum {
|
|||
CO_ERROR_TX_PDO_WINDOW = -10, /**< Synchronous TPDO is outside window */
|
||||
CO_ERROR_TX_UNCONFIGURED = -11, /**< Transmit buffer was not confugured
|
||||
properly */
|
||||
CO_ERROR_PARAMETERS = -12, /**< Error in function function parameters*/
|
||||
CO_ERROR_OD_PARAMETERS = -12, /**< Error in Object Dictionary parameters*/
|
||||
CO_ERROR_DATA_CORRUPT = -13, /**< Stored data are corrupt */
|
||||
CO_ERROR_CRC = -14, /**< CRC does not match */
|
||||
CO_ERROR_TX_BUSY = -15, /**< Sending rejected because driver is
|
||||
|
|
@ -697,7 +637,47 @@ void CO_CANclearPendingSyncPDOs(CO_CANmodule_t *CANmodule);
|
|||
*/
|
||||
void CO_CANmodule_process(CO_CANmodule_t *CANmodule);
|
||||
|
||||
/** @} */ /* @defgroup CO_driver Driver */
|
||||
|
||||
/**
|
||||
* Get uint8_t value from memory buffer
|
||||
*
|
||||
* @param buf Memory buffer to get value from.
|
||||
*
|
||||
* @return Value
|
||||
*/
|
||||
static inline uint8_t CO_getUint8(const void *buf) {
|
||||
uint8_t value; memmove(&value, buf, sizeof(value)); return value;
|
||||
}
|
||||
/** Get uint16_t value from memory buffer, see @ref CO_getUint8 */
|
||||
static inline uint16_t CO_getUint16(const void *buf) {
|
||||
uint16_t value; memmove(&value, buf, sizeof(value)); return value;
|
||||
}
|
||||
/** Get uint32_t value from memory buffer, see @ref CO_getUint8 */
|
||||
static inline uint32_t CO_getUint32(const void *buf) {
|
||||
uint32_t value; memmove(&value, buf, sizeof(value)); return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write uint8_t value into memory buffer
|
||||
*
|
||||
* @param buf Memory buffer.
|
||||
* @param value Value to be written into buf.
|
||||
*
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
static inline uint8_t CO_setUint8(void *buf, uint8_t value) {
|
||||
memmove(buf, &value, sizeof(value)); return sizeof(value);
|
||||
}
|
||||
/** Write uint16_t value into memory buffer, see @ref CO_setUint8 */
|
||||
static inline uint8_t CO_setUint16(void *buf, uint16_t value) {
|
||||
memmove(buf, &value, sizeof(value)); return sizeof(value);
|
||||
}
|
||||
/** Write uint32_t value into memory buffer, see @ref CO_setUint8 */
|
||||
static inline uint8_t CO_setUint32(void *buf, uint32_t value) {
|
||||
memmove(buf, &value, sizeof(value)); return sizeof(value);
|
||||
}
|
||||
|
||||
/** @} */ /* CO_driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,17 +23,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "301/CO_fifo.h"
|
||||
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ENABLE
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#if CO_CONFIG_FIFO_CRC16_CCITT == 1
|
||||
#include "crc16-ccitt.h"
|
||||
#endif
|
||||
|
||||
#if CO_CONFIG_FIFO_ASCII_COMMANDS == 1
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
|
@ -41,8 +40,14 @@
|
|||
#define DELIM_COMMAND '\n'
|
||||
/* Graphical character for comment delimiter */
|
||||
#define DELIM_COMMENT '#'
|
||||
#endif /* CO_CONFIG_FIFO_ASCII_COMMANDS == 1 */
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS */
|
||||
|
||||
/* verify configuration */
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_CRC16_CCITT
|
||||
#if !((CO_CONFIG_CRC16) & CO_CONFIG_CRC16_ENABLE)
|
||||
#error CO_CONFIG_CRC16_ENABLE must be enabled.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
void CO_fifo_init(CO_fifo_t *fifo, char *buf, size_t bufSize) {
|
||||
|
|
@ -97,7 +102,7 @@ size_t CO_fifo_write(CO_fifo_t *fifo,
|
|||
|
||||
*bufDest = *buf;
|
||||
|
||||
#if CO_CONFIG_FIFO_CRC16_CCITT > 0
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_CRC16_CCITT
|
||||
if (crc != NULL) {
|
||||
crc16_ccitt_single(crc, (unsigned char)*buf);
|
||||
}
|
||||
|
|
@ -152,7 +157,7 @@ size_t CO_fifo_read(CO_fifo_t *fifo, char *buf, size_t count, bool_t *eof) {
|
|||
}
|
||||
i--;
|
||||
|
||||
#if CO_CONFIG_FIFO_ASCII_COMMANDS == 1
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS
|
||||
/* is delimiter? */
|
||||
if (eof != NULL && c == DELIM_COMMAND) {
|
||||
*eof = true;
|
||||
|
|
@ -165,7 +170,7 @@ size_t CO_fifo_read(CO_fifo_t *fifo, char *buf, size_t count, bool_t *eof) {
|
|||
}
|
||||
|
||||
|
||||
#if CO_CONFIG_FIFO_ALT_READ == 1
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ
|
||||
/******************************************************************************/
|
||||
size_t CO_fifo_altBegin(CO_fifo_t *fifo, size_t offset) {
|
||||
size_t i;
|
||||
|
|
@ -202,7 +207,7 @@ void CO_fifo_altFinish(CO_fifo_t *fifo, uint16_t *crc) {
|
|||
else {
|
||||
const char *bufSrc = &fifo->buf[fifo->readPtr];
|
||||
while (fifo->readPtr != fifo->altReadPtr) {
|
||||
#if CO_CONFIG_FIFO_CRC16_CCITT > 0
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_CRC16_CCITT
|
||||
crc16_ccitt_single(crc, (unsigned char)*bufSrc);
|
||||
#endif
|
||||
/* increment variable */
|
||||
|
|
@ -244,10 +249,10 @@ size_t CO_fifo_altRead(CO_fifo_t *fifo, char *buf, size_t count) {
|
|||
|
||||
return count - i;
|
||||
}
|
||||
#endif /* CO_CONFIG_FIFO_ALT_READ == 1 */
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ */
|
||||
|
||||
|
||||
#if CO_CONFIG_FIFO_ASCII_COMMANDS == 1
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS
|
||||
/******************************************************************************/
|
||||
bool_t CO_fifo_CommSearch(CO_fifo_t *fifo, bool_t clear) {
|
||||
bool_t newCommand = false;
|
||||
|
|
@ -461,10 +466,10 @@ size_t CO_fifo_readToken(CO_fifo_t *fifo,
|
|||
|
||||
return tokenSize;
|
||||
}
|
||||
#endif /* #if CO_CONFIG_FIFO_ASCII_COMMANDS == 1 */
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS */
|
||||
|
||||
|
||||
#if CO_CONFIG_FIFO_ASCII_DATATYPES == 1
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES
|
||||
/******************************************************************************/
|
||||
size_t CO_fifo_readU82a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end) {
|
||||
uint8_t n;
|
||||
|
|
@ -1139,4 +1144,6 @@ size_t CO_fifo_cpyTok2Vs(CO_fifo_t *dest, CO_fifo_t *src, CO_fifo_st *status) {
|
|||
return destSpaceStart - destSpace;
|
||||
}
|
||||
|
||||
#endif /* CO_CONFIG_FIFO_ASCII_DATATYPES == 1 */
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES */
|
||||
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ENABLE */
|
||||
|
|
|
|||
|
|
@ -23,34 +23,17 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_FIFO_H
|
||||
#define CO_FIFO_H
|
||||
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_FIFO
|
||||
#define CO_CONFIG_FIFO (0)
|
||||
#endif
|
||||
|
||||
#if (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK
|
||||
#ifndef CO_CONFIG_FIFO_ALT_READ
|
||||
#define CO_CONFIG_FIFO_ALT_READ 1
|
||||
#endif
|
||||
#ifndef CO_CONFIG_FIFO_CRC16_CCITT
|
||||
#define CO_CONFIG_FIFO_CRC16_CCITT 1
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK */
|
||||
|
||||
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
|
||||
#ifndef CO_CONFIG_FIFO_ASCII_COMMANDS
|
||||
#define CO_CONFIG_FIFO_ASCII_COMMANDS 1
|
||||
#endif
|
||||
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO
|
||||
#ifndef CO_CONFIG_FIFO_ASCII_DATATYPES
|
||||
#define CO_CONFIG_FIFO_ASCII_DATATYPES 1
|
||||
#endif
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII */
|
||||
|
||||
#if ((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -83,11 +66,11 @@ typedef struct {
|
|||
size_t writePtr;
|
||||
/** Location in the buffer, which will be next read. */
|
||||
size_t readPtr;
|
||||
#if CO_CONFIG_FIFO_ALT_READ > 0 || defined CO_DOXYGEN
|
||||
#if ((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ) || defined CO_DOXYGEN
|
||||
/** Location in the buffer, which will be next read. */
|
||||
size_t altReadPtr;
|
||||
#endif
|
||||
#if CO_CONFIG_FIFO_ASCII_DATATYPES > 0 || defined CO_DOXYGEN
|
||||
#if ((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES) || defined CO_DOXYGEN
|
||||
/** helper variable, set to false in CO_fifo_reset(), used in some
|
||||
* functions. */
|
||||
bool_t started;
|
||||
|
|
@ -118,7 +101,7 @@ static inline void CO_fifo_reset(CO_fifo_t *fifo) {
|
|||
if (fifo != NULL) {
|
||||
fifo->readPtr = 0;
|
||||
fifo->writePtr = 0;
|
||||
#if CO_CONFIG_FIFO_ASCII_DATATYPES > 0
|
||||
#if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES
|
||||
fifo->started = false;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -264,7 +247,7 @@ size_t CO_fifo_write(CO_fifo_t *fifo,
|
|||
size_t CO_fifo_read(CO_fifo_t *fifo, char *buf, size_t count, bool_t *eof);
|
||||
|
||||
|
||||
#if CO_CONFIG_FIFO_ALT_READ > 0 || defined CO_DOXYGEN
|
||||
#if ((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ) || defined CO_DOXYGEN
|
||||
/**
|
||||
* Initializes alternate read with #CO_fifo_altRead
|
||||
*
|
||||
|
|
@ -320,10 +303,10 @@ static inline size_t CO_fifo_altGetOccupied(CO_fifo_t *fifo) {
|
|||
* @return number of bytes actually read.
|
||||
*/
|
||||
size_t CO_fifo_altRead(CO_fifo_t *fifo, char *buf, size_t count);
|
||||
#endif /* CO_CONFIG_FIFO_ALT_READ > 0 */
|
||||
#endif /* #if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ */
|
||||
|
||||
|
||||
#if CO_CONFIG_FIFO_ASCII_COMMANDS > 0 || defined CO_DOXYGEN
|
||||
#if ((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS) || defined CO_DOXYGEN
|
||||
/**
|
||||
* Search command inside FIFO
|
||||
*
|
||||
|
|
@ -407,10 +390,10 @@ size_t CO_fifo_readToken(CO_fifo_t *fifo,
|
|||
size_t count,
|
||||
char *closed,
|
||||
bool_t *err);
|
||||
#endif /* CO_CONFIG_FIFO_ASCII_COMMANDS > 0 */
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS */
|
||||
|
||||
|
||||
#if CO_CONFIG_FIFO_ASCII_DATATYPES > 0 || defined CO_DOXYGEN
|
||||
#if ((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES) || defined CO_DOXYGEN
|
||||
/**
|
||||
* Read uint8_t variable from fifo and output as ascii string.
|
||||
*
|
||||
|
|
@ -513,11 +496,14 @@ size_t CO_fifo_cpyTok2Hex(CO_fifo_t *dest, CO_fifo_t *src, CO_fifo_st *status);
|
|||
* the quotes are escaped by a second quotes. See CO_fifo_cpyTok2U8 */
|
||||
size_t CO_fifo_cpyTok2Vs(CO_fifo_t *dest, CO_fifo_t *src, CO_fifo_st *status);
|
||||
|
||||
#endif /* CO_CONFIG_FIFO_ASCII_DATATYPES > 0 */
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES */
|
||||
|
||||
/** @} */ /* CO_CANopen_301_fifo */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ENABLE */
|
||||
|
||||
#endif /* CO_FIFO_H */
|
||||
|
|
|
|||
|
|
@ -23,19 +23,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CO_USE_OWN_CRC16
|
||||
|
||||
#include "301/crc16-ccitt.h"
|
||||
|
||||
#if (CO_CONFIG_CRC16) & CO_CONFIG_CRC16_ENABLE
|
||||
#if !((CO_CONFIG_CRC16) & CO_CONFIG_CRC16_EXTERNAL)
|
||||
|
||||
/*
|
||||
* CRC table calculated by the following algorithm:
|
||||
*
|
||||
* void crc16_ccitt_table_init(void){
|
||||
* unsigned short i, j;
|
||||
* uint16_t i, j;
|
||||
* for(i=0; i<256; i++){
|
||||
* unsigned short crc = 0;
|
||||
* unsigned short c = i << 8;
|
||||
* uint16_t crc = 0;
|
||||
* uint16_t c = i << 8;
|
||||
* for(j=0; j<8; j++){
|
||||
* if((crc ^ c) & 0x8000) crc = (crc << 1) ^ 0x1021;
|
||||
* else crc = crc << 1;
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
* }
|
||||
* }
|
||||
*/
|
||||
static const unsigned short crc16_ccitt_table[256] = {
|
||||
static const uint16_t crc16_ccitt_table[256] = {
|
||||
0x0000U, 0x1021U, 0x2042U, 0x3063U, 0x4084U, 0x50A5U, 0x60C6U, 0x70E7U,
|
||||
0x8108U, 0x9129U, 0xA14AU, 0xB16BU, 0xC18CU, 0xD1ADU, 0xE1CEU, 0xF1EFU,
|
||||
0x1231U, 0x0210U, 0x3273U, 0x2252U, 0x52B5U, 0x4294U, 0x72F7U, 0x62D6U,
|
||||
|
|
@ -82,25 +82,25 @@ static const unsigned short crc16_ccitt_table[256] = {
|
|||
|
||||
|
||||
/******************************************************************************/
|
||||
void crc16_ccitt_single(unsigned short *crc, const unsigned char chr) {
|
||||
unsigned char tmp = (unsigned char)(*crc >> 8U) ^ chr;
|
||||
void crc16_ccitt_single(uint16_t *crc, const uint8_t chr) {
|
||||
uint8_t tmp = (uint8_t)(*crc >> 8U) ^ chr;
|
||||
*crc = (*crc << 8U) ^ crc16_ccitt_table[tmp];
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
unsigned short crc16_ccitt(
|
||||
const unsigned char block[],
|
||||
unsigned int blockLength,
|
||||
unsigned short crc)
|
||||
uint16_t crc16_ccitt(const uint8_t block[],
|
||||
size_t blockLength,
|
||||
uint16_t crc)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
for(i=0U; i<blockLength; i++){
|
||||
unsigned char tmp = (unsigned char)(crc >> 8U) ^ block[i];
|
||||
for (i = 0U; i < blockLength; i++) {
|
||||
uint8_t tmp = (uint8_t)(crc >> 8U) ^ block[i];
|
||||
crc = (crc << 8U) ^ crc16_ccitt_table[tmp];
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
#endif /* CO_USE_OWN_CRC16 */
|
||||
#endif /* !((CO_CONFIG_CRC16) & CO_CONFIG_CRC16_EXTERNAL) */
|
||||
#endif /* (CO_CONFIG_CRC16) & CO_CONFIG_CRC16_ENABLE */
|
||||
|
|
|
|||
|
|
@ -24,10 +24,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRC16_CCITT_H
|
||||
#define CRC16_CCITT_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_CRC16
|
||||
#define CO_CONFIG_CRC16 (0)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_CRC16) & CO_CONFIG_CRC16_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -55,10 +63,7 @@ extern "C" {
|
|||
* start of new CRC calculation, variable must be initialized (zero for xmodem).
|
||||
* @param chr One byte of data
|
||||
*/
|
||||
#ifdef CO_USE_OWN_CRC16
|
||||
extern
|
||||
#endif
|
||||
void crc16_ccitt_single(unsigned short *crc, const unsigned char chr);
|
||||
void crc16_ccitt_single(uint16_t *crc, const uint8_t chr);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -71,19 +76,17 @@ void crc16_ccitt_single(unsigned short *crc, const unsigned char chr);
|
|||
*
|
||||
* @return Calculated CRC.
|
||||
*/
|
||||
#ifdef CO_USE_OWN_CRC16
|
||||
extern
|
||||
#endif
|
||||
unsigned short crc16_ccitt(
|
||||
const unsigned char block[],
|
||||
unsigned int blockLength,
|
||||
unsigned short crc);
|
||||
uint16_t crc16_ccitt(const uint8_t block[],
|
||||
size_t blockLength,
|
||||
uint16_t crc);
|
||||
|
||||
|
||||
/** @} */
|
||||
/** @} */ /* CO_crc16_ccitt */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_CRC16) & CO_CONFIG_CRC16_ENABLE */
|
||||
|
||||
#endif /* CRC16_CCITT_H */
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "303/CO_LEDs.h"
|
||||
|
||||
#if (CO_CONFIG_LEDS) & CO_CONFIG_LEDS_ENABLE
|
||||
|
||||
/******************************************************************************/
|
||||
CO_ReturnError_t CO_LEDs_init(CO_LEDs_t *LEDs) {
|
||||
|
|
@ -150,3 +151,5 @@ void CO_LEDs_process(CO_LEDs_t *LEDs,
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* (CO_CONFIG_LEDS) & CO_CONFIG_LEDS_ENABLE */
|
||||
|
|
|
|||
|
|
@ -23,19 +23,25 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_LEDS_H
|
||||
#define CO_LEDS_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_NMT_Heartbeat.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_LEDS
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_LEDS) & CO_CONFIG_LEDS_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup CO_LEDs LED indicator specification
|
||||
* @defgroup CO_LEDs LED indicators
|
||||
* @ingroup CO_CANopen_303
|
||||
* @{
|
||||
*
|
||||
|
|
@ -140,10 +146,12 @@ void CO_LEDs_process(CO_LEDs_t *LEDs,
|
|||
bool_t firmwareDownload,
|
||||
uint32_t *timerNext_us);
|
||||
|
||||
/** @} */
|
||||
/** @} */ /* CO_LEDs */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_LEDS) & CO_CONFIG_LEDS_ENABLE */
|
||||
|
||||
#endif /* CO_LEDS_H */
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "304/CO_GFC.h"
|
||||
|
||||
#if (CO_CONFIG_GFC) & CO_CONFIG_GFC_ENABLE
|
||||
|
||||
#if (CO_CONFIG_GFC) & CO_CONFIG_GFC_CONSUMER
|
||||
|
||||
static void CO_GFC_receive(void *object, void *msg)
|
||||
|
|
@ -125,3 +127,5 @@ CO_ReturnError_t CO_GFCsend(CO_GFC_t *GFC)
|
|||
return CO_ERROR_NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* (CO_CONFIG_GFC) & CO_CONFIG_GFC_ENABLE */
|
||||
|
|
|
|||
18
304/CO_GFC.h
18
304/CO_GFC.h
|
|
@ -23,11 +23,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
#ifndef CO_GFC_H
|
||||
#define CO_GFC_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_GFC
|
||||
#define CO_CONFIG_GFC (0)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_GFC) & CO_CONFIG_GFC_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -120,9 +127,12 @@ void CO_GFC_initCallbackEnterSafeState(CO_GFC_t *GFC,
|
|||
CO_ReturnError_t CO_GFCsend(CO_GFC_t *GFC);
|
||||
#endif
|
||||
|
||||
/** @} */ /* CO_GFC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_GFC) & CO_CONFIG_GFC_ENABLE */
|
||||
|
||||
#endif /* CO_GFC_H */
|
||||
|
|
|
|||
|
|
@ -25,8 +25,15 @@
|
|||
|
||||
#include "304/CO_SRDO.h"
|
||||
|
||||
#if (CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE
|
||||
|
||||
#include "301/crc16-ccitt.h"
|
||||
|
||||
/* verify configuration */
|
||||
#if !((CO_CONFIG_CRC16) & CO_CONFIG_CRC16_ENABLE)
|
||||
#error CO_CONFIG_CRC16_ENABLE must be enabled.
|
||||
#endif
|
||||
|
||||
#define CO_SRDO_INVALID (0U)
|
||||
#define CO_SRDO_TX (1U)
|
||||
#define CO_SRDO_RX (2U)
|
||||
|
|
@ -321,7 +328,7 @@ static uint16_t CO_SRDOcalcCrc(const CO_SRDO_t *SRDO){
|
|||
CO_memcpySwap2(&buffer[0], &com->safetyCycleTime);
|
||||
result = crc16_ccitt(&buffer[0], 2, result);
|
||||
result = crc16_ccitt(&com->safetyRelatedValidationTime, 1, result);
|
||||
|
||||
|
||||
/* adjust COB-ID if the default is used
|
||||
Caution: if the node id changes and you are using the default COB-ID you have to recalculate the checksum
|
||||
This behaviour is controversial and could be changed or made optional.
|
||||
|
|
@ -836,3 +843,5 @@ void CO_SRDO_process(
|
|||
CO_FLAG_CLEAR(SRDO->CANrxNew[1]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* (CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE */
|
||||
|
|
|
|||
|
|
@ -23,13 +23,23 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CO_SRDO_H
|
||||
#define CO_SRDO_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_Emergency.h"
|
||||
#include "301/CO_NMT_Heartbeat.h"
|
||||
|
||||
#ifndef CO_SRDO_H
|
||||
#define CO_SRDO_H
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_SRDO
|
||||
#define CO_CONFIG_SRDO (0)
|
||||
#endif
|
||||
#ifndef CO_CONFIG_SRDO_MINIMUM_DELAY
|
||||
#define CO_CONFIG_SRDO_MINIMUM_DELAY 0
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -293,10 +303,12 @@ void CO_SRDO_process(
|
|||
uint32_t timeDifference_us,
|
||||
uint32_t *timerNext_us);
|
||||
|
||||
/** @} */ /* CO_SRDO */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE */
|
||||
|
||||
#endif /* CO_SRDO_H */
|
||||
|
|
|
|||
12
305/CO_LSS.h
12
305/CO_LSS.h
|
|
@ -27,6 +27,15 @@
|
|||
#ifndef CO_LSS_H
|
||||
#define CO_LSS_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_LSS
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_LSS) & (CO_CONFIG_LSS_SLAVE | CO_CONFIG_LSS_MASTER)) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -232,8 +241,11 @@ static const uint16_t CO_LSS_bitTimingTableLookup[] = {
|
|||
a1.identity.vendorID == a2.identity.vendorID)
|
||||
|
||||
/** @} */ /*@defgroup CO_LSS*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif /* (CO_CONFIG_LSS) & (CO_CONFIG_LSS_SLAVE | CO_CONFIG_LSS_MASTER) */
|
||||
|
||||
#endif /*CO_LSS_H*/
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h" /* for helper functions */
|
||||
#include "305/CO_LSSmaster.h"
|
||||
|
||||
#if (CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* LSS master slave select state machine. Compared to #CO_LSS_state_t this
|
||||
* has information if we currently have selected one or all slaves. This
|
||||
|
|
@ -1112,3 +1112,5 @@ CO_LSSmaster_return_t CO_LSSmaster_IdentifyFastscan(
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* (CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER */
|
||||
|
|
|
|||
|
|
@ -24,16 +24,17 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_LSSmaster_H
|
||||
#define CO_LSSmaster_H
|
||||
|
||||
#include "305/CO_LSS.h"
|
||||
|
||||
#if ((CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "305/CO_LSS.h"
|
||||
|
||||
/**
|
||||
* @defgroup CO_LSSmaster LSS Master
|
||||
* @ingroup CO_CANopen_305
|
||||
|
|
@ -469,8 +470,11 @@ CO_LSSmaster_return_t CO_LSSmaster_IdentifyFastscan(
|
|||
CO_LSSmaster_fastscan_t *fastscan);
|
||||
|
||||
/** @} */ /*@defgroup CO_LSSmaster*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif /* (CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER */
|
||||
|
||||
#endif /*CO_LSSmaster_H*/
|
||||
|
|
|
|||
|
|
@ -25,12 +25,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h" /* for helper functions */
|
||||
#include "305/CO_LSSslave.h"
|
||||
|
||||
#if (CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Read received message from CAN module.
|
||||
|
|
@ -484,3 +483,5 @@ bool_t CO_LSSslave_process(CO_LSSslave_t *LSSslave) {
|
|||
|
||||
return resetCommunication;
|
||||
}
|
||||
|
||||
#endif /* (CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE */
|
||||
|
|
|
|||
|
|
@ -25,16 +25,17 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_LSSslave_H
|
||||
#define CO_LSSslave_H
|
||||
|
||||
#include "305/CO_LSS.h"
|
||||
|
||||
#if ((CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "305/CO_LSS.h"
|
||||
|
||||
/**
|
||||
* @defgroup CO_LSSslave LSS Slave
|
||||
* @ingroup CO_CANopen_305
|
||||
|
|
@ -271,8 +272,11 @@ void CO_LSSslave_initCfgStoreCallback(
|
|||
bool_t (*pFunctLSScfgStore)(void *object, uint8_t id, uint16_t bitRate));
|
||||
|
||||
/** @} */ /*@defgroup CO_LSSslave*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif /* (CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE */
|
||||
|
||||
#endif /*CO_LSSslave_H*/
|
||||
|
|
|
|||
|
|
@ -24,15 +24,28 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "309/CO_gateway_ascii.h"
|
||||
|
||||
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "309/CO_gateway_ascii.h"
|
||||
|
||||
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
|
||||
/* verify configuration */
|
||||
#if !((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ENABLE)
|
||||
#error CO_CONFIG_FIFO_ENABLE must be enabled.
|
||||
#endif
|
||||
#if !((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS)
|
||||
#error CO_CONFIG_FIFO_ASCII_COMMANDS must be enabled.
|
||||
#endif
|
||||
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO
|
||||
#if !((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES)
|
||||
#error CO_CONFIG_FIFO_ASCII_DATATYPES must be enabled.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
CO_ReturnError_t CO_GTWA_init(CO_GTWA_t* gtwa,
|
||||
|
|
|
|||
|
|
@ -24,35 +24,30 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_GATEWAY_ASCII_H
|
||||
#define CO_GATEWAY_ASCII_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
|
||||
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) || defined CO_DOXYGEN
|
||||
|
||||
#include "301/CO_fifo.h"
|
||||
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO) || defined CO_DOXYGEN
|
||||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_SDOclient.h"
|
||||
#endif
|
||||
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT) || defined CO_DOXYGEN
|
||||
#include "301/CO_NMT_Heartbeat.h"
|
||||
#endif
|
||||
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS) || defined CO_DOXYGEN
|
||||
#include "305/CO_LSSmaster.h"
|
||||
#endif
|
||||
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_PRINT_LEDS) || defined CO_DOXYGEN
|
||||
#include "303/CO_LEDs.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_GTW
|
||||
#define CO_CONFIG_GTW (0)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup CO_CANopen_309_3 ASCII mapping
|
||||
* @defgroup CO_CANopen_309_3 Gateway ASCII mapping
|
||||
* @ingroup CO_CANopen_309
|
||||
* @{
|
||||
*
|
||||
|
|
@ -524,6 +519,7 @@ void CO_GTWA_process(CO_GTWA_t *gtwa,
|
|||
uint32_t timeDifference_us,
|
||||
uint32_t *timerNext_us);
|
||||
|
||||
/** @} */ /* CO_CANopen_309_3 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
@ -531,5 +527,4 @@ void CO_GTWA_process(CO_GTWA_t *gtwa,
|
|||
|
||||
#endif /* (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII */
|
||||
|
||||
/** @} */
|
||||
#endif /* CO_GATEWAY_ASCII_H */
|
||||
|
|
|
|||
20
CANopen.c
20
CANopen.c
|
|
@ -616,10 +616,10 @@ CO_ReturnError_t CO_LSSinit(uint8_t *nodeId,
|
|||
nodeId,
|
||||
CO->CANmodule[0],
|
||||
CO_RXCAN_LSS_SLV,
|
||||
CO_CAN_ID_LSS_SRV,
|
||||
CO_CAN_ID_LSS_MST,
|
||||
CO->CANmodule[0],
|
||||
CO_TXCAN_LSS_SLV,
|
||||
CO_CAN_ID_LSS_CLI);
|
||||
CO_CAN_ID_LSS_SLV);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
@ -640,24 +640,24 @@ CO_ReturnError_t CO_CANopenInit(uint8_t nodeId) {
|
|||
else
|
||||
#endif
|
||||
if (nodeId < 1 || nodeId > 127) {
|
||||
return CO_ERROR_PARAMETERS;
|
||||
return CO_ERROR_ILLEGAL_ARGUMENT;
|
||||
}
|
||||
/* Verify parameters from CO_OD */
|
||||
#if CO_NO_SRDO != 0
|
||||
if (sizeof(OD_SRDOCommunicationParameter_t) != sizeof(CO_SRDOCommPar_t) ||
|
||||
sizeof(OD_SRDOMappingParameter_t) != sizeof(CO_SRDOMapPar_t)) {
|
||||
return CO_ERROR_PARAMETERS;
|
||||
return CO_ERROR_OD_PARAMETERS;
|
||||
}
|
||||
#endif
|
||||
if (sizeof(OD_TPDOCommunicationParameter_t) != sizeof(CO_TPDOCommPar_t) ||
|
||||
sizeof(OD_TPDOMappingParameter_t) != sizeof(CO_TPDOMapPar_t) ||
|
||||
sizeof(OD_RPDOCommunicationParameter_t) != sizeof(CO_RPDOCommPar_t) ||
|
||||
sizeof(OD_RPDOMappingParameter_t) != sizeof(CO_RPDOMapPar_t)) {
|
||||
return CO_ERROR_PARAMETERS;
|
||||
return CO_ERROR_OD_PARAMETERS;
|
||||
}
|
||||
#if CO_NO_SDO_CLIENT != 0
|
||||
if (sizeof(OD_SDOClientParameter_t) != sizeof(CO_SDOclientPar_t)) {
|
||||
return CO_ERROR_PARAMETERS;
|
||||
return CO_ERROR_OD_PARAMETERS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -680,8 +680,8 @@ CO_ReturnError_t CO_CANopenInit(uint8_t nodeId) {
|
|||
uint32_t COB_IDServerToClient;
|
||||
if (i == 0) {
|
||||
/*Default SDO server must be located at first index*/
|
||||
COB_IDClientToServer = CO_CAN_ID_RSDO + nodeId;
|
||||
COB_IDServerToClient = CO_CAN_ID_TSDO + nodeId;
|
||||
COB_IDClientToServer = CO_CAN_ID_SDO_CLI + nodeId;
|
||||
COB_IDServerToClient = CO_CAN_ID_SDO_SRV + nodeId;
|
||||
}
|
||||
else {
|
||||
COB_IDClientToServer =
|
||||
|
|
@ -904,10 +904,10 @@ CO_ReturnError_t CO_CANopenInit(uint8_t nodeId) {
|
|||
CO_LSSmaster_DEFAULT_TIMEOUT,
|
||||
CO->CANmodule[0],
|
||||
CO_RXCAN_LSS_MST,
|
||||
CO_CAN_ID_LSS_CLI,
|
||||
CO_CAN_ID_LSS_SLV,
|
||||
CO->CANmodule[0],
|
||||
CO_TXCAN_LSS_MST,
|
||||
CO_CAN_ID_LSS_SRV);
|
||||
CO_CAN_ID_LSS_MST);
|
||||
|
||||
if (err) return err;
|
||||
#endif
|
||||
|
|
|
|||
59
CANopen.h
59
CANopen.h
|
|
@ -28,6 +28,24 @@
|
|||
#ifndef CANopen_H
|
||||
#define CANopen_H
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_SDOclient.h"
|
||||
#include "301/CO_Emergency.h"
|
||||
#include "301/CO_NMT_Heartbeat.h"
|
||||
#include "301/CO_TIME.h"
|
||||
#include "301/CO_SYNC.h"
|
||||
#include "301/CO_PDO.h"
|
||||
#include "301/CO_HBconsumer.h"
|
||||
#include "303/CO_LEDs.h"
|
||||
#include "304/CO_GFC.h"
|
||||
#include "304/CO_SRDO.h"
|
||||
#include "305/CO_LSSslave.h"
|
||||
#include "305/CO_LSSmaster.h"
|
||||
#include "309/CO_gateway_ascii.h"
|
||||
#include "extra/CO_trace.h"
|
||||
#include "CO_OD.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -141,16 +159,6 @@ extern "C" {
|
|||
* @{
|
||||
*/
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h"
|
||||
#include "301/CO_Emergency.h"
|
||||
#include "301/CO_NMT_Heartbeat.h"
|
||||
#include "301/CO_TIME.h"
|
||||
#include "301/CO_PDO.h"
|
||||
#include "301/CO_HBconsumer.h"
|
||||
#include "CO_OD.h"
|
||||
|
||||
|
||||
#ifdef CO_DOXYGEN
|
||||
/**
|
||||
* @defgroup CO_NO_OBJ CANopen configuration
|
||||
|
|
@ -247,35 +255,6 @@ extern "C" {
|
|||
#endif /* CO_DOXYGEN */
|
||||
|
||||
|
||||
#if CO_NO_SYNC == 1 || defined CO_DOXYGEN
|
||||
#include "301/CO_SYNC.h"
|
||||
#endif
|
||||
#if CO_NO_SDO_CLIENT != 0 || defined CO_DOXYGEN
|
||||
#include "301/CO_SDOclient.h"
|
||||
#endif
|
||||
#if CO_NO_GFC != 0 || defined CO_DOXYGEN
|
||||
#include "304/CO_GFC.h"
|
||||
#endif
|
||||
#if CO_NO_SRDO != 0 || defined CO_DOXYGEN
|
||||
#include "304/CO_SRDO.h"
|
||||
#endif
|
||||
#if CO_NO_LSS_SLAVE != 0 || defined CO_DOXYGEN
|
||||
#include "305/CO_LSSslave.h"
|
||||
#endif
|
||||
#if ((CO_CONFIG_LEDS) & CO_CONFIG_LEDS_ENABLE) || defined CO_DOXYGEN
|
||||
#include "303/CO_LEDs.h"
|
||||
#endif
|
||||
#if CO_NO_LSS_MASTER != 0 || defined CO_DOXYGEN
|
||||
#include "305/CO_LSSmaster.h"
|
||||
#endif
|
||||
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) || defined CO_DOXYGEN
|
||||
#include "309/CO_gateway_ascii.h"
|
||||
#endif
|
||||
#if CO_NO_TRACE != 0 || defined CO_DOXYGEN
|
||||
#include "extra/CO_trace.h"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* CANopen object with pointers to all CANopenNode objects.
|
||||
*/
|
||||
|
|
@ -492,7 +471,7 @@ void CO_process_SRDO(CO_t *co,
|
|||
uint32_t *timerNext_us);
|
||||
#endif /* CO_NO_SRDO != 0 */
|
||||
|
||||
/** @} */
|
||||
/** @} */ /* CO_CANopen */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,96 +42,111 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Stack configuration override from CO_driver.h. Compile full stack.
|
||||
/* Stack configuration override default values.
|
||||
* For more information see file CO_config.h. */
|
||||
#ifndef CO_CONFIG_NMT
|
||||
#define CO_CONFIG_NMT (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_NMT_CALLBACK_CHANGE | \
|
||||
CO_CONFIG_NMT_MASTER)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO
|
||||
#define CO_CONFIG_SDO (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_SDO_SEGMENTED | \
|
||||
CO_CONFIG_SDO_BLOCK)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 1800
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_EM
|
||||
#define CO_CONFIG_EM (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_EM_CONSUMER)
|
||||
#define CO_CONFIG_NMT (CO_CONFIG_NMT_CALLBACK_CHANGE | \
|
||||
CO_CONFIG_NMT_MASTER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_HB_CONS
|
||||
#define CO_CONFIG_HB_CONS (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE | \
|
||||
CO_CONFIG_HB_CONS_CALLBACK_CHANGE | \
|
||||
CO_CONFIG_HB_CONS_CALLBACK_MULTI | \
|
||||
CO_CONFIG_HB_CONS_QUERY_FUNCT)
|
||||
CO_CONFIG_HB_CONS_QUERY_FUNCT | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_GFC
|
||||
#define CO_CONFIG_GFC (CO_CONFIG_GFC_CONSUMER | \
|
||||
CO_CONFIG_GFC_PRODUCER)
|
||||
#ifndef CO_CONFIG_EM
|
||||
#define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER | \
|
||||
CO_CONFIG_EM_HISTORY | \
|
||||
CO_CONFIG_EM_CONSUMER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_FLAG_OD_DYNAMIC)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SRDO
|
||||
#define CO_CONFIG_SRDO (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_SRDO_CHECK_TX | \
|
||||
CO_CONFIG_RSRDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_TSRDO_CALLS_EXTENSION)
|
||||
#ifndef CO_CONFIG_SDO_SRV
|
||||
#define CO_CONFIG_SDO_SRV (CO_CONFIG_SDO_SRV_SEGMENTED | \
|
||||
CO_CONFIG_SDO_SRV_BLOCK | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_FLAG_OD_DYNAMIC)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SRDO_MINIMUM_DELAY
|
||||
#define CO_CONFIG_SRDO_MINIMUM_DELAY 0
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_PDO
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_PDO_SYNC_ENABLE | \
|
||||
CO_CONFIG_RPDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_TPDO_CALLS_EXTENSION)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#ifndef CO_CONFIG_SDO_SRV_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_SRV_BUFFER_SIZE (127*7)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_CLI
|
||||
#define CO_CONFIG_SDO_CLI (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
#define CO_CONFIG_SDO_CLI (CO_CONFIG_SDO_CLI_ENABLE | \
|
||||
CO_CONFIG_SDO_CLI_SEGMENTED | \
|
||||
CO_CONFIG_SDO_CLI_BLOCK | \
|
||||
CO_CONFIG_SDO_CLI_LOCAL)
|
||||
CO_CONFIG_SDO_CLI_LOCAL | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_FLAG_OD_DYNAMIC)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_CLI_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | \
|
||||
CO_CONFIG_SYNC_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_PDO
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | \
|
||||
CO_CONFIG_TPDO_ENABLE | \
|
||||
CO_CONFIG_PDO_SYNC_ENABLE | \
|
||||
CO_CONFIG_RPDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_TPDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TIME
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | \
|
||||
CO_CONFIG_TIME_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LEDS
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_LEDS_ENABLE)
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_GFC
|
||||
#define CO_CONFIG_GFC (CO_CONFIG_GFC_ENABLE | \
|
||||
CO_CONFIG_GFC_CONSUMER | \
|
||||
CO_CONFIG_GFC_PRODUCER)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SRDO
|
||||
#define CO_CONFIG_SRDO (CO_CONFIG_SRDO_ENABLE | \
|
||||
CO_CONFIG_SRDO_CHECK_TX | \
|
||||
CO_CONFIG_RSRDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_TSRDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SRDO_MINIMUM_DELAY
|
||||
#define CO_CONFIG_SRDO_MINIMUM_DELAY 0
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LSS
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_LSS_SLAVE | \
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE | \
|
||||
CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND | \
|
||||
CO_CONFIG_LSS_MASTER)
|
||||
CO_CONFIG_LSS_MASTER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_GTW
|
||||
|
|
@ -148,6 +163,22 @@ extern "C" {
|
|||
#define CO_CONFIG_GTWA_LOG_BUF_SIZE 2000
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_CRC16
|
||||
#define CO_CONFIG_CRC16 (CO_CONFIG_CRC16_ENABLE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_FIFO
|
||||
#define CO_CONFIG_FIFO (CO_CONFIG_FIFO_ENABLE | \
|
||||
CO_CONFIG_FIFO_ALT_READ | \
|
||||
CO_CONFIG_FIFO_CRC16_CCITT | \
|
||||
CO_CONFIG_FIFO_ASCII_COMMANDS | \
|
||||
CO_CONFIG_FIFO_ASCII_DATATYPES)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TRACE
|
||||
#define CO_CONFIG_TRACE (CO_CONFIG_TRACE_ENABLE)
|
||||
#endif
|
||||
|
||||
|
||||
/* Basic definitions. If big endian, CO_SWAP_xx macros must swap bytes. */
|
||||
#define CO_LITTLE_ENDIAN
|
||||
|
|
|
|||
|
|
@ -22,11 +22,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "extra/CO_trace.h"
|
||||
|
||||
#if (CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef CO_OWN_INTTYPES
|
||||
#if !((CO_CONFIG_TRACE) & CO_CONFIG_TRACE_OWN_INTTYPES)
|
||||
#include <inttypes.h> /* for PRIu32("u" or "lu") and PRId32("d" or "ld") */
|
||||
#endif
|
||||
|
||||
|
|
@ -501,3 +503,5 @@ void CO_trace_process(CO_trace_t *trace, uint32_t timestamp) {
|
|||
trace->lastTimeStamp = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* (CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE */
|
||||
|
|
|
|||
|
|
@ -23,17 +23,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_TRACE_H
|
||||
#define CO_TRACE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "301/CO_driver.h"
|
||||
#include "301/CO_SDOserver.h"
|
||||
|
||||
/* default configuration, see CO_config.h */
|
||||
#ifndef CO_CONFIG_TRACE
|
||||
#define CO_CONFIG_TRACE (0)
|
||||
#endif
|
||||
|
||||
#if ((CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE) || defined CO_DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup CO_trace Trace
|
||||
|
|
@ -163,9 +168,12 @@ void CO_trace_init(
|
|||
*/
|
||||
void CO_trace_process(CO_trace_t *trace, uint32_t timestamp);
|
||||
|
||||
/** @} */ /* CO_trace */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
#endif /* (CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE */
|
||||
|
||||
#endif /* CO_TRACE_H */
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#ifndef CO_LINUX_THREADS_H
|
||||
#define CO_LINUX_THREADS_H
|
||||
|
||||
#include "309/CO_gateway_ascii.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -604,13 +604,13 @@ CO_ReturnError_t CO_CANtxBuffer_setInterface(
|
|||
|
||||
index = CO_CANgetIndexFromIdent(CANmodule->txIdentToIndex, ident);
|
||||
if ((index == CO_INVALID_COB_ID) || (index > CANmodule->txSize)) {
|
||||
return CO_ERROR_PARAMETERS;
|
||||
return CO_ERROR_ILLEGAL_ARGUMENT;
|
||||
}
|
||||
CANmodule->txArray[index].CANptr = CANptrTx;
|
||||
|
||||
return CO_ERROR_NO;
|
||||
}
|
||||
return CO_ERROR_PARAMETERS;
|
||||
return CO_ERROR_ILLEGAL_ARGUMENT;
|
||||
}
|
||||
|
||||
#endif /* CO_DRIVER_MULTI_INTERFACE */
|
||||
|
|
@ -628,7 +628,7 @@ static CO_ReturnError_t CO_CANCheckSendInterface(
|
|||
ssize_t n;
|
||||
|
||||
if (CANmodule==NULL || interface==NULL || interface->fd < 0) {
|
||||
return CO_ERROR_PARAMETERS;
|
||||
return CO_ERROR_ILLEGAL_ARGUMENT;
|
||||
}
|
||||
|
||||
#if CO_DRIVER_ERROR_REPORTING > 0
|
||||
|
|
|
|||
|
|
@ -50,77 +50,90 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Stack configuration override from CO_driver.h.
|
||||
/* Stack configuration override default values.
|
||||
* For more information see file CO_config.h. */
|
||||
#ifndef CO_CONFIG_NMT
|
||||
#define CO_CONFIG_NMT (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_NMT_CALLBACK_CHANGE | \
|
||||
CO_CONFIG_NMT_MASTER)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO
|
||||
#define CO_CONFIG_SDO (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_SDO_SEGMENTED | \
|
||||
CO_CONFIG_SDO_BLOCK)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 1800
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_EM
|
||||
#define CO_CONFIG_EM (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_EM_CONSUMER)
|
||||
#define CO_CONFIG_NMT (CO_CONFIG_NMT_CALLBACK_CHANGE | \
|
||||
CO_CONFIG_NMT_MASTER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_HB_CONS
|
||||
#define CO_CONFIG_HB_CONS (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE | \
|
||||
CO_CONFIG_HB_CONS_CALLBACK_CHANGE | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_EM
|
||||
#define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER | \
|
||||
CO_CONFIG_EM_HISTORY | \
|
||||
CO_CONFIG_EM_CONSUMER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_FLAG_OD_DYNAMIC)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_SRV
|
||||
#define CO_CONFIG_SDO_SRV (CO_CONFIG_SDO_SRV_SEGMENTED | \
|
||||
CO_CONFIG_SDO_SRV_BLOCK | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_HB_CONS_CALLBACK_CHANGE)
|
||||
CO_CONFIG_FLAG_OD_DYNAMIC)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_PDO
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_PDO_SYNC_ENABLE | \
|
||||
CO_CONFIG_RPDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_TPDO_CALLS_EXTENSION)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#ifndef CO_CONFIG_SDO_SRV_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_SRV_BUFFER_SIZE (127*7)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_CLI
|
||||
#define CO_CONFIG_SDO_CLI (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
#define CO_CONFIG_SDO_CLI (CO_CONFIG_SDO_CLI_ENABLE | \
|
||||
CO_CONFIG_SDO_CLI_SEGMENTED | \
|
||||
CO_CONFIG_SDO_CLI_BLOCK | \
|
||||
CO_CONFIG_SDO_CLI_LOCAL)
|
||||
CO_CONFIG_SDO_CLI_LOCAL | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_FLAG_OD_DYNAMIC)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_CLI_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | \
|
||||
CO_CONFIG_SYNC_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_PDO
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | \
|
||||
CO_CONFIG_TPDO_ENABLE | \
|
||||
CO_CONFIG_PDO_SYNC_ENABLE | \
|
||||
CO_CONFIG_RPDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_TPDO_CALLS_EXTENSION | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TIME
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | \
|
||||
CO_CONFIG_TIME_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LEDS
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_FLAG_TIMERNEXT | \
|
||||
CO_CONFIG_LEDS_ENABLE)
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LSS
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_FLAG_CALLBACK_PRE | \
|
||||
CO_CONFIG_LSS_SLAVE | \
|
||||
#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE | \
|
||||
CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND | \
|
||||
CO_CONFIG_LSS_MASTER)
|
||||
CO_CONFIG_LSS_MASTER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_GTW
|
||||
|
|
@ -137,6 +150,22 @@ extern "C" {
|
|||
#define CO_CONFIG_GTWA_LOG_BUF_SIZE 10000
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_CRC16
|
||||
#define CO_CONFIG_CRC16 (CO_CONFIG_CRC16_ENABLE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_FIFO
|
||||
#define CO_CONFIG_FIFO (CO_CONFIG_FIFO_ENABLE | \
|
||||
CO_CONFIG_FIFO_ALT_READ | \
|
||||
CO_CONFIG_FIFO_CRC16_CCITT | \
|
||||
CO_CONFIG_FIFO_ASCII_COMMANDS | \
|
||||
CO_CONFIG_FIFO_ASCII_DATATYPES)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TRACE
|
||||
#define CO_CONFIG_TRACE (CO_CONFIG_TRACE_ENABLE)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_socketCAN_driver_target CO_driver_target.h
|
||||
|
|
|
|||
Loading…
Reference in a new issue