mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 10:12:45 +01:00
nvram: Add generic SPI connected NVRAM interface.
This commit is contained in:
parent
a982af330c
commit
db9d3ddf48
66
drivers/include/nvram-spi.h
Normal file
66
drivers/include/nvram-spi.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Eistec AB
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License v2.1. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup nvram
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*
|
||||
* @brief Device interface for various SPI connected NVRAM.
|
||||
*
|
||||
* Tested on:
|
||||
* - Cypress/Ramtron FM25L04B.
|
||||
*
|
||||
* @author Joakim Gebart <joakim.gebart@eistec.se>
|
||||
*/
|
||||
|
||||
#ifndef DRIVERS_NVRAM_SPI_H_
|
||||
#define DRIVERS_NVRAM_SPI_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nvram.h"
|
||||
#include "periph/spi.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bus parameters for SPI NVRAM.
|
||||
*/
|
||||
typedef struct nvram_spi_params {
|
||||
/** @brief RIOT SPI device */
|
||||
spi_t spi;
|
||||
/** @brief Chip select pin */
|
||||
gpio_t cs;
|
||||
/** @brief Number of address bytes following each read/write command. */
|
||||
uint8_t address_count;
|
||||
} nvram_spi_params_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize an nvram_t structure with SPI settings.
|
||||
*
|
||||
* This will also initialize the CS pin as a GPIO output, without pull resistors.
|
||||
*
|
||||
* @param[out] dev Pointer to NVRAM device descriptor
|
||||
* @param[out] spi_params Pointer to SPI settings
|
||||
* @param[in] size Device capacity
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return <0 on errors
|
||||
*/
|
||||
int nvram_spi_init(nvram_t *dev, nvram_spi_params_t *spi_params, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DRIVERS_NVRAM_SPI_H_ */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user