Loading...
Searching...
No Matches
at25xxx.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 ML!PA Consulting GmbH
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
23#ifndef AT25XXX_H
24#define AT25XXX_H
25
26#include <stdint.h>
27#include <stdbool.h>
28
29#include "periph/spi.h"
30#include "periph/gpio.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
39typedef struct {
40 spi_t spi;
43 gpio_t wp_pin;
44 gpio_t hold_pin;
45 uint32_t size;
46 uint16_t page_size;
48
52typedef struct {
54} at25xxx_t;
55
65int at25xxx_init(at25xxx_t *dev, const at25xxx_params_t *params);
66
75uint8_t at25xxx_read_byte(const at25xxx_t *dev, uint32_t pos);
76
88int at25xxx_read(const at25xxx_t *dev, uint32_t pos, void *data, size_t len);
89
97void at25xxx_write_byte(const at25xxx_t *dev, uint32_t pos, uint8_t data);
98
110int at25xxx_write(const at25xxx_t *dev, uint32_t pos, const void *data, size_t len);
111
125int at25xxx_write_page(const at25xxx_t *dev, uint32_t page, uint32_t offset,
126 const void *data, size_t len);
127
140int at25xxx_set(const at25xxx_t *dev, uint32_t pos, uint8_t val, size_t len);
141
154int at25xxx_clear(const at25xxx_t *dev, uint32_t pos, size_t len);
155
156#ifdef __cplusplus
157}
158#endif
159
160#endif /* AT25XXX_H */
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:352
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:135
Low-level SPI peripheral driver interface definition.
struct holding all params needed for device initialization
Definition at25xxx.h:39
spi_cs_t cs_pin
GPIO pin connected to chip select.
Definition at25xxx.h:42
spi_clk_t spi_clk
SPI clock speed to use.
Definition at25xxx.h:41
uint16_t page_size
Page Size of the EEPROM in bytes.
Definition at25xxx.h:46
gpio_t wp_pin
GPIO pin connected to the write-protect pin.
Definition at25xxx.h:43
gpio_t hold_pin
GPIO pin connected to the hold pin.
Definition at25xxx.h:44
uint32_t size
Size of the EEPROM in bytes.
Definition at25xxx.h:45
spi_t spi
SPI bus the device is connected to.
Definition at25xxx.h:40
struct that represents an AT25XXX device
Definition at25xxx.h:52
at25xxx_params_t params
parameters
Definition at25xxx.h:53