no-OS
Loading...
Searching...
No Matches
m24512.c File Reference

Implementation of M24512 EEPROM driver. More...

#include <string.h>
#include "m24512.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_gpio.h"
#include "no_os_eeprom.h"
Include dependency graph for m24512.c:

Functions

int32_t m24512_init (struct no_os_eeprom_desc **desc, const struct no_os_eeprom_init_param *param)
 Initialize the M24512 EEPROM device.
 
int32_t m24512_remove (struct no_os_eeprom_desc *desc)
 Free resources allocated by M24512 device.
 
int32_t m24512_read_data (struct no_os_eeprom_desc *desc, uint32_t address, uint8_t *data, uint16_t len)
 Read multiple bytes from EEPROM.
 
int32_t m24512_write_data (struct no_os_eeprom_desc *desc, uint32_t address, uint8_t *data, uint16_t len)
 Write multiple bytes to EEPROM (handles page boundaries)
 
bool m24512_is_ready (struct m24512_dev *dev)
 Check if EEPROM is ready (write cycle completed)
 
int m24512_wait_ready (struct m24512_dev *dev, uint32_t timeout_ms)
 Wait for write cycle completion.
 
int m24512_get_info (struct m24512_dev *dev, uint32_t *memory_size, uint16_t *page_size, uint16_t *num_pages)
 Get device information.
 

Variables

const struct no_os_eeprom_platform_ops eeprom_m24512_ops
 M24512 EEPROM specific ops structure.
 

Detailed Description

Implementation of M24512 EEPROM driver.

Author
rober.nosp@m.t.bu.nosp@m.dai@a.nosp@m.nalo.nosp@m.g.com

Copyright 2025(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG Devices, INC. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ m24512_get_info()

int m24512_get_info ( struct m24512_dev * dev,
uint32_t * memory_size,
uint16_t * page_size,
uint16_t * num_pages )

Get device information.

Parameters
dev- Device descriptor
memory_size- Pointer to store memory size
page_size- Pointer to store page size
num_pages- Pointer to store number of pages
Returns
0 in case of success, negative error code otherwise

◆ m24512_init()

int32_t m24512_init ( struct no_os_eeprom_desc ** desc,
const struct no_os_eeprom_init_param * param )

Initialize the M24512 EEPROM device.

Parameters
desc- Pointer to device descriptor
param- Initialization parameters
Returns
0 in case of success, negative error code otherwise

◆ m24512_is_ready()

bool m24512_is_ready ( struct m24512_dev * dev)

Check if EEPROM is ready (write cycle completed)

Parameters
dev- Device descriptor
Returns
true if ready, false if busy

◆ m24512_read_data()

int32_t m24512_read_data ( struct no_os_eeprom_desc * desc,
uint32_t address,
uint8_t * data,
uint16_t len )

Read multiple bytes from EEPROM.

Parameters
desc- Device descriptor
address- Starting memory address
data- Buffer to store read data
len- Number of bytes to read
Returns
0 in case of success, negative error code otherwise

◆ m24512_remove()

int32_t m24512_remove ( struct no_os_eeprom_desc * desc)

Free resources allocated by M24512 device.

Parameters
desc- Device descriptor
Returns
0 in case of success, negative error code otherwise

◆ m24512_wait_ready()

int m24512_wait_ready ( struct m24512_dev * dev,
uint32_t timeout_ms )

Wait for write cycle completion.

Parameters
dev- Device descriptor
timeout_ms- Maximum timeout in milliseconds
Returns
0 if ready, negative error code on timeout
Here is the caller graph for this function:

◆ m24512_write_data()

int32_t m24512_write_data ( struct no_os_eeprom_desc * desc,
uint32_t address,
uint8_t * data,
uint16_t len )

Write multiple bytes to EEPROM (handles page boundaries)

Parameters
desc- Device descriptor
address- Starting memory address
data- Data buffer to write
len- Number of bytes to write
Returns
0 in case of success, negative error code otherwise

Variable Documentation

◆ eeprom_m24512_ops

const struct no_os_eeprom_platform_ops eeprom_m24512_ops
Initial value:
= {
.init = &m24512_init,
.remove = &m24512_remove,
.read = &m24512_read_data,
.write = &m24512_write_data,
}
int32_t m24512_remove(struct no_os_eeprom_desc *desc)
Free resources allocated by M24512 device.
Definition m24512.c:160
int32_t m24512_write_data(struct no_os_eeprom_desc *desc, uint32_t address, uint8_t *data, uint16_t len)
Write multiple bytes to EEPROM (handles page boundaries)
Definition m24512.c:222
int32_t m24512_read_data(struct no_os_eeprom_desc *desc, uint32_t address, uint8_t *data, uint16_t len)
Read multiple bytes from EEPROM.
Definition m24512.c:185
int32_t m24512_init(struct no_os_eeprom_desc **desc, const struct no_os_eeprom_init_param *param)
Initialize the M24512 EEPROM device.
Definition m24512.c:86

M24512 EEPROM specific ops structure.

M24512 EEPROM specific ops structure