Added file CO_config.h for stack configuration. Added CO_HBconsumer_initCallback()
This commit is contained in:
parent
0b2476ec95
commit
794c0f903a
11 changed files with 260 additions and 98 deletions
|
|
@ -49,6 +49,13 @@ static void CO_HBcons_receive(void *object, void *msg){
|
|||
HBconsNode->NMTstate = (CO_NMT_internalState_t)data[0];
|
||||
CO_FLAG_SET(HBconsNode->CANrxNew);
|
||||
}
|
||||
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_FLAG_CANRX_CALLBACK
|
||||
/* Optional signal to RTOS, which can resume task, which handles HBcons. */
|
||||
if(HBconsNode->pFunctSignalCanRx != NULL) {
|
||||
HBconsNode->pFunctSignalCanRx(HBconsNode->functSignalObjectCanRx);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -116,11 +123,22 @@ CO_ReturnError_t CO_HBconsumer_init(
|
|||
HBcons->NMTisPreOrOperationalPrev = false;
|
||||
HBcons->CANdevRx = CANdevRx;
|
||||
HBcons->CANdevRxIdxStart = CANdevRxIdxStart;
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
HBcons->pFunctSignalNmtChanged = NULL;
|
||||
#endif
|
||||
|
||||
for(i=0; i<HBcons->numberOfMonitoredNodes; i++) {
|
||||
uint8_t nodeId = (HBcons->HBconsTime[i] >> 16U) & 0xFFU;
|
||||
uint16_t time = HBcons->HBconsTime[i] & 0xFFFFU;
|
||||
ret = CO_HBconsumer_initEntry(HBcons, i, nodeId, time);
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_FLAG_CANRX_CALLBACK
|
||||
HBcons->monitoredNodes[i].pFunctSignalCanRx = NULL;
|
||||
#endif
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK
|
||||
HBcons->monitoredNodes[i].pFunctSignalHbStarted = NULL;
|
||||
HBcons->monitoredNodes[i].pFunctSignalTimeout = NULL;
|
||||
HBcons->monitoredNodes[i].pFunctSignalRemoteReset = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Configure Object dictionary entry at index 0x1016 */
|
||||
|
|
@ -165,7 +183,7 @@ CO_ReturnError_t CO_HBconsumer_initEntry(
|
|||
monitoredNode->nodeId = nodeId;
|
||||
monitoredNode->time_us = (int32_t)consumerTime_ms * 1000;
|
||||
monitoredNode->NMTstate = CO_NMT_INITIALIZING;
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 1
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
monitoredNode->NMTstatePrev = CO_NMT_INITIALIZING;
|
||||
#endif
|
||||
CO_FLAG_CLEAR(monitoredNode->CANrxNew);
|
||||
|
|
@ -196,7 +214,25 @@ CO_ReturnError_t CO_HBconsumer_initEntry(
|
|||
}
|
||||
|
||||
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 1
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_FLAG_CANRX_CALLBACK
|
||||
/******************************************************************************/
|
||||
void CO_HBconsumer_initCallback(
|
||||
CO_HBconsumer_t *HBcons,
|
||||
void *object,
|
||||
void (*pFunctSignal)(void *object))
|
||||
{
|
||||
if (HBcons != NULL) {
|
||||
uint8_t i;
|
||||
for(i=0; i<HBcons->numberOfMonitoredNodes; i++) {
|
||||
HBcons->monitoredNodes[i].pFunctSignalCanRx = pFunctSignal;
|
||||
HBcons->monitoredNodes[i].functSignalObjectCanRx = object;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
/******************************************************************************/
|
||||
void CO_HBconsumer_initCallbackNmtChanged(
|
||||
CO_HBconsumer_t *HBcons,
|
||||
|
|
@ -212,10 +248,10 @@ void CO_HBconsumer_initCallbackNmtChanged(
|
|||
HBcons->pFunctSignalNmtChanged = pFunctSignal;
|
||||
HBcons->pFunctSignalObjectNmtChanged = object;
|
||||
}
|
||||
#endif /* CO_CONFIG_HB_CONS_CALLBACKS & 1 */
|
||||
#endif
|
||||
|
||||
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 2
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK
|
||||
/******************************************************************************/
|
||||
void CO_HBconsumer_initCallbackHeartbeatStarted(
|
||||
CO_HBconsumer_t *HBcons,
|
||||
|
|
@ -271,7 +307,7 @@ void CO_HBconsumer_initCallbackRemoteReset(
|
|||
monitoredNode->pFunctSignalRemoteReset = pFunctSignal;
|
||||
monitoredNode->functSignalObjectRemoteReset = object;
|
||||
}
|
||||
#endif /* CO_CONFIG_HB_CONS_CALLBACKS & 2 */
|
||||
#endif /* CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK */
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -298,7 +334,7 @@ void CO_HBconsumer_process(
|
|||
if (CO_FLAG_READ(monitoredNode->CANrxNew)) {
|
||||
if (monitoredNode->NMTstate == CO_NMT_INITIALIZING) {
|
||||
/* bootup message*/
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 2
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK
|
||||
if (monitoredNode->pFunctSignalRemoteReset != NULL) {
|
||||
monitoredNode->pFunctSignalRemoteReset(
|
||||
monitoredNode->nodeId, i,
|
||||
|
|
@ -315,7 +351,7 @@ void CO_HBconsumer_process(
|
|||
}
|
||||
else {
|
||||
/* heartbeat message */
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 2
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK
|
||||
if (monitoredNode->HBstate != CO_HBconsumer_ACTIVE &&
|
||||
monitoredNode->pFunctSignalHbStarted != NULL) {
|
||||
monitoredNode->pFunctSignalHbStarted(
|
||||
|
|
@ -337,7 +373,7 @@ void CO_HBconsumer_process(
|
|||
|
||||
if (monitoredNode->timeoutTimer >= monitoredNode->time_us) {
|
||||
/* timeout expired */
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 2
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK
|
||||
if (monitoredNode->pFunctSignalTimeout!=NULL) {
|
||||
monitoredNode->pFunctSignalTimeout(
|
||||
monitoredNode->nodeId, i,
|
||||
|
|
@ -366,7 +402,7 @@ void CO_HBconsumer_process(
|
|||
if (monitoredNode->NMTstate != CO_NMT_OPERATIONAL) {
|
||||
allMonitoredOperationalCurrent = CO_NMT_INITIALIZING;
|
||||
}
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 1
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
/* Verify, if NMT state of monitored node changed */
|
||||
if(monitoredNode->NMTstate != monitoredNode->NMTstatePrev) {
|
||||
if (HBcons->pFunctSignalNmtChanged != NULL) {
|
||||
|
|
@ -384,7 +420,7 @@ void CO_HBconsumer_process(
|
|||
/* (pre)operational state changed, clear variables */
|
||||
for(i=0; i<HBcons->numberOfMonitoredNodes; i++) {
|
||||
monitoredNode->NMTstate = CO_NMT_INITIALIZING;
|
||||
#if CO_CONFIG_HB_CONS_CALLBACKS & 1
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
monitoredNode->NMTstatePrev = CO_NMT_INITIALIZING;
|
||||
#endif
|
||||
CO_FLAG_CLEAR(monitoredNode->CANrxNew);
|
||||
|
|
|
|||
|
|
@ -69,10 +69,6 @@ typedef struct {
|
|||
uint8_t nodeId;
|
||||
/** Of the remote node (Heartbeat payload) */
|
||||
CO_NMT_internalState_t NMTstate;
|
||||
#if (CO_CONFIG_HB_CONS_CALLBACKS & 1) || defined CO_DOXYGEN
|
||||
/** Previous value of the remote node (Heartbeat payload) */
|
||||
CO_NMT_internalState_t NMTstatePrev;
|
||||
#endif
|
||||
/** Current heartbeat state */
|
||||
CO_HBconsumer_state_t HBstate;
|
||||
/** Time since last heartbeat received */
|
||||
|
|
@ -81,7 +77,17 @@ typedef struct {
|
|||
uint32_t time_us;
|
||||
/** Indication if new Heartbeat message received from the CAN bus */
|
||||
volatile void *CANrxNew;
|
||||
#if (CO_CONFIG_HB_CONS_CALLBACKS & 2) || defined CO_DOXYGEN
|
||||
#if (CO_CONFIG_HB_CONS & CO_CONFIG_FLAG_CANRX_CALLBACK) || defined CO_DOXYGEN
|
||||
/** From CO_HBconsumer_initCallback() or NULL */
|
||||
void (*pFunctSignalCanRx)(void *object);
|
||||
/** From CO_HBconsumer_initCallback() or NULL */
|
||||
void *functSignalObjectCanRx;
|
||||
#endif
|
||||
#if (CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK) || defined CO_DOXYGEN
|
||||
/** Previous value of the remote node (Heartbeat payload) */
|
||||
CO_NMT_internalState_t NMTstatePrev;
|
||||
#endif
|
||||
#if (CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK) || defined CO_DOXYGEN
|
||||
/** Callback for heartbeat state change to active event.
|
||||
* From CO_HBconsumer_initCallbackHeartbeatStarted() or NULL. */
|
||||
void (*pFunctSignalHbStarted)(uint8_t nodeId, uint8_t idx, void *object);
|
||||
|
|
@ -121,7 +127,7 @@ typedef struct{
|
|||
bool_t NMTisPreOrOperationalPrev; /**< previous state of var */
|
||||
CO_CANmodule_t *CANdevRx; /**< From CO_HBconsumer_init() */
|
||||
uint16_t CANdevRxIdxStart; /**< From CO_HBconsumer_init() */
|
||||
#if (CO_CONFIG_HB_CONS_CALLBACKS & 1) || defined CO_DOXYGEN
|
||||
#if (CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK) || defined CO_DOXYGEN
|
||||
/** Callback for remote NMT changed event.
|
||||
* From CO_HBconsumer_initCallbackNmtChanged() or NULL. */
|
||||
void (*pFunctSignalNmtChanged)(uint8_t nodeId,
|
||||
|
|
@ -182,7 +188,25 @@ CO_ReturnError_t CO_HBconsumer_initEntry(
|
|||
uint8_t nodeId,
|
||||
uint16_t consumerTime_ms);
|
||||
|
||||
#if (CO_CONFIG_HB_CONS_CALLBACKS & 1) || defined CO_DOXYGEN
|
||||
#if (CO_CONFIG_HB_CONS & CO_CONFIG_FLAG_CANRX_CALLBACK) || defined CO_DOXYGEN
|
||||
/**
|
||||
* Initialize Heartbeat consumer callback function.
|
||||
*
|
||||
* Function initializes optional callback function, which should immediately
|
||||
* start processing of CO_HBconsumer_process() function.
|
||||
* Callback is called after HBconsumer message is received from the CAN bus.
|
||||
*
|
||||
* @param HBcons This object.
|
||||
* @param object Pointer to object, which will be passed to pFunctSignal(). Can be NULL
|
||||
* @param pFunctSignal Pointer to the callback function. Not called if NULL.
|
||||
*/
|
||||
void CO_HBconsumer_initCallback(
|
||||
CO_HBconsumer_t *HBcons,
|
||||
void *object,
|
||||
void (*pFunctSignal)(void *object));
|
||||
#endif
|
||||
|
||||
#if (CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK) || defined CO_DOXYGEN
|
||||
/**
|
||||
* Initialize Heartbeat consumer NMT changed callback function.
|
||||
*
|
||||
|
|
@ -202,7 +226,7 @@ void CO_HBconsumer_initCallbackNmtChanged(
|
|||
void *object));
|
||||
#endif
|
||||
|
||||
#if (CO_CONFIG_HB_CONS_CALLBACKS & 2) || defined CO_DOXYGEN
|
||||
#if (CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK) || defined CO_DOXYGEN
|
||||
/**
|
||||
* Initialize Heartbeat consumer started callback function.
|
||||
*
|
||||
|
|
@ -257,7 +281,7 @@ void CO_HBconsumer_initCallbackRemoteReset(
|
|||
uint8_t idx,
|
||||
void *object,
|
||||
void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object));
|
||||
#endif
|
||||
#endif /* CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_MULTI_CALLBACK */
|
||||
|
||||
/**
|
||||
* Process Heartbeat consumer object.
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ CO_ReturnError_t CO_NMT_init(
|
|||
CO_ReturnError_t ret = CO_ERROR_NO;
|
||||
|
||||
/* blinking bytes and LEDS */
|
||||
#if CO_CONFIG_NMT_LEDS > 0
|
||||
#if CO_CONFIG_NMT & CO_CONFIG_NMT_LEDS
|
||||
NMT->LEDtimer = 0;
|
||||
NMT->LEDflickering = 0;
|
||||
NMT->LEDblinking = 0;
|
||||
|
|
@ -223,7 +223,7 @@ CO_NMT_reset_cmd_t CO_NMT_process(
|
|||
CANpassive = 1;
|
||||
|
||||
|
||||
#if CO_CONFIG_NMT_LEDS > 0
|
||||
#if CO_CONFIG_NMT & CO_CONFIG_NMT_LEDS
|
||||
NMT->LEDtimer += timeDifference_us;
|
||||
if (NMT->LEDtimer >= 50000) {
|
||||
NMT->LEDtimer -= 50000;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ typedef enum{
|
|||
* @ref CO_NMT_statusLEDdiodes. Object is initialized by CO_NMT_init().
|
||||
*/
|
||||
typedef struct{
|
||||
#if CO_CONFIG_NMT_LEDS > 0 || defined CO_DOXYGEN
|
||||
#if (CO_CONFIG_NMT & CO_CONFIG_NMT_LEDS) || defined CO_DOXYGEN
|
||||
uint32_t LEDtimer; /**< 50ms led timer */
|
||||
int8_t LEDflickering; /**< See @ref CO_NMT_statusLEDdiodes */
|
||||
int8_t LEDblinking; /**< See @ref CO_NMT_statusLEDdiodes */
|
||||
|
|
|
|||
146
301/CO_config.h
Normal file
146
301/CO_config.h
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
/**
|
||||
* Configuration macros for CANopenNode.
|
||||
*
|
||||
* @file CO_config.h
|
||||
* @ingroup CO_driver
|
||||
* @author Janez Paternoster
|
||||
* @copyright 2020 Janez Paternoster
|
||||
*
|
||||
* This file is part of CANopenNode, an opensource CANopen Stack.
|
||||
* Project home page is <https://github.com/CANopenNode/CANopenNode>.
|
||||
* For more information on CANopen see <http://www.can-cia.org/>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CO_CONFIG_FLAGS_H
|
||||
#define CO_CONFIG_FLAGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG Stack configuration
|
||||
* @ingroup CO_driver
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Enable custom callback after CAN receive
|
||||
*
|
||||
* Flag enables optional callback functions, which are part of some CANopenNode
|
||||
* objects. Callbacks can optionally be registered by application, which
|
||||
* configures threads in operating system. Callback are called after CAN message
|
||||
* is received and preprocessed by higher priority thread. Callback may
|
||||
* immediately start mainline processing function, which further processes
|
||||
* received CAN message.
|
||||
*
|
||||
* If callback functions are used, they must be initialized separately, after
|
||||
* the object initialization.
|
||||
*
|
||||
* This flag is common to multiple configuration macros.
|
||||
*/
|
||||
#define CO_CONFIG_FLAG_CANRX_CALLBACK 0x0100
|
||||
|
||||
|
||||
/**
|
||||
* Configuration of NMT
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_NMT_LEDS - Calculate CANopen blinking variables, which can
|
||||
* be used for LEDs.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_NMT CO_CONFIG_NMT_LEDS
|
||||
#endif
|
||||
#define CO_CONFIG_NMT_LEDS 0x01
|
||||
|
||||
/**
|
||||
* Configuration of Heartbeat Consumer
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - #CO_CONFIG_FLAG_CANRX_CALLBACK - Enable custom callback after CAN receive.
|
||||
* Callback is configured by CO_HBconsumer_initCallback().
|
||||
* - CO_CONFIG_HB_CONS_CHANGE_CALLBACK - Enable custom callback after NMT
|
||||
* state of the monitored node changes. Callback is configured by
|
||||
* CO_HBconsumer_initCallbackNmtChanged().
|
||||
* - CO_CONFIG_HB_CONS_MULTI_CALLBACK - Enable multiple custom callbacks, which
|
||||
* can be configured for each monitored node. Callback are configured by
|
||||
* CO_HBconsumer_initCallbackHeartbeatStarted(),
|
||||
* CO_HBconsumer_initCallbackTimeout() and
|
||||
* CO_HBconsumer_initCallbackRemoteReset() functions.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_HB_CONS CO_CONFIG_FLAG_CANRX_CALLBACK | CO_CONFIG_HB_CONS_CHANGE_CALLBACK | CO_CONFIG_HB_CONS_MULTI_CALLBACK
|
||||
#endif
|
||||
#define CO_CONFIG_HB_CONS_CHANGE_CALLBACK 0x01
|
||||
#define CO_CONFIG_HB_CONS_MULTI_CALLBACK 0x02
|
||||
|
||||
|
||||
/**
|
||||
* Size of the internal SDO buffer.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef CO_CONFIG_SDO_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Configuration of Standard CiA 309 usage.
|
||||
*
|
||||
* CiA 309 standard covers CANopen access from other networks. It enables
|
||||
* usage of the NMT master, SDO client and LSS master as a gateway device.
|
||||
*
|
||||
* Value can be one of the following:
|
||||
* - 0: Disabled.
|
||||
* - 1: Interface enabled
|
||||
* - 2: Modbus/TCP mapping (Not implemented)
|
||||
* - 3: ASCII mapping
|
||||
* - 4: Profinet (Not implemented)
|
||||
*/
|
||||
#ifndef CO_CONFIG_309
|
||||
#define CO_CONFIG_309 0
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* CO_CONFIG_FLAGS_H */
|
||||
|
|
@ -28,11 +28,32 @@
|
|||
#define CO_DRIVER_H
|
||||
|
||||
#include "CO_driver_target.h"
|
||||
#include "CO_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Default stack configuration for most common configuration.
|
||||
* For more information see file CO_config.h. */
|
||||
#ifndef CO_CONFIG_NMT
|
||||
#define CO_CONFIG_NMT 0
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SDO_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_HB_CONS
|
||||
#define CO_CONFIG_HB_CONS 0
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_309
|
||||
#define CO_CONFIG_309 0
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_driver Driver
|
||||
* @ingroup CO_CANopen_301
|
||||
|
|
@ -88,74 +109,6 @@ extern "C" {
|
|||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG Stack configuration
|
||||
*
|
||||
* Definitions specify, which parts of the stack will be enabled. Values can be
|
||||
* overridden by CO_driver_target.h file for example.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Usage of CANopen LEDS.
|
||||
*
|
||||
* If >0, calculate CANopen blinking variables, which can be used for LEDs */
|
||||
#ifndef CO_CONFIG_NMT_LEDS
|
||||
#define CO_CONFIG_NMT_LEDS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Size of the internal SDO buffer.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef CO_CONFIG_SDO_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Configuration of Heartbeat Consumer Callbacks usage.
|
||||
*
|
||||
* - value = 0: Don't include any Heartbeat consumer callback functions in the
|
||||
* code.
|
||||
* - value = 1: Use function CO_HBconsumer_initCallbackNmtChanged(). It enables
|
||||
* application to configure one callback, which will notify about NMT state
|
||||
* change of the monitored node.
|
||||
* - value = 2: Use functions CO_HBconsumer_initCallbackHeartbeatStarted(),
|
||||
* CO_HBconsumer_initCallbackTimeout() and
|
||||
* CO_HBconsumer_initCallbackRemoteReset(). Those functions enable application
|
||||
* to configure set of three callbacks, different for each monitored node.
|
||||
* - value = 3: Use all functions, from 1 and 2.
|
||||
*/
|
||||
#ifndef CO_CONFIG_HB_CONS_CALLBACKS
|
||||
#define CO_CONFIG_HB_CONS_CALLBACKS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Configuration of Standard CiA 309 usage.
|
||||
*
|
||||
* CiA 309 standard covers CANopen access from other networks. It enables
|
||||
* usage of the NMT master, SDO client and LSS master as a gateway device.
|
||||
*
|
||||
* Value can be one of the following:
|
||||
* - 0: Disabled.
|
||||
* - 1: Interface enabled
|
||||
* - 2: Modbus/TCP mapping (Not implemented)
|
||||
* - 3: ASCII mapping
|
||||
* - 4: Profinet (Not implemented)
|
||||
*/
|
||||
#ifndef CO_CONFIG_309
|
||||
#define CO_CONFIG_309 0
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/* Macros and declarations in following part are only used for documentation. */
|
||||
#ifdef CO_DOXYGEN
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ Flowchart of a typical CANopenNode implementation
|
|||
File structure
|
||||
--------------
|
||||
- **301/** - CANopen application layer and communication profile.
|
||||
- **CO_config.h** - Configuration macros for CANopenNode.
|
||||
- **CO_driver.h** - Interface between CAN hardware and CANopenNode.
|
||||
- **CO_Emergency.h/.c** - CANopen Emergency protocol.
|
||||
- **CO_HBconsumer.h/.c** - CANopen Heartbeat consumer protocol.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Change Log
|
|||
- Rename in CO_driver_target.h: `IS_CANrxNew` -> `CO_FLAG_READ`, `SET_CANrxNew` -> `CO_FLAG_SET`, `CLEAR_CANrxNew` -> `CO_FLAG_CLEAR`
|
||||
- CO_driver.h file, function `CO_CANrxBufferInit()`, last argument (callback) changed from `(*pFunct)(void *object, const CO_CANrxMsg_t *message)` to `void (*CANrx_callback)(void *object, void *message)`. New functions are defined in `CO_driver_target.h` file: `CO_CANrxMsg_readIdent()`, `CO_CANrxMsg_readDLC()` and `CO_CANrxMsg_readData()`.
|
||||
- It is necessary to manually update CO_OD.c file - it must include: `301/CO_driver.h`, `CO_OD.h` and `301/CO_SDOserver.h`.
|
||||
- Added `void *object` argument to CO_*_initCallback() functions. API clarified. Callback functions called also from SDO_blockTransferInProgress.
|
||||
- Added `void *object` argument to CO_*_initCallback() functions. API clarified.
|
||||
- Add emergency receive callback also for own emergency messages.
|
||||
### Changed SocketCAN
|
||||
- ./stack/socketCAN removed from the project, ./stack/Neuberger-socketCAN moved to ./socketCAN
|
||||
|
|
@ -31,7 +31,7 @@ Change Log
|
|||
### Added
|
||||
- Documentation added to `doc` directory: CHANGELOG.md, deviceSupport.md, gettingStarted.md, LSSusage.md and traceUsage.md.
|
||||
- All CANopen objects calculates next timer info for OS. Useful for energy saving.
|
||||
- Stack configuration added to CO_driver.h. Can be overridden by custom definitions.
|
||||
- Added file CO_config.h for stack configuration. Can be overridden by target specific or by custom definitions.
|
||||
|
||||
[Unreleased master]
|
||||
-------------------
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Stack configuration override */
|
||||
#ifndef CO_CONFIG_NMT_LEDS
|
||||
#define CO_CONFIG_NMT_LEDS 1
|
||||
#ifndef CO_CONFIG_NMT
|
||||
#define CO_CONFIG_NMT CO_CONFIG_NMT_LEDS
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ void threadMainWait_init(uint32_t interval_us)
|
|||
/* Configure callback functions */
|
||||
CO_SDO_initCallback(CO->SDO[0], NULL, threadMainWait_callback);
|
||||
CO_EM_initCallback(CO->em, NULL, threadMainWait_callback);
|
||||
CO_HBconsumer_initCallback(CO->HBcons, NULL, threadMainWait_callback);
|
||||
|
||||
/* Initial value for time calculation */
|
||||
threadMainWait.start = CO_LinuxThreads_clock_gettime_us();
|
||||
|
|
|
|||
|
|
@ -50,13 +50,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Stack configuration override */
|
||||
/* Stack configuration override from CO_driver.h.
|
||||
* For more information see file CO_config.h. */
|
||||
#ifndef CO_CONFIG_HB_CONS
|
||||
#define CO_CONFIG_HB_CONS CO_CONFIG_FLAG_CANRX_CALLBACK | CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
#endif
|
||||
#ifndef CO_CONFIG_SDO_BUFFER_SIZE
|
||||
#define CO_CONFIG_SDO_BUFFER_SIZE 889
|
||||
#endif
|
||||
#ifndef CO_CONFIG_HB_CONS_CALLBACKS
|
||||
#define CO_CONFIG_HB_CONS_CALLBACKS 1
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue