CANopen Bootloader Documentation
Version 4.10.00
|
This module holds all functions for the initialisation and control of the CANopen Bootloader. Some functions of this module need to be adopted to the target platform:
These functions are located in the cbl_user.c
file.
Enumerations | |
enum | CblFlashStatus_e { eCBL_FLASH_STATUS_OK = 0 , eCBL_FLASH_STATUS_PROGRESS = 1 } |
enum | CblFlashFail_e { eCBL_FLASH_FAIL_NO_PROGRAM = 1 , eCBL_FLASH_FAIL_FORMAT_UNKOWN , eCBL_FLASH_FAIL_FORMAT_CRC , eCBL_FLASH_FAIL_NOT_CLEARED , eCBL_FLASH_FAIL_WRITE_ERROR , eCBL_FLASH_FAIL_ADDRESS_ERROR , eCBL_FLASH_FAIL_SECURED } |
enum | CblProgControl_e { eCBL_PROG_CONTROL_STOP = 0 , eCBL_PROG_CONTROL_START , eCBL_PROG_CONTROL_RESET , eCBL_PROG_CONTROL_CLEAR , eCBL_PROG_CONTROL_MANUFACTURER = 0x80 } |
Functions | |
uint32_t | CblMgrBufferCrc (uint8_t *pubMemStartV, uint32_t ulSizeV) |
void | CblMgrBufferStore (uint8_t ubProgNumV, uint8_t *pubBufferV, uint16_t uwSizeV) |
void | CblMgrEventBusOff (void) |
void | CblMgrEventProgControl (uint8_t ubProgNumV, uint8_t ubProgControlV) |
void | CblMgrFlashDelete (uint8_t ubProgNumV) |
void | CblMgrFlashFinalize (uint8_t ubProgNumV, uint32_t ulSizeV) |
uint8_t | CblMgrGetBitrate (void) |
uint8_t | CblMgrGetNodeId (void) |
uint32_t | CblMgrGetSerialNumber (void) |
uint8_t | CblMgrInit (uint8_t ubCanIfV, uint16_t uwConfigV) |
uint8_t | CblMgrProcess (void) |
uint8_t | CblMgrRelease (void) |
uint8_t | CblMgrStart (uint8_t ubBitrateSelV, uint8_t ubNodeIdV) |
enum CblFlashFail_e |
Flash failure information.
This enumeration holds the flash failure information (index 1F57h) after programming. The information is coded in bit 1 to 7 of the object.
enum CblFlashStatus_e |
enum CblProgControl_e |
Program control.
This enumeration holds the program control values for index 1F51h.
uint32_t CblMgrBufferCrc | ( | uint8_t * | pubMemStartV, |
uint32_t | ulSizeV | ||
) |
[in] | pubMemStartV | Pointer to beginning of memory |
[in] | ulSizeV | Number of bytes |
This function calculates the CRC-32 value of the memory starting at pubMemStartV with a size of ulSizeV bytes. The algorithm is explained at http://de.wikipedia.org/wiki/CRC32 .
void CblMgrBufferStore | ( | uint8_t | ubProgNumV, |
uint8_t * | pubBufferV, | ||
uint16_t | uwSizeV | ||
) |
[in] | ubProgNumV | Program number |
[in] | pubBufferV | Pointer to data |
[in] | uwSizeV | Number of bytes |
cbl_user.c
. Also refer to the Flash Programming section for details.This function stores the transferred data from the RAM buffer into the Flash memory. The pointer pubBufferV denotes the beginning of the RAM buffer. The parameter uwSizeV defines the number of bytes to be stored.
The parameter ubProgNumV denotes the program number, the start value of the program number is 0. The value corresponds to the sub-index of object 1F50h, i.e. sub-index 1 is program number 0.
void CblMgrEventBusOff | ( | void | ) |
cbl_user.c
.This function is called upon a CAN bus-off condition. The reaction on a bus-off condition is application specific.
A sample implementation is located in the file cbl_user.c
void CblMgrEventProgControl | ( | uint8_t | ubProgNumV, |
uint8_t | ubProgControlV | ||
) |
[in] | ubProgNumV | Program number |
[in] | ubProgControlV | Program control value |
cbl_user.c
.This function is called upon writing a value greater or equal to 80h (eCBL_PROG_CONTROL_MANUFACTURER) to object 1F51h (program control). The behaviour of the program control operation is manufacturer specific.
The parameter ubProgNumV denotes the program number, the start value of the program number is 0. The value corresponds to the sub-index of object 1F51h, i.e. sub-index 1 is program number 0.
A sample implementation is located in the file cbl_user.c
void CblMgrFlashDelete | ( | uint8_t | ubProgNumV | ) |
[in] | ubProgNumV | Program number |
cbl_user.c
. Also refer to the Flash Programming section for details.This function erases the flash memory for the application. The parameter ubProgNumV denotes the program number, the start value of the program number is 0. The value corresponds to the sub-index of object 1F51h, i.e. sub-index 1 is program number 0.
void CblMgrFlashFinalize | ( | uint8_t | ubProgNumV, |
uint32_t | ulSizeV | ||
) |
[in] | ubProgNumV | Program number |
[in] | ulSizeV | Number of bytes |
cbl_user.c
. Also refer to the Flash Programming section for details.This function is called after all data has been transferred to the device. It is responsible to validate the stored data. The parameter ulSizeV defines the size of the application data.
The parameter ubProgNumV denotes the program number, the start value of the program number is 0. The value corresponds to the sub-index of object 1F50h, i.e. sub-index 1 is program number 0.
uint8_t CblMgrGetBitrate | ( | void | ) |
cbl_user.c
.This routine returns the device bit-rate.
uint8_t CblMgrGetNodeId | ( | void | ) |
cbl_user.c
.This routine returns the node-ID of the device. The return value has to be in the range from 1 to 127.
uint32_t CblMgrGetSerialNumber | ( | void | ) |
cbl_user.c
.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 in Identity Object (Index 1018:04h).
uint8_t CblMgrInit | ( | uint8_t | ubCanIfV, |
uint16_t | uwConfigV | ||
) |
[in] | ubCanIfV | Physical CAN interface |
[in] | uwConfigV | Initial configuration |
The CANopen Bootloader is initialised with CblMgrInit(). This routine will setup the CAN controller and initialise all necessary services. The support of services and their behaviour can be configured by setting the symbols inside the cbl_conf.h configuration file. The parameter ubCanIfV defines the physical CAN interface, taken from the CpChannel_e enumeration. The parameter uwConfigV is reserved and shall be set to 0.
Afterwards the stack can be started by calling the CblMgrStart() to start the CANopen Bootloader.
uint8_t CblMgrProcess | ( | void | ) |
This function is responsible to handle all CAN messages and to execute the necessary operations (e.g. erase flash memory). It must be called within the main loop of the application. The function returns an error code defined by the CblErr_e enumeration. The return code eCblErr_NODE_RESET requires a complete re-initialisation of the device, e.g. via a watchdog operation.
uint8_t CblMgrRelease | ( | void | ) |
This routine stops the CANopen Bootloader protocol stack. The function returns eCblErr_OK on success.
uint8_t CblMgrStart | ( | uint8_t | ubBitrateSelV, |
uint8_t | ubNodeIdV | ||
) |
[in] | ubBitrateSelV | Nominal bit-rate value |
[in] | ubNodeIdV | Device node-ID (NID) |
This routine starts the CANopen Bootloader protocol stack on the given node-ID defined by ubNodeIdV and bit-rate ubBitrateSelV. The initialisation routines from other CANopen services are called and the Boot-up message is sent. The function returns eCblErr_OK on success.