Loading...
Searching...
No Matches

Detailed Description

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "xfa.h"
+ Include dependency graph for mtd.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mtd_dev_t
 MTD device descriptor. More...
 
struct  mtd_desc
 MTD driver interface. More...
 

Macros

#define MTD_XFA_ADD(dev, idx)    XFA_CONST(mtd_dev_xfa, idx) mtd_dev_t *mtd ## idx = (mtd_dev_t *)&(dev)
 Define MTD device pointer variable mtd<idx>
 
#define MTD_NUMOF   XFA_LEN(mtd_dev_t *, mtd_dev_xfa)
 Number of MTDs defined in the MTD device array in XFA.
 
#define MTD_DRIVER_FLAG_DIRECT_WRITE   (1 << 0)
 MTD driver can write any data to the storage without erasing it first.
 
#define MTD_DRIVER_FLAG_CLEARING_OVERWRITE   (1 << 1)
 MTD driver supports arbitrary clearing overwrites.
 

Typedefs

typedef struct mtd_desc mtd_desc_t
 MTD driver interface.
 

Enumerations

enum  mtd_power_state { MTD_POWER_UP , MTD_POWER_DOWN }
 MTD power states. More...
 

Functions

int mtd_init (mtd_dev_t *mtd)
 mtd_init Initialize a MTD device
 
int mtd_read (mtd_dev_t *mtd, void *dest, uint32_t addr, uint32_t count)
 Read data from a MTD device.
 
int mtd_read_page (mtd_dev_t *mtd, void *dest, uint32_t page, uint32_t offset, uint32_t size)
 Read data from a MTD device with pagewise addressing.
 
int mtd_write (mtd_dev_t *mtd, const void *src, uint32_t addr, uint32_t count)
 Write data to a MTD device.
 
int mtd_write_page_raw (mtd_dev_t *mtd, const void *src, uint32_t page, uint32_t offset, uint32_t size)
 Write data to a MTD device with pagewise addressing.
 
int mtd_write_page (mtd_dev_t *mtd, const void *src, uint32_t page, uint32_t offset, uint32_t size)
 Write data to a MTD device with pagewise addressing.
 
int mtd_erase (mtd_dev_t *mtd, uint32_t addr, uint32_t count)
 Erase sectors of a MTD device.
 
int mtd_erase_sector (mtd_dev_t *mtd, uint32_t sector, uint32_t num)
 Erase sectors of a MTD device.
 
int mtd_write_sector (mtd_dev_t *mtd, const void *src, uint32_t sector, uint32_t num)
 Write data to a MTD device with whole sector writes.
 
int mtd_power (mtd_dev_t *mtd, enum mtd_power_state power)
 Set power mode on a MTD device.
 
static mtd_dev_tmtd_dev_get (unsigned idx)
 Get an MTD device by index.
 

Variables

mtd_dev_t *const mtd_dev_xfa []
 MTD device array as XFA.