MAX3267X LittleFS demo
main.c File Reference

Flash Control Mass Erase & Write 32-bit enabled mode Example. More...

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "mxc_assert.h"
#include "mxc_device.h"
#include "flc.h"
#include "flash.h"
#include "littlefs/lfs.h"

Macros

#define APP_PAGE_CNT   8
 Flash memory blocks reserved for the app code. More...
 
#define APP_SIZE   (MXC_FLASH_PAGE_SIZE*APP_PAGE_CNT)
 The app code flash memory area size. More...
 
#define TESTSIZE   (MXC_FLASH_PAGE_SIZE)
 8 pages of 32 bit samples More...
 
#define TOTAL_FLASH_PAGES   (MXC_FLASH_MEM_SIZE / MXC_FLASH_PAGE_SIZE)
 Flash memory blocks reserved for internal storage. More...
 
#define FLASH_STORAGE_START_PAGE   8
 Internal storage first flash memory block. More...
 
#define FLASH_STORAGE_PAGE_CNT   8
 Flash memory blocks reserved for the internal storage. More...
 
#define FLASH_STORAGE_START_ADDR   MXC_FLASH_PAGE_ADDR(FLASH_STORAGE_START_PAGE)
 Internal storage start address. More...
 
#define FLASH_STORAGE_SIZE   FLASH_STORAGE_PAGE_CNT * MXC_FLASH_PAGE_SIZE
 Internal storage size. More...
 
#define FULL_WRITE_TEST   0
 
#define FULL_READ_TEST   0
 

Functions

int main (void)
 Application entry point. More...
 

Variables

uint32_t testdata [TESTSIZE]
 Test data buffer. More...
 
lfs_t lfs
 File system instance. More...
 
uint32_t start_block = FLASH_STORAGE_START_PAGE
 Internal memory start block to be passed to flash functions by littlefs. More...
 
const struct lfs_config cfg
 

Detailed Description

Flash Control Mass Erase & Write 32-bit enabled mode Example.

This example shows how to mass erase the flash using the library and also how to Write and Verify 4 Words to the flash.

Macro Definition Documentation

◆ APP_PAGE_CNT

#define APP_PAGE_CNT   8

Flash memory blocks reserved for the app code.

◆ APP_SIZE

#define APP_SIZE   (MXC_FLASH_PAGE_SIZE*APP_PAGE_CNT)

The app code flash memory area size.

◆ FLASH_STORAGE_PAGE_CNT

#define FLASH_STORAGE_PAGE_CNT   8

Flash memory blocks reserved for the internal storage.

◆ FLASH_STORAGE_SIZE

#define FLASH_STORAGE_SIZE   FLASH_STORAGE_PAGE_CNT * MXC_FLASH_PAGE_SIZE

Internal storage size.

◆ FLASH_STORAGE_START_ADDR

#define FLASH_STORAGE_START_ADDR   MXC_FLASH_PAGE_ADDR(FLASH_STORAGE_START_PAGE)

Internal storage start address.

◆ FLASH_STORAGE_START_PAGE

#define FLASH_STORAGE_START_PAGE   8

Internal storage first flash memory block.

◆ FULL_READ_TEST

#define FULL_READ_TEST   0

◆ FULL_WRITE_TEST

#define FULL_WRITE_TEST   0

◆ TESTSIZE

#define TESTSIZE   (MXC_FLASH_PAGE_SIZE)

8 pages of 32 bit samples

◆ TOTAL_FLASH_PAGES

#define TOTAL_FLASH_PAGES   (MXC_FLASH_MEM_SIZE / MXC_FLASH_PAGE_SIZE)

Flash memory blocks reserved for internal storage.

Function Documentation

◆ main()

int main ( void  )

Application entry point.

Returns
Exit code

Variable Documentation

◆ cfg

const struct lfs_config cfg
Initial value:
= {
.context = &start_block,
.read = flash_read,
.prog = flash_write,
.erase = flash_erase,
.sync = flash_sync,
.read_size = 1,
.prog_size = 4,
.block_size = MXC_FLASH_PAGE_SIZE,
.block_count = FLASH_STORAGE_PAGE_CNT,
.cache_size = 16,
.lookahead_size = 16,
.block_cycles = 500,
}

◆ lfs

File system instance.

◆ start_block

uint32_t start_block = FLASH_STORAGE_START_PAGE

Internal memory start block to be passed to flash functions by littlefs.

◆ testdata

uint32_t testdata[TESTSIZE]

Test data buffer.

flash_sync
int flash_sync(const struct lfs_config *c)
Performs pending flash operations.
Definition: flash.c:85
flash_read
int flash_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size)
Reads flash memory.
Definition: flash.c:50
flash_write
int flash_write(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size)
Writes flash memory.
Definition: flash.c:62
start_block
uint32_t start_block
Internal memory start block to be passed to flash functions by littlefs.
Definition: main.c:77
flash_erase
int flash_erase(const struct lfs_config *c, lfs_block_t block)
Erases flash memory block.
Definition: flash.c:72
FLASH_STORAGE_PAGE_CNT
#define FLASH_STORAGE_PAGE_CNT
Flash memory blocks reserved for the internal storage.
Definition: main.c:58