OpenNuvoton / M031BSP

BSP for M031 Series MCU
Apache License 2.0
15 stars 16 forks source link

Writing/reading struct to/from flash. #7

Closed jeromeDms closed 2 years ago

jeromeDms commented 2 years ago

Hi there, I have a C struct that I would like to save to flash. I do not see in fmc.h any function to read/write flash, passing a pointer and data Len to write/read.

My struct is as follow :

typedef struct
{
    uint8_t midiInRouting[MIDI_DEV_MAX_USB_NUM_CABLES * 2];       
    uint16_t filterChannels[MIDI_DEV_MAX_USB_NUM_CABLES * 2];
    uint8_t filterStatus[MIDI_DEV_MAX_USB_NUM_CABLES * 2][MAX_FILTER_STATUS];
} _snvSettings;

Any tip to achieve this ? Thanks

kchuang1 commented 2 years ago

Hi,

Please try FMC_Read(...) and FMC_Write(...) function for flash read/write by passing a pointer instead of address.

jeromeDms commented 2 years ago

Not sure to understand. FMC_Read reads a single word from flash, how can I fill my entire struct by reading a single word ?

kchuang1 commented 2 years ago

You can implement a function to utilize FMC_Read function by changing the address to achieve this purpose.