Blame view

RIOT/drivers/include/nvram-spi.h 1.47 KB
fb11e647   vrobic   reseau statique a...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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     drivers_nvram
   * @{
   *
   * @file
   *
   * @brief       Device interface for various SPI connected NVRAM.
   *
   * Tested on:
   * - Cypress/Ramtron FM25L04B.
   *
   * @author      Joakim Nohlgård <joakim.nohlgard@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_ */
  /** @} */