blob: e647c6a9caf9f1e98ed31f0d447a8a6b85a4f96e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#ifndef __SPI_FLASH_H__
#define __SPI_FLASH_H__
#include <stdbool.h>
#include <unistd.h>
struct spi_mem_id {
size_t size;
uint8_t mfg_id;
uint8_t type;
};
struct spi_flash_if {
struct spi_mem_id id;
uint32_t spi_base;
size_t page_size;
void (*cs)(bool val);
};
void spif_init(struct spi_flash_if *spif, size_t page_size, uint32_t spi_base, void (*cs)(bool val));
void spif_write(struct spi_flash_if *spif, size_t addr, size_t len, const char* data);
void spif_read(struct spi_flash_if *spif, size_t addr, size_t len, char* data);
void spif_clear_mem(struct spi_flash_if *spif);
void spif_clear_sector(struct spi_flash_if *spif, size_t addr);
void spif_deep_power_down(struct spi_flash_if *spif);
void spif_wakeup(struct spi_flash_if *spif);
#endif /* __SPI_FLASH_H__ */
|