Midnight Sun Firmware
Loading...
Searching...
No Matches
fota_flash.h
1#pragma once
2
3/************************************************************************************************
4 * @file fota_flash.h
5 *
6 * @brief Fota Flash Header File
7 *
8 * @date 2025-04-30
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stdint.h>
15
16/* Inter-component Headers */
17
18/* Intra-component Headers */
19#include "fota_error.h"
20
28#define NUM_FLASH_PAGES 128U
29
31#define FOTA_PAGE_BYTES ((uint32_t)0x800U)
32
34#define FOTA_PING_BYTES ((uint32_t)0x1000U)
35
37#define FOTA_FLASH_WORD_SIZE 4U
38
44#define FOTA_ADDR_TO_PAGE(addr) (((uintptr_t)(addr) - (uintptr_t)APPLICATION_START_ADDRESS) / FOTA_PAGE_BYTES)
45
51#define FOTA_PAGE_TO_ADDR(page) ((uintptr_t)(page) * (uintptr_t)FOTA_PAGE_BYTES + (uintptr_t)APPLICATION_START_ADDRESS)
52
63FotaError fota_flash_write(uintptr_t address, uint8_t *buffer, uint32_t buffer_len);
64
72FotaError fota_flash_erase(uint8_t start_page, uint8_t num_pages);
73
82FotaError fota_flash_read(uintptr_t address, uint8_t *buffer, uint32_t buffer_len);
83
91
FotaError fota_verify_flash_memory(void)
Verify that the flash memory is not erased.
FotaError fota_flash_read(uintptr_t address, uint8_t *buffer, uint32_t buffer_len)
Read from flash memory.
FotaError fota_flash_write(uintptr_t address, uint8_t *buffer, uint32_t buffer_len)
Write to flash memory.
FotaError
FOTA Error code definitions.
Definition: fota_error.h:27
FotaError fota_flash_erase(uint8_t start_page, uint8_t num_pages)
Erase some number of flash pages.