Patched version of nrf51822 FOTA compatible driver, with GPTIO disabled, as it clashed with the mbed definitions...

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Flash Manager

Flash Manager

Module for accessing flash memory. More...

Functions

uint32_t ble_flash_page_write (uint8_t page_num, uint32_t *p_in_array, uint8_t word_count)
 Function for erasing the specified flash page, and then writes the given data to this page.
uint32_t ble_flash_page_read (uint8_t page_num, uint32_t *p_out_array, uint8_t *p_word_count)
 Function for reading data from flash to RAM.
uint32_t ble_flash_page_erase (uint8_t page_num)
 Function for erasing a flash page.
uint32_t ble_flash_word_write (uint32_t *p_address, uint32_t value)
 Function for writing one word to flash.
uint32_t ble_flash_block_write (uint32_t *p_address, uint32_t *p_in_array, uint16_t word_count)
 Function for writing a data block to flash.
uint32_t ble_flash_page_addr (uint8_t page_num, uint32_t **pp_page_addr)
 Function for computing pointer to start of specified flash page.
uint16_t ble_flash_crc16_compute (uint8_t *p_data, uint16_t size, uint16_t *p_crc)
 Function for calculating a 16 bit CRC using the CRC-16-CCITT scheme.
void ble_flash_on_radio_active_evt (bool radio_active)
 Function for handling flashing module Radio Notification event.

Detailed Description

Module for accessing flash memory.

It contains functions for reading, writing and erasing one page in flash.

The module uses the first 32 bits of the flash page to write a magic number in order to determine if the page has been written or not.

Note:
Be careful not to use a page number in the SoftDevice area (which currently occupies the range 0 to 127), or in your application space! In both cases, this would end up with a hard fault.

Function Documentation

uint32_t ble_flash_block_write ( uint32_t *  p_address,
uint32_t *  p_in_array,
uint16_t  word_count 
)

Function for writing a data block to flash.

Note:
Flash locations to be written must have been erased previously.
Parameters:
[in]p_addressPointer to start of flash location to be written.
[in]p_in_arrayPointer to start of flash block to be written.
[in]word_countNumber of words to be written.
Returns:
NRF_SUCCESS.

Definition at line 154 of file ble_flash.c.

uint16_t ble_flash_crc16_compute ( uint8_t *  p_data,
uint16_t  size,
uint16_t *  p_crc 
)

Function for calculating a 16 bit CRC using the CRC-16-CCITT scheme.

Parameters:
[in]p_dataPointer to data on which the CRC is to be calulated.
[in]sizeNumber of bytes on which the CRC is to be calulated.
[in]p_crcInitial CRC value (if NULL, a preset value is used as the initial value).
Returns:
Calculated CRC.

Definition at line 28 of file ble_flash.c.

void ble_flash_on_radio_active_evt ( bool  radio_active )

Function for handling flashing module Radio Notification event.

Note:
For flash writing to work safely while in a connection or while advertising, this function MUST be called from the Radio Notification module's event handler (see Radio Notification Event Handler for details).
Parameters:
[in]radio_activeTRUE if radio is active (or about to become active), FALSE otherwise.

Definition at line 284 of file ble_flash.c.

uint32_t ble_flash_page_addr ( uint8_t  page_num,
uint32_t **  pp_page_addr 
)

Function for computing pointer to start of specified flash page.

Parameters:
[in]page_numPage number.
[out]pp_page_addrPointer to start of flash page.
Returns:
NRF_SUCCESS.

Definition at line 277 of file ble_flash.c.

uint32_t ble_flash_page_erase ( uint8_t  page_num )

Function for erasing a flash page.

Note:
This operation blocks the CPU, so it should not be done while the radio is running!
Parameters:
[in]page_numPage number to erase.
Returns:
NRF_SUCCESS on success, an error_code otherwise.

Definition at line 168 of file ble_flash.c.

uint32_t ble_flash_page_read ( uint8_t  page_num,
uint32_t *  p_out_array,
uint8_t *  p_word_count 
)

Function for reading data from flash to RAM.

Parameters:
[in]page_numPage number to read.
[out]p_out_arrayPointer to a RAM area where the found data will be written. This area has to be 32 bits aligned.
[out]p_word_countNumber of 32 bits words read.
Returns:
NRF_SUCCESS on successful upload, NRF_ERROR_NOT_FOUND if no valid data has been found in flash (first 32 bits not equal to the MAGIC_NUMBER+CRC).

Definition at line 231 of file ble_flash.c.

uint32_t ble_flash_page_write ( uint8_t  page_num,
uint32_t *  p_in_array,
uint8_t  word_count 
)

Function for erasing the specified flash page, and then writes the given data to this page.

Warning:
This operation blocks the CPU. DO NOT use while in a connection!
Parameters:
[in]page_numPage number to update.
[in]p_in_arrayPointer to a RAM area containing the elements to write in flash. This area has to be 32 bits aligned.
[in]word_countNumber of 32 bits words to write in flash.
Returns:
NRF_SUCCESS on successful flash write, otherwise an error code.

Definition at line 177 of file ble_flash.c.

uint32_t ble_flash_word_write ( uint32_t *  p_address,
uint32_t  value 
)

Function for writing one word to flash.

Note:
Flash location to be written must have been erased previously.
Parameters:
[in]p_addressPointer to flash location to be written.
[in]valueValue to write to flash.
Returns:
NRF_SUCCESS.

Definition at line 147 of file ble_flash.c.