For nRF24LE1 there are 2 options for flash writing which is selected by the PMW bit in PCON:
Functions | |
void | hal_flash_page_erase (uint8_t pn) |
void | hal_flash_byte_write (uint16_t a, uint8_t b) |
void | hal_flash_bytes_write (uint16_t a, const uint8_t *p, uint16_t n) |
uint8_t | hal_flash_byte_read (uint16_t a) |
void | hal_flash_bytes_read (uint16_t a, uint8_t *p, uint16_t n) |
Hardware dependencies | |
This sections contains hardware specific flash definitions. These definitions are not used inside the Flash HAL directly, but can become handy for the user of the Flash HAL. | |
#define | HAL_FLASH_PAGE_SIZE 512 |
#define | HAL_DATA_NV_BASE_ADDRESS 0xFA00 |
#define | HAL_DATA_NV_FLASH_PAGES 2 |
#define | HAL_DATA_NV_FLASH_PN0 32 |
#define | HAL_DATA_NV_FLASH_PN1 33 |
#define HAL_FLASH_PAGE_SIZE 512 |
Number of bytes per Flash page.
Definition at line 32 of file hal_flash_hw.h.
#define HAL_DATA_NV_BASE_ADDRESS 0xFA00 |
Start (xdata) address for "Non Voltaile Data Memory".
Used by the EEPROM library.
Definition at line 39 of file hal_flash_hw.h.
#define HAL_DATA_NV_FLASH_PAGES 2 |
Defines the number of physical Flash pages used by one "Non Voltaile Data Memory" page.
Definition at line 45 of file hal_flash_hw.h.
#define HAL_DATA_NV_FLASH_PN0 32 |
Defines the first physical flash page to which one "Non Voltaile Data Memory" is mapped.
Used by the EEPROM library.
Definition at line 53 of file hal_flash_hw.h.
#define HAL_DATA_NV_FLASH_PN1 33 |
Defines the second physical flash page to which one "Non Voltaile Data Memory" page is mapped.
Used by the EEPROM library.
Definition at line 61 of file hal_flash_hw.h.
void hal_flash_page_erase | ( | uint8_t | pn ) |
Function to erase a page in the Flash memory
pn | Page number |
Definition at line 21 of file hal_flash.c.
{ // Save interrupt enable state and disable interrupts: F0 = EA; EA = 0; // Enable flash write operation: WEN = 1; // Write the page address to FCR to start the page erase operation. This // operation is "self timed" when executing from the flash; the CPU will // halt until the operation is finished: FCR = pn; // When running from XDATA RAM we need to wait for the operation to finish: while(RDYN == 1) ; WEN = 0; EA = F0; // Restore interrupt enable state }
void hal_flash_byte_write | ( | uint16_t | a, |
uint8_t | b | ||
) |
Function to write a byte to the Flash memory
a | 16 bit address in Flash |
b | byte to write |
Definition at line 44 of file hal_flash.c.
{ static uint8_t xdata *pb; // Save interrupt enable state and disable interrupts: F0 = EA; EA = 0; // Enable flash write operation: WEN = 1; // Write the byte directly to the flash. This operation is "self timed" when // executing from the flash; the CPU will halt until the operation is // finished: pb = (uint8_t xdata *)a; *pb = b; //lint -e613 "Null pointer ok here" // When running from XDATA RAM we need to wait for the operation to finish: while(RDYN == 1) ; WEN = 0; EA = F0; // Restore interrupt enable state }
void hal_flash_bytes_write | ( | uint16_t | a, |
const uint8_t * | p, | ||
uint16_t | n | ||
) |
Function to write n bytes to the Flash memory
a | 16 bit address in Flash |
*p | pointer to bytes to write |
n | number of bytes to write |
Definition at line 70 of file hal_flash.c.
{ static uint8_t xdata *pb; // Save interrupt enable state and disable interrupts: F0 = EA; EA = 0; // Enable flash write operation: WEN = 1; // Write the bytes directly to the flash. This operation is // "self timed"; the CPU will halt until the operation is // finished: pb = (uint8_t xdata *)a; while(n--) { *pb++ = *p++; // // When running from XDATA RAM we need to wait for the operation to // finish: while(RDYN == 1) ; } WEN = 0; EA = F0; // Restore interrupt enable state }
uint8_t hal_flash_byte_read | ( | uint16_t | a ) |
Function to read a byte from the Flash memory
a | 16 bit address in Flash |
Definition at line 100 of file hal_flash.c.
{
uint8_t xdata *pb = (uint8_t xdata *)a;
return *pb;
}
void hal_flash_bytes_read | ( | uint16_t | a, |
uint8_t * | p, | ||
uint16_t | n | ||
) |
Function to read n bytes from the Flash memory
a | 16 bit address in Flash |
*p | pointer to bytes to write |
n | number of bytes to read |
Definition at line 106 of file hal_flash.c.
{
uint8_t xdata *pb = (uint8_t xdata *)a;
while(n--)
{
*p = *pb;
pb++;
p++;
}
}