Skip to content

devcoons/stm32-drv-eeprom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EEPROM DRIVER

EEPROM driver reusable in different platforms. Supports all I2C speed modes.

Supported Hardware

  • NUCLEO-L552ZE-Q
  • NUCLEO-H745ZI-Q
  • NUCLEO-U575ZI-Q

Functions Guide

  • eeprom_initialize: initializes the eeprom_t instance and adds it in the eeprom_t eeprom_interface array.
  • eeprom_deinitialize: deinitializes the eeprom_t instance.
  • eeprom_read: reads the data from the eeprom starting from a given address and saves it in the specified buffer. The amount of data to be sent must be specified.
  • eeprom_available: checks wether the eeprom is free or not.
  • eeprom_wait_sync: puts the eeprom in timeout.
  • eeprom_write: writes the data contained in a specified buffer on the eeprom starting from a given address. The amount of data to be sent must be specified.
  • eeprom_clear_all: writes 0x00 in the whole EEPROM.

How to use

  • Set the I2C peripheral in the .ioc file

  • Include the header file drv_eeprom.h

  • Define an eeprom_t handler and initialize/assign properly the structure:

    • instance.handler: I2C handler of choice.
    • instance.mx_init : I2C initializing function generated by the configuration tool.
    • instance.dev_addr : address of the EEPROM.
    • instance.pg_sz: Page size in bytes.
    • instance.mem_sz: EEPROM memory size.
    • mem_addr_sz : Number of bytes of the address
  • Use the function:

    • eeprom_initialize: to initialize the EEPROM.
    • eeprom_read: to read data from the EEPROM.
    • eeprom_write: to write data on the EEPROM.

Example

This example uses the NUCLEO-L552ZE-Q with the X-NUCLEO-EEPRMA2 board extension.

eeprom_t eeprom_u1 = {

                .mx_init = MX_I2C1_Init,
                .handler = &hi2c1,
                .pg_sz = 16,
                .dev_addr = 0xA8,
		.mem_addr_sz = 2,
                .mem_sz = 2024
};

eeprom_initialize(&eeprom_u1)

memmove(eeprom_read_buffer, rw_buffer, 20);

eeprom_write(&eeprom_u1, 0x000A, eeprom_read_buffer, 20);

memset(eeprom_read_buffer,0, 100);

eeprom_read(&eeprom_u1, 0x0000, eeprom_read_buffer, 20);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages