Wirepas SDK
external_flash.h
Go to the documentation of this file.
1 /* Copyright 2018 Wirepas Ltd. All Rights Reserved.
2  *
3  * See file LICENSE.txt for full license details.
4  *
5  */
6 
7 #ifndef EXTERNAL_FLASH_H_
8 #define EXTERNAL_FLASH_H_
9 
10 #include <stddef.h>
11 #include <stdint.h>
12 #include <stdbool.h>
13 
14 
16 typedef enum
17 {
18  EXTFLASH_RES_OK = 0, /* Operation is successful */
19  EXTFLASH_RES_ERROR = 1, /* Error during operation */
20  EXTFLASH_RES_BUSY = 2, /* Flash driver is busy */
21  EXTFLASH_RES_NODRIVER = 3, /* Flash driver not implemented */
22  EXTFLASH_RES_PARAM = 4 /* Invalid parameters */
24 
26 typedef struct
27 {
29  size_t flash_size;
44  uint32_t byte_write_time;
46  uint32_t page_write_time;
57 } flash_info_t;
58 
59 
66 
78 extFlash_res_e externalFlash_startRead(void * to, const void * from,
79  size_t amount);
91 extFlash_res_e externalFlash_startWrite(void * to, const void * from,
92  size_t amount);
93 
106 extFlash_res_e externalFlash_startErase(size_t * sector_base,
107  size_t * number_of_sector);
108 
113 bool externalFlash_isBusy(void);
114 
123 
124 #endif //EXTERNAL_FLASH_H__
EXTFLASH_RES_PARAM
@ EXTFLASH_RES_PARAM
Definition: external_flash.h:22
flash_info_t::page_write_call_time
uint32_t page_write_call_time
Definition: external_flash.h:52
flash_info_t::byte_write_call_time
uint32_t byte_write_call_time
Definition: external_flash.h:50
EXTFLASH_RES_NODRIVER
@ EXTFLASH_RES_NODRIVER
Definition: external_flash.h:21
externalFlash_startRead
extFlash_res_e externalFlash_startRead(void *to, const void *from, size_t amount)
Read bytes from external flash.
EXTFLASH_RES_ERROR
@ EXTFLASH_RES_ERROR
Definition: external_flash.h:19
flash_info_t::flash_size
size_t flash_size
Definition: external_flash.h:29
EXTFLASH_RES_BUSY
@ EXTFLASH_RES_BUSY
Definition: external_flash.h:20
externalFlash_startErase
extFlash_res_e externalFlash_startErase(size_t *sector_base, size_t *number_of_sector)
Erase a sector of flash.
flash_info_t::sector_erase_time
uint32_t sector_erase_time
Definition: external_flash.h:48
flash_info_t::sector_erase_call_time
uint32_t sector_erase_call_time
Definition: external_flash.h:54
flash_info_t
Flash memory info definition.
Definition: external_flash.h:26
externalFlash_getInfo
extFlash_res_e externalFlash_getInfo(flash_info_t *info)
Fills a structure with info about flash.
flash_info_t::is_busy_call_time
uint32_t is_busy_call_time
Definition: external_flash.h:56
externalFlash_isBusy
bool externalFlash_isBusy(void)
Checks if flash driver is busy.
externalFlash_init
extFlash_res_e externalFlash_init(void)
Initialize the external flash driver.
flash_info_t::write_page_size
size_t write_page_size
Definition: external_flash.h:31
externalFlash_startWrite
extFlash_res_e externalFlash_startWrite(void *to, const void *from, size_t amount)
Write bytes to flash.
flash_info_t::write_alignment
size_t write_alignment
Definition: external_flash.h:38
flash_info_t::page_write_time
uint32_t page_write_time
Definition: external_flash.h:46
extFlash_res_e
extFlash_res_e
External flash operations result.
Definition: external_flash.h:16
flash_info_t::erase_sector_size
size_t erase_sector_size
Definition: external_flash.h:33
EXTFLASH_RES_OK
@ EXTFLASH_RES_OK
Definition: external_flash.h:18
flash_info_t::byte_write_time
uint32_t byte_write_time
Definition: external_flash.h:44