CANopen Master Documentation
Version 6.06.04
|
This module holds all functions for the initialisation and control of the CANopen Master. Some functions of this module need to be adopted to the target platform. These functions are located inside the com_user.c
file.
Data Structures | |
struct | ComMgrIdentity_s |
Typedefs | |
typedef struct ComMgrIdentity_s | ComMgrIdentity_ts |
Enumerations | |
enum | ComVersion_e { eCOM_VERSION_STACK = 1 , eCOM_VERSION_COMPILER , eCOM_VERSION_SYSTEM } |
enum | ComMode_e { eCOM_MODE_NMT_SLAVE = 0x0000 , eCOM_MODE_NMT_MASTER = 0x0001 , eCOM_MODE_NMT_START_ALL = 0x0002 , eCOM_MODE_NMT_PREOPERATIONAL = 0x0004 , eCOM_MODE_NMT_APP_START_NODE = 0x0008 , eCOM_MODE_NMT_RESET_ALL = 0x0010 , eCOM_MODE_NMT_FLYING_MASTER = 0x0020 , eCOM_MODE_NMT_STOP_ALL = 0x0040 , eCOM_MODE_NMT_MASTER_DETECT = 0x0100 , eCOM_MODE_FD = 0x0200 , eCOM_MODE_CAN_RAW = 0x1000 , eCOM_MODE_J1939 = 0x2000 } |
Functions | |
CpState_ts * | ComMgrBusState (uint8_t ubNetV) |
void | ComMgrEventBus (uint8_t ubNetV, CpState_ts *ptsBusStateV) |
int32_t | ComMgrGetDataBitrate (uint8_t ubNetV) |
const char * | ComMgrGetVersionString (uint8_t ubTypeV) |
const char * | ComMgrGetConfiguration (void) |
ComStatus_tv | ComMgrInit (uint8_t ubCanIfV, uint8_t ubNetV, uint8_t ubBitrateNomSelV, uint8_t ubNodeIdV, uint32_t ulModeV) |
void | ComMgrNetTimerEvent (uint8_t ubNetV) |
ComStatus_tv | ComMgrNodeAdd (uint8_t ubNetV, uint8_t ubNodeIdV, ComNode_ts *ptsNodeV) |
ComStatus_tv | ComMgrNodeDelete (uint8_t ubNetV, uint8_t ubNodeIdV) |
ComStatus_tv | ComMgrProcess (uint8_t ubNetV) |
ComStatus_tv | ComMgrRelease (uint8_t ubNetV) |
ComStatus_tv | ComMgrSetErrorRegister (uint8_t ubNetV, uint8_t ubSetErrorV, uint8_t ubResetErrorV) |
ComStatus_tv | ComMgrSetIdentity (uint8_t ubNetV, ComMgrIdentity_ts *ptsIdentityV) |
ComStatus_tv | ComMgrStart (uint8_t ubNetV) |
ComStatus_tv | ComMgrStop (uint8_t ubNetV) |
void | ComMgrTimerEvent (void) |
ComStatus_tv | ComMgrUserInit (uint8_t ubNetV) |
typedef struct ComMgrIdentity_s ComMgrIdentity_ts |
CANopen Master - device identity.
The structure ComMgrIdentity_s allows access to the device identity object. It is used by the functions ComMgrGetIdentity() and ComMgrSetIdentity().
enum ComMode_e |
NMT startup mode.
The enumeration defines the values for starting the CANopen Master supplied to ComMgrInit(). The CANopen NMT configuration is reflected by object 1F80h (least significant 8 bits).
enum ComVersion_e |
Retrieve stack information.
The enumeration defines possible values for the parameter value ComMgrGetVersionString().
CpState_ts * ComMgrBusState | ( | uint8_t | ubNetV | ) |
[in] | ubNetV | CANopen Network channel |
This function returns a pointer to the CpState_ts structure of the corresponding network.
void ComMgrEventBus | ( | uint8_t | ubNetV, |
CpState_ts * | ptsBusStateV | ||
) |
[in] | ubNetV | CANopen Network channel |
[out] | ptsBusStateV | Pointer to CpState_ts value of bus |
This function is called by the stack on a CAN bus state change. The action on this function is application specific. The function body is placed in the file com_user.c
.
const char * ComMgrGetConfiguration | ( | void | ) |
This function returns a configuration string of the CANopen FD Master.
int32_t ComMgrGetDataBitrate | ( | uint8_t | ubNetV | ) |
[in] | ubNetV | CANopen Network channel |
This function is called by ComMgrInit() if the symbol COM_FD_SUPPORT is set to 1 and the CAN FD mode is enabled by eCOM_MODE_FD. In case no bit-rate switching is desired, the function shall return eCP_BITRATE_NONE. The function body is placed in the file com_user.c
.
const char * ComMgrGetVersionString | ( | uint8_t | ubTypeV | ) |
[in] | ubTypeV | - Information type |
This function returns a version string of the CANopen FD Master. The parameter ubTypeV defines the requested information, possible values are defined by the enumeration ComVersion_e.
ComStatus_tv ComMgrInit | ( | uint8_t | ubCanIfV, |
uint8_t | ubNetV, | ||
uint8_t | ubBitrateNomSelV, | ||
uint8_t | ubNodeIdV, | ||
uint32_t | ulModeV | ||
) |
[in] | ubCanIfV | Physical CAN interface |
[in] | ubNetV | CANopen Network channel |
[in] | ubBitrateNomSelV | Nominal bit-rate selection |
[in] | ubNodeIdV | Node-ID value |
[in] | ulModeV | Mode selection |
This function must be called before any other function of the CANopen FD Master stack. It is responsible for the initialisation of all services (NMT, SYNC, SDO, PDO, etc).
The function assigns the logical CANopen network number ubNetV to the CAN interface given by ubCanIfV
. The value for ubNetV can be taken from the ComNet_e enumeration. The maximum value is given by the symbol COM_NET_MAX.
The parameter ulModeV selects the mode of the protocol stack, possible values are defined by the enumeration ComMode_e.
void ComMgrNetTimerEvent | ( | uint8_t | ubNetV | ) |
Execute Timer-based Services.
ubNetV | - CANopen Network channel |
This routine must be called by a timer resource of the target system. It is responsible to call services that depend on a timer (e.g. Heartbeat). The period of the timer is defined via the COM_TIMER_PERIOD constant. The function calls the services for the CANopen network defined by ubNetV. Execution of timer-based services for all CANopen networks is possible via ComMgrTimerEvent().
Example
ComStatus_tv ComMgrNodeAdd | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
ComNode_ts * | ptsNodeV | ||
) |
ubNetV | - CANopen Network channel |
ubNodeIdV | - Node-ID value |
ptsNodeV | - Pointer to CANopen node |
This function adds a new CANopen node (device) to the CANopen Master on address ubNodeIdV.
ComStatus_tv ComMgrNodeDelete | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV | ||
) |
Remove CANopen device.
ubNetV | - CANopen Network channel |
ubNodeIdV | - Node-ID value |
This function removes a CANopen node (device) from the CANopen Master on address ubNodeIdV.
ComStatus_tv ComMgrProcess | ( | uint8_t | ubNetV | ) |
[in] | ubNetV | - CANopen Network channel |
This function is responsible for processing of CAN messages if the symbol COM_MGR_INT is set to 0.
ComStatus_tv ComMgrRelease | ( | uint8_t | ubNetV | ) |
Shutdown the CANopen Master.
[in] | ubNetV | - CANopen Network channel |
This function performs a shutdown of the CANopen Master.
ComStatus_tv ComMgrSetErrorRegister | ( | uint8_t | ubNetV, |
uint8_t | ubSetErrorV, | ||
uint8_t | ubResetErrorV | ||
) |
Set error register.
ubNetV | - CANopen Network channel |
ubSetErrorV | - Set new new error state |
ubResetErrorV | - Clear error state |
This function sets and clears bit-masked error states of the error register.
ComStatus_tv ComMgrSetIdentity | ( | uint8_t | ubNetV, |
ComMgrIdentity_ts * | ptsIdentityV | ||
) |
Set CANopen master identity values.
[in] | ubNetV | CANopen Network channel |
[in] | ptsIdentityV | Identity structure |
This function sets the values for object 1000h (device type) and object 1018h (identity). The new value must be different from 0, otherwise the default value is not modified. The value of object 1018h, sub-index 3 (software revision) allows only the modification of the lower 16 bits (minor revision number).
ComStatus_tv ComMgrStart | ( | uint8_t | ubNetV | ) |
Start the CANopen Master.
[in] | ubNetV | CANopen Network channel |
ComStatus_tv ComMgrStop | ( | uint8_t | ubNetV | ) |
Stop the CANopen Master.
[in] | ubNetV | CANopen Network channel |
void ComMgrTimerEvent | ( | void | ) |
Execute Timer-based Services.
This routine must be called by a timer resource of the target system. It is responsible to call services that depend on a timer (e.g. Heartbeat). The period of the timer is defined via the COM_TIMER_PERIOD constant. The function calls the services for all available networks. Execution of timer-based services for an individual network is possible via ComMgrNetTimerEvent().
Example
ComStatus_tv ComMgrUserInit | ( | uint8_t | ubNetV | ) |
Change CANopen Master settings.
ubNetV | - CANopen Network channel |
This function is called by ComMgrInit() during the initialisation phase. It can be used to change internal values of the Master (e.g. the vendor-ID or product code). The behavior of this function is application specific. The function body is placed in the file com_user.c
.