CANopen Bootloader Documentation
Version 4.10.00
Loading...
Searching...
No Matches
cbl_mgr.h File Reference

Detailed Description

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.

+ Include dependency graph for cbl_mgr.h:

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)
 

Enumeration Type Documentation

◆ 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.

Enumerator
eCBL_FLASH_FAIL_NO_PROGRAM 

No valid program available.

eCBL_FLASH_FAIL_FORMAT_UNKOWN 

Data format unknown

eCBL_FLASH_FAIL_FORMAT_CRC 

Data format error or data CRC error

eCBL_FLASH_FAIL_NOT_CLEARED 

Flash not cleared before write

eCBL_FLASH_FAIL_WRITE_ERROR 

Flash write error

eCBL_FLASH_FAIL_ADDRESS_ERROR 

General address error

eCBL_FLASH_FAIL_SECURED 

Flash secured (write access forbidden)

◆ CblFlashStatus_e

Flash status information.

This enumeration holds the flash status information (index 1F57h) during programming. The information is coded in bit 0 of the object.

Enumerator
eCBL_FLASH_STATUS_OK 

Flash status OK

eCBL_FLASH_STATUS_PROGRESS 

Programming in progress

◆ CblProgControl_e

Program control.

This enumeration holds the program control values for index 1F51h.

Enumerator
eCBL_PROG_CONTROL_STOP 

Stop program

eCBL_PROG_CONTROL_START 

Start program

eCBL_PROG_CONTROL_RESET 

Reset program

eCBL_PROG_CONTROL_CLEAR 

Clear program

eCBL_PROG_CONTROL_MANUFACTURER 

Manufacturer specific operation

Function Documentation

◆ CblMgrBufferCrc()

uint32_t CblMgrBufferCrc ( uint8_t *  pubMemStartV,
uint32_t  ulSizeV 
)
Parameters
[in]pubMemStartVPointer to beginning of memory
[in]ulSizeVNumber of bytes
Returns
CRC value

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 .

◆ CblMgrBufferStore()

void CblMgrBufferStore ( uint8_t  ubProgNumV,
uint8_t *  pubBufferV,
uint16_t  uwSizeV 
)
Parameters
[in]ubProgNumVProgram number
[in]pubBufferVPointer to data
[in]uwSizeVNumber of bytes
Note
Adopt this function to the application, a sample implementation is located in the file 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.

◆ CblMgrEventBusOff()

void CblMgrEventBusOff ( void  )
Note
Adopt this function to the application, a sample implementation is located in the file 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

{
//---------------------------------------------------------------------------------------------------
// Todo: handle CAN bus-off condition
//
}
void CblMgrEventBusOff(void)

◆ CblMgrEventProgControl()

void CblMgrEventProgControl ( uint8_t  ubProgNumV,
uint8_t  ubProgControlV 
)
Parameters
[in]ubProgNumVProgram number
[in]ubProgControlVProgram control value
Note
Adopt this function to the application, a sample implementation is located in the file 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 CblMgrEventProgControl(uint8_t ubProgNumV, uint8_t ubProgControlV)
{
//---------------------------------------------------------------------------------------------------
// Todo: handle manufacturer specific action
//
switch(ubProgControlV)
{
case eCBL_PROG_CONTROL_APP_VALID:
break;
case eCBL_PROG_CONTROL_APP_NOT_VALID:
break;
default:
break;
}
//---------------------------------------------------------------------------------------------------
// set the program control register to a defined value, e.g. eCBL_PROG_CONTROL_STOP
//
}
@ eCBL_PROG_CONTROL_STOP
Definition cbl_mgr.h:127
void CblMgrEventProgControl(uint8_t ubProgNumV, uint8_t ubProgControlV)
uint8_t aubIdx1F51_ControlG[]
Program control - index 1F51:0xh

◆ CblMgrFlashDelete()

void CblMgrFlashDelete ( uint8_t  ubProgNumV)
Parameters
[in]ubProgNumVProgram number
Note
Adopt this function to the application, a sample implementation is located in the file 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.

◆ CblMgrFlashFinalize()

void CblMgrFlashFinalize ( uint8_t  ubProgNumV,
uint32_t  ulSizeV 
)
Parameters
[in]ubProgNumVProgram number
[in]ulSizeVNumber of bytes
Note
Adopt this function to the application, a sample implementation is located in the file 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.

◆ CblMgrGetBitrate()

uint8_t CblMgrGetBitrate ( void  )
Returns
Value defined in CpBitrate_e enumeration
Note
Adopt this function to the application, a sample implementation is located in the file cbl_user.c.

This routine returns the device bit-rate.

uint8_t CblMgrGetBitrate(void)
{
uint8_t ubBitrateT = eCP_BITRATE_500K;
//---------------------------------------------------------------------------------------------------
// read DIP switch settings here or value from NVM
//
return (ubBitrateT);
}
@ eCP_BITRATE_500K
Definition canpie.h:677
uint8_t CblMgrGetBitrate(void)

◆ CblMgrGetNodeId()

uint8_t CblMgrGetNodeId ( void  )
Returns
node-ID
Note
Adopt this function to the application, a sample implementation is located in the file 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.

uint8_t CblMgrGetNodeId(void)
{
uint8_t ubNodeIdT = 126;
//---------------------------------------------------------------------------------------------------
// read DIP switch settings here or value from NVM
//
return (ubNodeIdT);
}
uint8_t CblMgrGetNodeId(void)

◆ CblMgrGetSerialNumber()

uint32_t CblMgrGetSerialNumber ( void  )
Returns
Serial number
Note
Adopt this function to the application, a sample implementation is located in the file 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).

uint32_t CblMgrGetSerialNumber(void)
{
uint32_t ulSerNumT;
//---------------------------------------------------------------------------------------------------
// read serial number from NVM
//
ulSerNumT = 1;
return(ulSerNumT);
}
uint32_t CblMgrGetSerialNumber(void)

◆ CblMgrInit()

uint8_t CblMgrInit ( uint8_t  ubCanIfV,
uint16_t  uwConfigV 
)
Parameters
[in]ubCanIfVPhysical CAN interface
[in]uwConfigVInitial configuration
Returns
Error code defined in CblErr_e enumeration

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.

◆ CblMgrProcess()

uint8_t CblMgrProcess ( void  )
Returns
Error code defined in CblErr_e enumeration

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.

◆ CblMgrRelease()

uint8_t CblMgrRelease ( void  )
Returns
Error code defined in CblErr_e enumeration

This routine stops the CANopen Bootloader protocol stack. The function returns eCblErr_OK on success.

◆ CblMgrStart()

uint8_t CblMgrStart ( uint8_t  ubBitrateSelV,
uint8_t  ubNodeIdV 
)
Parameters
[in]ubBitrateSelVNominal bit-rate value
[in]ubNodeIdVDevice node-ID (NID)
Returns
Error code defined in CblErr_e enumeration

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.