ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
w25q.h
Go to the documentation of this file.
1
14#ifndef W25Q_H
15#define W25Q_H
16
17#include <stdint.h>
18
19typedef struct {
21 int (*xfer)(void *ctx, const uint8_t *tx, uint32_t ntx, uint8_t *rx, uint32_t nrx);
23 int (*xfer_w)(void *ctx, const uint8_t *tx, uint32_t ntx, const uint8_t *data, uint32_t n);
24 void (*delay_ms)(uint32_t ms);
25 uint32_t (*now_ms)(void);
26 void *ctx;
28
29typedef struct {
31 uint32_t size;
32 uint8_t mfr, type, cap;
33 uint32_t base;
34} w25q_t;
35
37int w25q_init(w25q_t *d, const w25q_bus_t *bus);
38
39int w25q_read(w25q_t *d, uint32_t addr, void *buf, uint32_t n);
40int w25q_prog(w25q_t *d, uint32_t addr, const void *buf, uint32_t n);
41int w25q_erase_sector(w25q_t *d, uint32_t addr);
42int w25q_erase_chip(w25q_t *d);
44/* log_flash_t adapters (ctx = w25q_t*) */
45int w25q_lf_read(void *ctx, uint32_t addr, void *buf, uint32_t n);
46int w25q_lf_prog(void *ctx, uint32_t addr, const void *buf, uint32_t n);
47int w25q_lf_erase(void *ctx, uint32_t addr);
48
49#endif /* W25Q_H */
static void tx(const uint8_t *f, size_t len)
Definition app_task.c:83
uint32_t n
Definition calib_mgr.c:35
static int32_t xfer(void *h, uint16_t reg, uint16_t regsz, uint8_t *d, uint16_t len, int write)
Definition ext_i2c.c:12
static uint32_t addr(uint16_t sect)
Definition log_store.c:49
uint16_t ms
Definition log_task.c:42
void * ctx
Definition w25q.h:26
Definition w25q.h:29
uint32_t base
start of the log area
Definition w25q.h:33
uint8_t cap
JEDEC id
Definition w25q.h:32
uint32_t size
bytes, from the JEDEC id
Definition w25q.h:31
w25q_bus_t bus
Definition w25q.h:30
int w25q_init(w25q_t *d, const w25q_bus_t *bus)
reads the JEDEC id, releases power-down; 0 = a W25Q-compatible part
Definition w25q.c:59
int w25q_lf_read(void *ctx, uint32_t addr, void *buf, uint32_t n)
Definition w25q.c:111
int w25q_lf_prog(void *ctx, uint32_t addr, const void *buf, uint32_t n)
Definition w25q.c:112
int w25q_prog(w25q_t *d, uint32_t addr, const void *buf, uint32_t n)
inside one page
Definition w25q.c:83
int w25q_erase_chip(w25q_t *d)
waits (≤ 200 s)
Definition w25q.c:104
int w25q_read(w25q_t *d, uint32_t addr, void *buf, uint32_t n)
Definition w25q.c:75
int w25q_lf_erase(void *ctx, uint32_t addr)
Definition w25q.c:113
int w25q_erase_sector(w25q_t *d, uint32_t addr)
4 KB, waits (≤ 400 ms)
Definition w25q.c:94