CANopenNode
CANopen protocol stack
Loading...
Searching...
No Matches
Data storage base

Base module for Data storage. More...

+ Collaboration diagram for Data storage base:

Files

file  CO_storage.h
 CANopen data storage base object.
 

Data Structures

struct  CO_storage_t
 Data storage object. More...
 

Enumerations

enum  CO_storage_attributes_t { CO_storage_cmd = 0x01 , CO_storage_auto = 0x02 , CO_storage_restore = 0x04 }
 Attributes (bit masks) for Data storage object. More...
 

Functions

CO_ReturnError_t CO_storage_init (CO_storage_t *storage, CO_CANmodule_t *CANmodule, OD_entry_t *OD_1010_StoreParameters, OD_entry_t *OD_1011_RestoreDefaultParameters, ODR_t(*store)(CO_storage_entry_t *entry, CO_CANmodule_t *CANmodule), ODR_t(*restore)(CO_storage_entry_t *entry, CO_CANmodule_t *CANmodule), CO_storage_entry_t *entries, uint8_t entriesCount)
 Initialize data storage object.
 

Detailed Description

Base module for Data storage.

CANopen provides OD objects 0x1010 and 0x1011 for control of storing and restoring data. Data source is usually a group of variables inside object dictionary, but it is not limited to OD.

When object dictionary is generated (OD.h and OD.c files), OD variables are grouped into structures according to 'Storage group' parameter.

Autonomous data storing must be implemented target specific, if in use.

OD object 0x1010 - Store parameters:

Sub-indexes 1 and above:

OD object 0x1011 - Restore default parameters

Sub-indexes 1 and above:

Enumeration Type Documentation

◆ CO_storage_attributes_t

Attributes (bit masks) for Data storage object.

Enumerator
CO_storage_cmd 

CANopen device saves parameters on OD 1010 command.

CO_storage_auto 

CANopen device saves parameters autonomously.

CO_storage_restore 

CANopen device restores parameters on OD 1011 command

Function Documentation

◆ CO_storage_init()

CO_ReturnError_t CO_storage_init ( CO_storage_t * storage,
CO_CANmodule_t * CANmodule,
OD_entry_t * OD_1010_StoreParameters,
OD_entry_t * OD_1011_RestoreDefaultParameters,
ODR_t(* store )(CO_storage_entry_t *entry, CO_CANmodule_t *CANmodule),
ODR_t(* restore )(CO_storage_entry_t *entry, CO_CANmodule_t *CANmodule),
CO_storage_entry_t * entries,
uint8_t entriesCount )

Initialize data storage object.

This function should be called by application after the program startup, before CO_CANopenInit(). This function initializes storage object and OD extensions on objects 1010 and 1011. Function does not load stored data on startup, because loading data is target specific.

Parameters
storageThis object will be initialized. It must be defined by application and must exist permanently.
CANmoduleCAN device, used for CO_LOCK_OD() macro.
OD_1010_StoreParametersOD entry for 0x1010 -"Store parameters". Entry is optional, may be NULL.
OD_1011_RestoreDefaultParametersOD entry for 0x1011 -"Restore default parameters". Entry is optional, may be NULL.
storePointer to externally defined function, which will store data specified by CO_storage_entry_t. Function will be called when OD variable 0x1010 will be written. Argument to function is entry, where 'entry->subIndexOD' equals accessed subIndex. Function returns value from ODR_t : "ODR_OK" in case of success, "ODR_HW" in case of hardware error.
restoreSame as 'store', but for restoring default data.
entriesPointer to array of storage entries. Array must be defined and initialized by application and must exist permanently. Structure CO_storage_entry_t is target specific and must be defined by CO_driver_target.h. See CO_driver.h for required parameters.
entriesCountCount of storage entries
Returns
CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT.