PX4 Firmware
PX4 Autopilot Software http://px4.io
24xxxx_mtd.c File Reference
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/time.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/mtd/mtd.h>
#include <perf/perf_counter.h>
Include dependency graph for 24xxxx_mtd.c:

Go to the source code of this file.

Classes

struct  at24c_dev_s
 

Macros

#define CONFIG_AT24XX_SIZE   64
 
#define CONFIG_AT24XX_ADDR   0x50
 
#define AT24XX_NPAGES   256
 
#define AT24XX_PAGESIZE   32
 
#define CONFIG_AT24XX_MTD_BLOCKSIZE   AT24XX_PAGESIZE
 
#define CONFIG_AT24XX_WRITE_TIMEOUT_MS   20
 

Functions

static int at24c_erase (FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks)
 
static ssize_t at24c_bread (FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR uint8_t *buf)
 
static ssize_t at24c_bwrite (FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR const uint8_t *buf)
 
static int at24c_ioctl (FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
 
void at24c_test (void)
 
int at24c_nuke (void)
 
static int at24c_eraseall (FAR struct at24c_dev_s *priv)
 
FAR struct mtd_dev_s * at24c_initialize (FAR struct i2c_master_s *dev)
 

Variables

static struct at24c_dev_s g_at24c
 

Macro Definition Documentation

◆ AT24XX_NPAGES

#define AT24XX_NPAGES   256

Definition at line 123 of file 24xxxx_mtd.c.

Referenced by at24c_initialize().

◆ AT24XX_PAGESIZE

#define AT24XX_PAGESIZE   32

Definition at line 124 of file 24xxxx_mtd.c.

Referenced by at24c_bread(), at24c_bwrite(), at24c_eraseall(), and at24c_initialize().

◆ CONFIG_AT24XX_ADDR

#define CONFIG_AT24XX_ADDR   0x50

Definition at line 95 of file 24xxxx_mtd.c.

Referenced by at24c_initialize().

◆ CONFIG_AT24XX_MTD_BLOCKSIZE

#define CONFIG_AT24XX_MTD_BLOCKSIZE   AT24XX_PAGESIZE

Definition at line 145 of file 24xxxx_mtd.c.

Referenced by at24c_bread(), at24c_bwrite(), at24c_ioctl(), and at24c_test().

◆ CONFIG_AT24XX_SIZE

#define CONFIG_AT24XX_SIZE   64

Definition at line 88 of file 24xxxx_mtd.c.

Referenced by at24c_ioctl().

◆ CONFIG_AT24XX_WRITE_TIMEOUT_MS

#define CONFIG_AT24XX_WRITE_TIMEOUT_MS   20

Definition at line 152 of file 24xxxx_mtd.c.

Referenced by at24c_bread(), and at24c_bwrite().

Function Documentation

◆ at24c_bread()

static ssize_t at24c_bread ( FAR struct mtd_dev_s *  dev,
off_t  startblock,
size_t  nblocks,
FAR uint8_t *  buf 
)
static

Definition at line 285 of file 24xxxx_mtd.c.

References at24c_dev_s::addr, AT24XX_PAGESIZE, CONFIG_AT24XX_MTD_BLOCKSIZE, CONFIG_AT24XX_WRITE_TIMEOUT_MS, at24c_dev_s::dev, nblocks, at24c_dev_s::npages, at24c_dev_s::pagesize, perf_begin(), perf_count(), perf_end(), at24c_dev_s::perf_errors, at24c_dev_s::perf_resets_retries, and at24c_dev_s::perf_transfers.

Referenced by at24c_initialize(), and at24c_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at24c_bwrite()

static ssize_t at24c_bwrite ( FAR struct mtd_dev_s *  dev,
off_t  startblock,
size_t  nblocks,
FAR const uint8_t *  buf 
)
static

Definition at line 379 of file 24xxxx_mtd.c.

References at24c_dev_s::addr, AT24XX_PAGESIZE, CONFIG_AT24XX_MTD_BLOCKSIZE, CONFIG_AT24XX_WRITE_TIMEOUT_MS, at24c_dev_s::dev, nblocks, at24c_dev_s::npages, at24c_dev_s::pagesize, perf_begin(), perf_count(), perf_end(), at24c_dev_s::perf_errors, and at24c_dev_s::perf_transfers.

Referenced by at24c_initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at24c_erase()

static int at24c_erase ( FAR struct mtd_dev_s *  dev,
off_t  startblock,
size_t  nblocks 
)
static

Definition at line 245 of file 24xxxx_mtd.c.

References nblocks.

Referenced by at24c_initialize().

Here is the caller graph for this function:

◆ at24c_eraseall()

static int at24c_eraseall ( FAR struct at24c_dev_s priv)
static

Definition at line 206 of file 24xxxx_mtd.c.

References AT24XX_PAGESIZE, and OK.

Referenced by at24c_ioctl(), and at24c_nuke().

Here is the caller graph for this function:

◆ at24c_initialize()

FAR struct mtd_dev_s* at24c_initialize ( FAR struct i2c_master_s *  dev)

Definition at line 540 of file 24xxxx_mtd.c.

References at24c_dev_s::addr, at24c_bread(), at24c_bwrite(), at24c_erase(), at24c_ioctl(), AT24XX_NPAGES, AT24XX_PAGESIZE, CONFIG_AT24XX_ADDR, at24c_dev_s::dev, g_at24c, at24c_dev_s::mtd, at24c_dev_s::npages, at24c_dev_s::pagesize, PC_COUNT, PC_ELAPSED, perf_alloc, perf_begin(), perf_end(), at24c_dev_s::perf_errors, at24c_dev_s::perf_resets_retries, and at24c_dev_s::perf_transfers.

Referenced by mtd_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at24c_ioctl()

static int at24c_ioctl ( FAR struct mtd_dev_s *  dev,
int  cmd,
unsigned long  arg 
)
static

Definition at line 463 of file 24xxxx_mtd.c.

References at24c_eraseall(), CONFIG_AT24XX_MTD_BLOCKSIZE, CONFIG_AT24XX_SIZE, at24c_dev_s::npages, OK, and at24c_dev_s::pagesize.

Referenced by at24c_initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at24c_nuke()

int at24c_nuke ( void  )

Definition at line 613 of file 24xxxx_mtd.c.

References at24c_eraseall(), and g_at24c.

Here is the call graph for this function:

◆ at24c_test()

void at24c_test ( void  )

Definition at line 256 of file 24xxxx_mtd.c.

References at24c_bread(), CONFIG_AT24XX_MTD_BLOCKSIZE, g_at24c, and at24c_dev_s::mtd.

Here is the call graph for this function:

Variable Documentation

◆ g_at24c

struct at24c_dev_s g_at24c
static

Definition at line 200 of file 24xxxx_mtd.c.

Referenced by at24c_initialize(), at24c_nuke(), and at24c_test().