SEcube
SEcube Open Source Library - Device
Data Structures | Macros | Typedefs | Enumerations | Functions
se3_keys.h File Reference

Key management. More...

#include "se3_flash.h"

Go to the source code of this file.

Data Structures

struct  se3_flash_key_
 Flash key structure. More...
 

Macros

#define SE3_TYPE_KEY   100
 

Typedefs

typedef struct se3_flash_key_ se3_flash_key
 Flash key structure. More...
 

Enumerations

enum  {
  SE3_FLASH_KEY_OFF_ID = 0, SE3_FLASH_KEY_OFF_VALIDITY = 4, SE3_FLASH_KEY_OFF_DATA_LEN = 8, SE3_FLASH_KEY_OFF_NAME_LEN = 10,
  SE3_FLASH_KEY_OFF_NAME_AND_DATA = 12, SE3_FLASH_KEY_SIZE_HEADER = SE3_FLASH_KEY_OFF_NAME_AND_DATA
}
 

Functions

bool se3_key_find (uint32_t id, se3_flash_it *it)
 Find a key. More...
 
bool se3_key_remove (se3_flash_it *it)
 Remove a key. More...
 
bool se3_key_new (se3_flash_it *it, se3_flash_key *key)
 Add a new key. More...
 
void se3_key_read (se3_flash_it *it, se3_flash_key *key)
 Read a key. More...
 
bool se3_key_equal (se3_flash_it *it, se3_flash_key *key)
 Check if key is equal. More...
 
void se3_key_read_data (se3_flash_it *it, uint16_t data_size, uint8_t *data)
 Read data from key node. More...
 
bool se3_key_write (se3_flash_it *it, se3_flash_key *key)
 Write key data. More...
 

Detailed Description

Key management.

Author
Nicola Ferri

Typedef Documentation

typedef struct se3_flash_key_ se3_flash_key

Flash key structure.

Disposition of the fields within the flash node: 0:3 id 4:7 validity 8:9 data_size 10:11 name_size 12:(12+data_size-1) data (12+data_size):(12+data_size+name_size-1) name

Enumeration Type Documentation

anonymous enum

Flash key fields

Function Documentation

bool se3_key_equal ( se3_flash_it it,
se3_flash_key key 
)

Check if key is equal.

Check if the supplied key is equal to a key stored in the flash.

Parameters
ita flash iterator pointing to a key
keya flash key structure to compare
Returns
true if equal, else false
bool se3_key_find ( uint32_t  id,
se3_flash_it it 
)

Find a key.

Find a key in the flash memory

Parameters
ididentifier of the key
ita flash iterator that will be set to the key's position
Returns
true on success
bool se3_key_new ( se3_flash_it it,
se3_flash_key key 
)

Add a new key.

Create a new node with the necessary amount of space for the key, then write the key.

Remarks
if a flash operation fails, the hwerror flag (se3c0.hwerror) is set.
Parameters
ita flash iterator which will receive the position of the new node
keya flash key structure containing the key information The data and name fields must point to a valid memory region, unless their size (data_size, name_size) is zero.
Returns
true on success, else false
void se3_key_read ( se3_flash_it it,
se3_flash_key key 
)

Read a key.

Read a key from a flash node

Parameters
ita flash iterator pointing to the key
keya flash key structure which will receive the key's information. The data and name fields will be filled only if not NULL.
void se3_key_read_data ( se3_flash_it it,
uint16_t  data_size,
uint8_t *  data 
)

Read data from key node.

Read the key's data from a ket node

Parameters
ita flash iterator pointing to the key
data_sizethe number of bytes to read
dataoutput data buffer
bool se3_key_remove ( se3_flash_it it)

Remove a key.

Delete a key from the flash

Remarks
if a flash operation fails, the hwerror flag (se3c0.hwerror) is set.
Parameters
ita flash iterator pointing to the key
Returns
true on success
bool se3_key_write ( se3_flash_it it,
se3_flash_key key 
)

Write key data.

Write key data to a flash node

Remarks
if a flash operation fails, the hwerror flag (se3c0.hwerror) is set.
Parameters
ita flash iterator pointing to a newly created flash node of key type
keya flash key structure containing the key information The data and name fields must point to a valid memory region, unless their size (data_size, name_size) is zero.
Returns
true on success, else false