Loading...
Searching...
No Matches
at25xxx.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 ML!PA Consulting GmbH
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
21
22#include <stdint.h>
23#include <stdbool.h>
24
25#include "periph/spi.h"
26#include "periph/gpio.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
35typedef struct {
36 spi_t spi;
39 gpio_t wp_pin;
40 gpio_t hold_pin;
41 uint32_t size;
42 uint16_t page_size;
44
48typedef struct {
50} at25xxx_t;
51
61int at25xxx_init(at25xxx_t *dev, const at25xxx_params_t *params);
62
71uint8_t at25xxx_read_byte(const at25xxx_t *dev, uint32_t pos);
72
84int at25xxx_read(const at25xxx_t *dev, uint32_t pos, void *data, size_t len);
85
93void at25xxx_write_byte(const at25xxx_t *dev, uint32_t pos, uint8_t data);
94
106int at25xxx_write(const at25xxx_t *dev, uint32_t pos, const void *data, size_t len);
107
121int at25xxx_write_page(const at25xxx_t *dev, uint32_t page, uint32_t offset,
122 const void *data, size_t len);
123
136int at25xxx_set(const at25xxx_t *dev, uint32_t pos, uint8_t val, size_t len);
137
150int at25xxx_clear(const at25xxx_t *dev, uint32_t pos, size_t len);
151
152#ifdef __cplusplus
153}
154#endif
int at25xxx_clear(const at25xxx_t *dev, uint32_t pos, size_t len)
Set len bytes from position pos to 0.
int at25xxx_read(const at25xxx_t *dev, uint32_t pos, void *data, size_t len)
Sequentially read len bytes from a given position pos.
int at25xxx_write_page(const at25xxx_t *dev, uint32_t page, uint32_t offset, const void *data, size_t len)
Sequentially write len bytes to a given page.
int at25xxx_set(const at25xxx_t *dev, uint32_t pos, uint8_t val, size_t len)
Set len bytes from a given position pos to the value val.
int at25xxx_init(at25xxx_t *dev, const at25xxx_params_t *params)
Initialize an AT25XXX device handle with AT25XXX parameters.
int at25xxx_write(const at25xxx_t *dev, uint32_t pos, const void *data, size_t len)
Sequentially write len bytes from a given position pos.
uint8_t at25xxx_read_byte(const at25xxx_t *dev, uint32_t pos)
Read a byte at a given position pos.
void at25xxx_write_byte(const at25xxx_t *dev, uint32_t pos, uint8_t data)
Write a byte at a given position pos.
spi_clk_t
Definition periph_cpu.h:348
Low-level GPIO peripheral driver interface definitions.
gpio_t spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
Definition spi.h:157
Low-level SPI peripheral driver interface definition.
struct holding all params needed for device initialization
Definition at25xxx.h:35
spi_cs_t cs_pin
GPIO pin connected to chip select.
Definition at25xxx.h:38
spi_clk_t spi_clk
SPI clock speed to use.
Definition at25xxx.h:37
uint16_t page_size
Page Size of the EEPROM in bytes.
Definition at25xxx.h:42
gpio_t wp_pin
GPIO pin connected to the write-protect pin.
Definition at25xxx.h:39
gpio_t hold_pin
GPIO pin connected to the hold pin.
Definition at25xxx.h:40
uint32_t size
Size of the EEPROM in bytes.
Definition at25xxx.h:41
spi_t spi
SPI bus the device is connected to.
Definition at25xxx.h:36
struct that represents an AT25XXX device
Definition at25xxx.h:48
at25xxx_params_t params
parameters
Definition at25xxx.h:49