simple FS  v0.1.0
memory_driver.h
Go to the documentation of this file.
1 
22 #ifndef __MEMORY_DRIVER_H
23 #define __MEMORY_DRIVER_H
24 
25 #include <stdint.h>
26 #include <malloc.h>
27 
28 #define MEMORY_DRIVER_RAM 1
29 #define MEMORY_DRIVER_ONE_WIRE 2
30 #define MEMORY_DRIVER_SPI 3
31 
32 #ifdef USE_HAL_DRIVER
33 #define MEMORY_DRIVER MEMORY_DRIVER_SPI
34 #else
35 #define MEMORY_DRIVER MEMORY_DRIVER_RAM
36 #endif
37 
38 #ifndef MEMORY_EMPTY_VALUE
39  #define MEMORY_EMPTY_VALUE (uint8_t)0xFF
40 #endif
41 
42 //#if defined STM32L0 || defined STM32L4 || defined STM32F0
43 #if defined USE_HAL_DRIVER
44  #define SIMULATION 0
45 #else
46  #define SIMULATION 1
47 #endif
48 
49 #define MEMORY_PAGE_SIZE 256
50 
51 #if MEMORY_DRIVER == MEMORY_DRIVER_RAM
52 #define MEMORY_MAX_ADDRESS 0x4000
53 #elif MEMORY_DRIVER == MEMORY_DRIVER_ONE_WIRE
54 #define MEMORY_MAX_ADDRESS 0x50000
55 #elif MEMORY_DRIVER == MEMORY_DRIVER_SPI
56 //W25Q128
57 #define MEMORY_MAX_ADDRESS 0x1000000
58 #endif
59 
60 
62 #define FS_VARIANT_U 0x55
63 
64 #define FS_VARIANT_X 0x58
65 
66 #define FS_VARIANT_S 0x53
67 
68 #define FS_VARIANT_L 0x4C
69 
71 #define FS_SIZE_VARIANT FS_VARIANT_L
72 
73 
77 typedef enum state{
78  STATE_OK,
79  STATE_ERR,
80 }FS_state;
81 
86 typedef struct{
94  uint8_t (*Init)(void *hw_object, void* GPIOx, uint16_t GPIO_Pin);
102  uint16_t (*Read)(uint32_t addr,uint8_t *buf,uint16_t n);
110  uint16_t (*Write)(uint32_t addr,uint8_t *buf,int32_t n);
115  uint8_t (*IsBusy)(void);
120  uint8_t (*EraseAll)(void);
127  uint8_t (*EraseSector)(uint32_t addr_start);
132  uint8_t (*PowerUp)(void);
137  uint8_t (*PowerDown)(void);
138  void (*Dump)(void);
162  uint8_t (*Capacity)(void);
170  uint8_t (*Manufacturer)(void);
174  uint8_t (*Type)(void);
179  uint64_t (*Id)(void);
181 
182 #endif
183 
state
state
State definition for memory operations.
Definition: memory_driver.h:77
FS_state
enum state FS_state
State definition for memory operations.
MemoryDriver_t
Interface that defines list of functions with basic operation with memory.
Definition: memory_driver.h:86