Loading...
Searching...
No Matches
at24cxxx.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
69
70#include <stdint.h>
71
72#include "periph/gpio.h"
73#include "periph/i2c.h"
74
75#ifdef __cplusplus
76extern "C" {
77#endif
78
82enum {
83 AT24CXXX_OK,
84 AT24CXXX_I2C_ERROR
85};
86
90typedef struct at24cxxx_params {
92 gpio_t pin_wp;
93 uint32_t eeprom_size;
94 uint8_t dev_addr;
95 uint8_t page_size;
96 uint8_t max_polls;
98
105
117
129int at24cxxx_read_byte(const at24cxxx_t *dev, uint32_t pos, void *dest);
130
143int at24cxxx_read(const at24cxxx_t *dev, uint32_t pos, void *data, size_t len);
144
156int at24cxxx_write_byte(const at24cxxx_t *dev, uint32_t pos, uint8_t data);
157
172int at24cxxx_write(const at24cxxx_t *dev, uint32_t pos, const void *data,
173 size_t len);
174
190int at24cxxx_set(const at24cxxx_t *dev, uint32_t pos, uint8_t val,
191 size_t len);
192
205int at24cxxx_clear(const at24cxxx_t *dev, uint32_t pos, size_t len);
206
217
227
237
238#ifdef __cplusplus
239}
240#endif
241
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:144
Low-level I2C peripheral driver interface definition.
Struct that holds initialization parameters.
Definition at24cxxx.h:90
uint32_t eeprom_size
EEPROM memory capacity.
Definition at24cxxx.h:93
uint8_t dev_addr
I2C device address.
Definition at24cxxx.h:94
i2c_t i2c
I2C bus number.
Definition at24cxxx.h:91
gpio_t pin_wp
write protect pin
Definition at24cxxx.h:92
uint8_t max_polls
number of ACK poll attempts
Definition at24cxxx.h:96
uint8_t page_size
page size
Definition at24cxxx.h:95
Struct that represents an AT24CXXX device.
Definition at24cxxx.h:102
at24cxxx_params_t params
parameters
Definition at24cxxx.h:103