CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
mc_nvm.h File Reference

Detailed Description

For data access to a non-volatile memory (e.g. EEPROM) a simple API with read and write functions is provided.

+ Include dependency graph for mc_nvm.h:

Enumerations

enum  NVM_ERR_e {
  eNVM_ERR_NONE = 0x00 ,
  eNVM_ERR_OK = 0x00 ,
  eNVM_ERR_INIT = 0x01 ,
  eNVM_ERR_ADDRESS = 0x02 ,
  eNVM_ERR_READ = 0x04 ,
  eNVM_ERR_WRITE = 0x08 ,
  eNVM_ERR_ERASE = 0x10 ,
  eNVM_ERR_CHECKSUM = 0x20 ,
  eNVM_ERR_COLLISION = 0x40
}
 

Functions

uint16_t McNvmBuildChecksum (NvmAddr_tv tvStartAddressV, NvmSize_tv tvDataCountV)
 
void McNvmClearStatus (void)
 
Status_tv McNvmEraseDevice (void)
 
Status_tv McNvmGetStatus (void)
 
NvmSize_tv McNvmGetSize (void)
 
Status_tv McNvmInit (void)
 
Status_tv McNvmRead (NvmAddr_tv tvAddressV, uint8_t *pubDataV, NvmSize_tv tvSizeV)
 
Status_tv McNvmWriteEnable (void)
 
Status_tv McNvmWriteDisable (void)
 
Status_tv McNvmWrite (NvmAddr_tv tvAddressV, uint8_t *pubDataV, NvmSize_tv tvSizeV)
 

Enumeration Type Documentation

◆ NVM_ERR_e

enum NVM_ERR_e

Error code for NVM access.

The following error codes are used by the NVM driver. The status can be checked via the function McNvmGetStatus().

Enumerator
eNVM_ERR_NONE 

Device is operational, success of latest operation

eNVM_ERR_INIT 

Hardware or initialisation failure of device

eNVM_ERR_ADDRESS 

Address out of range

eNVM_ERR_READ 

Failure of read operation

eNVM_ERR_WRITE 

Failure of write operation

eNVM_ERR_ERASE 

Failure of erase operation

eNVM_ERR_CHECKSUM 

Failure of checksum operation

eNVM_ERR_COLLISION 

Collision during read / write operation

Function Documentation

◆ McNvmBuildChecksum()

uint16_t McNvmBuildChecksum ( NvmAddr_tv  tvStartAddressV,
NvmSize_tv  tvDataCountV 
)

Build Checksum.

Parameters
tvStartAddressV- First address for checksum algorithm
tvDataCountV- Number of data for checksum algorithm
Returns
checksum value

This function builds a checksum by adding the data from the memory location given by tvStartAddressV to tvStartAddressV + tvDataCountV. The value of tvDataCountV must be greater than 0.

◆ McNvmClearStatus()

void McNvmClearStatus ( void  )

Clear device status.

See also
McNvmGetStatus()

This function clears the device status / operation status.

◆ McNvmEraseDevice()

Status_tv McNvmEraseDevice ( void  )

Erase non-volatile memory.

Returns
Status code

This function erases the complete non-volatile memory. Possible return values are defined in the enumeration NVM_ERR_e.

◆ McNvmGetSize()

NvmSize_tv McNvmGetSize ( void  )

Get storage capacity.

Returns
Storage size

This function returns the maximum storage capacity of the device. The return value is the number of memory locations, independent of the data storage capabilities (BYTE or WORD) of the device. The highest memory address is then McNvmGetMax() - 1.

◆ McNvmGetStatus()

Status_tv McNvmGetStatus ( void  )

Get device status.

Returns
Status code

This function returns the device status / operation status. Possible return values are defined in the enumeration NVM_ERR_e. The device status is cleared with the function McNvmClearStatus().

◆ McNvmInit()

Status_tv McNvmInit ( void  )

Initialise Non-Volatile Memory.

Returns
Status code

This function is responsible for initialisation of the non-volatile memory. It has to be called prior to all other functions for non-volatile memory access.

Possible return values are defined in the enumeration NVM_ERR_e.

◆ McNvmRead()

Status_tv McNvmRead ( NvmAddr_tv  tvAddressV,
uint8_t *  pubDataV,
NvmSize_tv  tvSizeV 
)

Read data.

Parameters
tvAddressV- Memory read address
pubDataV- Pointer to data
tvSizeV- number of bytes to be read
Returns
Status code

This function is used to read data from a given memory location tvAddressV. The first memory location is address 0. The address points to a byte value location.

Possible return values are defined in the enumeration NVM_ERR_e.

◆ McNvmWrite()

Status_tv McNvmWrite ( NvmAddr_tv  tvAddressV,
uint8_t *  pubDataV,
NvmSize_tv  tvSizeV 
)

Write data.

Parameters
tvAddressV- Memory write address
pubDataV- Pointer to data
tvSizeV- number of bytes to be stored
Returns
Status code

This function is used to write data to a given memory location tvAddressV. The first memory location is address 0.

Possible return values are defined in the enumeration NVM_ERR_e.

◆ McNvmWriteDisable()

Status_tv McNvmWriteDisable ( void  )

Disable Write Operation.

Returns
Status code
See also
McNvmWriteEnable()

This function disables write-operation on the non-volatile memory.

Possible return values are defined in the enumeration NVM_ERR_e.

◆ McNvmWriteEnable()

Status_tv McNvmWriteEnable ( void  )

Enable Write Operation.

Returns
Status code
See also
McNvmWriteDisable()

This function enables write-operation to the non-volatile memory, which are disabled by default.

Possible return values are defined in the enumeration NVM_ERR_e.