Loading...
Searching...
No Matches
at24cxxx.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Otto-von-Guericke-Universität Magdeburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
66
67#include <stdint.h>
68
69#include "periph/gpio.h"
70#include "periph/i2c.h"
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
79enum {
80 AT24CXXX_OK,
81 AT24CXXX_I2C_ERROR
82};
83
87typedef struct at24cxxx_params {
89 gpio_t pin_wp;
90 uint32_t eeprom_size;
91 uint8_t dev_addr;
92 uint8_t page_size;
93 uint8_t max_polls;
95
99typedef struct {
101} at24cxxx_t;
102
114
126int at24cxxx_read_byte(const at24cxxx_t *dev, uint32_t pos, void *dest);
127
140int at24cxxx_read(const at24cxxx_t *dev, uint32_t pos, void *data, size_t len);
141
153int at24cxxx_write_byte(const at24cxxx_t *dev, uint32_t pos, uint8_t data);
154
169int at24cxxx_write(const at24cxxx_t *dev, uint32_t pos, const void *data,
170 size_t len);
171
187int at24cxxx_set(const at24cxxx_t *dev, uint32_t pos, uint8_t val,
188 size_t len);
189
202int at24cxxx_clear(const at24cxxx_t *dev, uint32_t pos, size_t len);
203
214
224
234
235#ifdef __cplusplus
236}
237#endif
238
Low-level GPIO peripheral driver interface definitions.
int at24cxxx_enable_write_protect(const at24cxxx_t *dev)
Enable write protection.
int at24cxxx_write_byte(const at24cxxx_t *dev, uint32_t pos, uint8_t data)
Write a byte at a given position pos.
int at24cxxx_clear(const at24cxxx_t *dev, uint32_t pos, size_t len)
Set len bytes from position pos to AT24CXXX_CLEAR_BYTE.
struct at24cxxx_params at24cxxx_params_t
Struct that holds initialization parameters.
int at24cxxx_read_byte(const at24cxxx_t *dev, uint32_t pos, void *dest)
Read a byte at a given position pos.
int at24cxxx_erase(const at24cxxx_t *dev)
Set the entire EEPROM memory to AT24CXXX_CLEAR_BYTE.
int at24cxxx_init(at24cxxx_t *dev, const at24cxxx_params_t *params)
Initialize an AT24CXXX device handle with AT24CXXX parameters.
int at24cxxx_read(const at24cxxx_t *dev, uint32_t pos, void *data, size_t len)
Sequentially read len bytes from a given position pos.
int at24cxxx_set(const at24cxxx_t *dev, uint32_t pos, uint8_t val, size_t len)
Set len bytes from a given position pos to the value val.
int at24cxxx_disable_write_protect(const at24cxxx_t *dev)
Disable write protection.
int at24cxxx_write(const at24cxxx_t *dev, uint32_t pos, const void *data, size_t len)
Sequentially write len bytes from a given position pos.
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
Struct that holds initialization parameters.
Definition at24cxxx.h:87
uint32_t eeprom_size
EEPROM memory capacity.
Definition at24cxxx.h:90
uint8_t dev_addr
I2C device address.
Definition at24cxxx.h:91
i2c_t i2c
I2C bus number.
Definition at24cxxx.h:88
gpio_t pin_wp
write protect pin
Definition at24cxxx.h:89
uint8_t max_polls
number of ACK poll attempts
Definition at24cxxx.h:93
uint8_t page_size
page size
Definition at24cxxx.h:92
Struct that represents an AT24CXXX device.
Definition at24cxxx.h:99
at24cxxx_params_t params
parameters
Definition at24cxxx.h:100