Home > other >  NRF52832 FDS file
NRF52832 FDS file

Time:10-06

FDS, the full name of the Flash Data Storage, which is used to access to the internal Flash chips, when you need to store Data in a Flash, Flash or read the user Data, or update, or delete Data in a Flash, so the FDS module is your best choice, the FDS USES to organize Flash files and recording Data, that is to say, the real Data is placed in a record, and multiple records of a file, according to the needs of the application, the system can be only one file, also can contain more than one file, file using the file ID to mark, file ID is 2 bytes (note: a value of 0 XFFFF), a file you can set a record, also can put multiple records, the record is the key to mark, record the length of key is 2 bytes (note: a value of 0 x0000), here it is important to note that the same file below two or multiple records their key can be the same, for example, we can establish a file system as follows: 1 file contains 2 records, file contains 2 3 records, 2 contains 2 key 0 x0003 record
Through fds_record_write to create a new record, that is, written records, pay attention to the written records, must ensure that the input parameter is a global variable, or the static local variables, it is recommended to use global variables. Due to record the key can be repeated, so the same fds_record_write call two consecutive times, in the same key will generate two records, the front also mentioned, fds_record_write is asynchronous, so it return values for success just said operations team success, real flash operation result is registered by the front fds_evt_handler to inform,
Void Write_Flash_Data (uint16_t ID, uint16_t KEY, uint8_t * data)
{
Ret_code_t ret=0;
Fds_record_desc_t dvr_sn_desc={0};
Fds_find_token_t tok={0};
Fds_record_find (ID, KEY, & amp; Dvr_sn_desc, & amp; Tok);
Fds_record_delete (& amp; Dvr_sn_desc);

Fds_record_chunk_t chunk.
Fds_record_t record;
Record. File_id=ID;
Record. Key=key;

The static uint8_t w_data [16].
Memcpy (w_data, data, 16);

The chunk. P_data=https://bbs.csdn.net/topics/(uint8_t *) w_data;
The chunk. Length_words=4;
Record. The data. P_chunks=& amp; The chunk.
Record the data. Num_chunks=1;

Ret=fds_record_write (& amp; Dvr_sn_desc, & amp; Record);
APP_ERROR_CHECK (ret);
}
Bool Read_Flash_Data (uint16_t ID, uint16_t KEY, uint8_t * data)
{
Fds_find_token_t tok={0};
Fds_record_desc_t dvr_sn_desc={0};

If (fds_record_find (ID, KEY, & amp; Dvr_sn_desc, & amp; Tok)==FDS_SUCCESS)
{
Fds_flash_record_t record={0};
Fds_record_open (& amp; Dvr_sn_desc, & amp; Record);
Memcpy (data, record p_data, 16);
Fds_record_close (& amp; Dvr_sn_desc);
return true;
}
return false;
}
Use the SDK 12.2 debugging through, can be divided into two functions to read and write
  • Related