CANopenNode
CANopen protocol stack
|
Base module for Data storage. More...
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. | |
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.
Sub-indexes 1 and above:
Sub-indexes 1 and above:
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.
storage | This object will be initialized. It must be defined by application and must exist permanently. |
CANmodule | CAN device, for optional usage. |
OD_1010_StoreParameters | OD entry for 0x1010 -"Store parameters". Entry is optional, may be NULL. |
OD_1011_RestoreDefaultParameters | OD entry for 0x1011 -"Restore default parameters". Entry is optional, may be NULL. |
store | Pointer 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. |
restore | Same as 'store', but for restoring default data. |
entries | Pointer 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. |
entriesCount | Count of storage entries |