#include <string.h>
#include <nrfx_nvmc.h>

#include "user_flash.h"



#define MAC_ADDR_START_ADDR 0x000F8000

enum sys_status store_mac_addr(uint8_t *data_ptr)
{
    uint32_t addr;
    uint8_t i;

    addr = MAC_ADDR_START_ADDR;
    
    for (i=0;i<6;i++)
    {
        nrfx_nvmc_byte_write(addr++, *data_ptr++);
    }

    return SYS_OK;
}

enum sys_status get_mac_addr(uint8_t *data_ptr)
{

    uint32_t addr;
    uint8_t i;

    addr = MAC_ADDR_START_ADDR;
    
    for (i=0;i<6;i++)
    {
        *data_ptr++ = *((volatile uint32_t *)addr);
        addr++;
    }

    return SYS_OK;

}

enum sys_status erase_mac_page(void)
{
    nrfx_nvmc_page_erase(MAC_ADDR_START_ADDR);
    return SYS_OK;

}