/* Function for writing data to flash upon store command. 
Function for writing data to flash upon executing store command. Data is written to flash in reverse order, meaning starting at the end. If the data that is to be written is greater than the flash page size, it will be fragmented to fit the flash page size.  */
static void store_cmd_flash_write_execute(void)
/* Function for writing data to flash upon store command. 
Function for writing data to flash upon executing store command. Data is written to flash in reverse order, meaning starting at the end. If the data that is to be written is greater than the flash page size, it will be fragmented to fit the flash page size.  */
static void store_cmd_flash_write_execute(void)
{
    const cmd_queue_element_t * p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp];
    if (p_cmd->size > SOC_MAX_WRITE_SIZE)    
    {
        const uint32_t offset = p_cmd->size - PSTORAGE_FLASH_PAGE_SIZE;
        flash_write((uint32_t *)(p_cmd->storage_addr.block_id + p_cmd->offset + offset),
                    (uint32_t *)(p_cmd->p_data_addr + offset), 
                    PSTORAGE_FLASH_PAGE_SIZE / sizeof(uint32_t));   
        m_num_of_bytes_written = PSTORAGE_FLASH_PAGE_SIZE;    
    }
    else
    {
        flash_write((uint32_t *)(p_cmd->storage_addr.block_id + p_cmd->offset),
                    (uint32_t *)(p_cmd->p_data_addr), 
                    p_cmd->size / sizeof(uint32_t));   
        m_num_of_bytes_written = p_cmd->size;        
    }    
}