CANopen Slave Documentation
Version 6.16.04
|
This module holds all functions for the initialization and control of the CANopen slave. Some functions of this module need to be adopted to the target application:
These functions are located in the cos_user.c file. Please refer to Initialization Process for details about the CosMgrInit() function and also check the Complete Startup Process for reference.
Macros | |
#define | COS_CONF_SLAVE ((uint16_t) 0x0000) |
#define | COS_CONF_MASTER ((uint16_t) 0x0001) |
#define | COS_CONF_AUTOSTART ((uint16_t) 0x0002) |
#define | COS_CONF_FD ((uint16_t) 0x0004) |
Functions | |
uint8_t | CosMgrGetBitrate (void) |
uint8_t | CosMgrGetNodeId (void) |
uint32_t | CosMgrGetProductCode (void) |
uint32_t | CosMgrGetSerialNumber (void) |
uint8_t | CosMgrInit (uint8_t ubCanIfV, uint16_t uwConfigV) |
void | CosMgrOnBootUp (void) |
void | CosMgrOnStart (uint8_t ubCallerResultV) |
uint8_t | CosMgrProcess (void) |
void | CosMgrProfileUpdate (uint16_t uwIndexV, uint8_t ubSubIndexV) |
uint8_t | CosMgrRelease (void) |
uint8_t | CosMgrStart (uint8_t ubNodeIdV, int32_t slBitrateNomSelV, int32_t slBitrateDatSelV) |
#define COS_CONF_AUTOSTART ((uint16_t) 0x0002) |
After transmission of the boot-up message, make an automatic transition of the NMT state machine to the Operational state.
#define COS_CONF_FD ((uint16_t) 0x0004) |
Start CANopen slave in ISO CAN FD mode (CANopen FD).
#define COS_CONF_MASTER ((uint16_t) 0x0001) |
Use the CANopen FD Slave protocol stack as NMT master and LSS master. This option is only possible in conjunction with the mini-master add-on. It is advised to use the CANopen FD Master protocol stack in order to achieve full support of all CANopen master features.
#define COS_CONF_SLAVE ((uint16_t) 0x0000) |
This the the default configuration: CANopen slave.
uint8_t CosMgrGetBitrate | ( | void | ) |
Get module bit-rate.
This routine checks for the bit-rate. The code of this routine has to be adopted to the specific target. The function returns a constant for the bit-rate that is specified in the canpie.h file.
uint8_t CosMgrGetNodeId | ( | void | ) |
This routine checks for the node-ID. The code of this routine has to be adopted to the specific target. The function returns a value in the range from 1 to 127.
uint32_t CosMgrGetProductCode | ( | void | ) |
This routine returns the Product Code of the module. The Product Number is used within in Identity Object (index 1018:02h).
uint32_t CosMgrGetSerialNumber | ( | void | ) |
This routine returns the Serial Number of the module, which must be a unique value for a product family. The Serial Number is used within the Identity Object (index 1018:04h).
uint8_t CosMgrInit | ( | uint8_t | ubCanIfV, |
uint16_t | uwConfigV | ||
) |
Initialise the CANopen Slave.
ubCanIfV | - Physical CAN interface |
uwConfigV | - Initial configuration |
The function returns eCOS_ERR_NONE on success. It is responsible for the following tasks:
Possible values for uwConfigV are:
void CosMgrOnBootUp | ( | void | ) |
This event is called after successful transmission of the Boot-up message.
void CosMgrOnStart | ( | uint8_t | ubCallerResultV | ) |
[in] | ubCallerResultV | Result of CANopen service initialization |
This event is called during the initialization of CANopen services (refer to CosMgrStart()). The parameter ubCallerResultV holds the state of the initialization process. Possible values are defined by the CosErr_e enumeration. On successful initialization the value for ubCallerResultV is eCOS_ERR_NONE.
The following example shows how to change default settings for the heartbeat and the SYNC producer, as well as registration of EMCY codes.
uint8_t CosMgrProcess | ( | void | ) |
Process CANopen message queue.
This function has to called within the main loop of the application. It is responsible to handle NVM operations and to check the requested NMT state. Possible return values are:
void CosMgrProfileUpdate | ( | uint16_t | uwIndexV, |
uint8_t | ubSubIndexV | ||
) |
Update parameter of device profile.
uwIndexV | parameter index |
ubSubIndexV | parameter sub-index |
This function is called by the stack when a parameter of a device profile is modified. It can be used to control the interaction between the CANopen slave stack and the application. The implementation of this function depends on the application.
uint8_t CosMgrRelease | ( | void | ) |
Release the CANopen Slave protocol stack.
This routine stops the CANopen protocol stack. The function returns CosErr_OK on success.
uint8_t CosMgrStart | ( | uint8_t | ubNodeIdV, |
int32_t | slBitrateNomSelV, | ||
int32_t | slBitrateDatSelV | ||
) |
ubNodeIdV | - Device node-ID (NID) |
slBitrateNomSelV | - Nominal bit rate value |
slBitrateDatSelV | - Data bit rate value |
This routine starts the CANopen protocol stack on the given node-ID and bit rate. The initialization routines from other CANopen services are called and the Boot-up message is sent. The function returns eCOS_ERR_NONE on success.
In case the device shall be started in classical CANopen mode the parameter slBitrateDatSelV
must be set to eCP_BITRATE_NONE.