Blame view

RIOT/drivers/kw2xrf/include/kw2xrf_spi.h 2.93 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
  /*
   * Copyright (C) 2015 PHYTEC Messtechnik GmbH
   *
   * 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_kw2xrf
   * @{
   * @file
   * @brief       Definition of KW2XRF SPI functions
   *
   * @author      Johann Fischer <j.fischer@phytec.de>
   */
  #ifndef KW2XRF_SPI_H
  #define KW2XRF_SPI_H
  
  #include <stdio.h>
  #include "board.h"
  #include "cpu.h"
  #include "periph/spi.h"
  #include "periph_conf.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /**
   * @brief SPI interface initialization
   * @param[in] spi           SPI bus the device is connected to
   * @param[in] spi_speed     SPI speed to use
   * @param[in] cs_pin        GPIO pin connected to chip select
   *
   * @return 0 on success
   * @return -1 on error
   */
  int kw2xrf_spi_init(spi_t spi, spi_speed_t spi_speed,
                      gpio_t cs_pin);
  
  /**
   * @brief Writes a byte to the kw2xrf register.
   *
   * @param[in] addr Address of the register to write.
   * @param[in] value The value to write in the register.
   */
  void kw2xrf_write_dreg(uint8_t addr, uint8_t value);
  
  /**
   * @brief Reads a byte from the kw2xrf register.
   *
   * @param[in] addr Address of the register to read.
   * @return Value of the register.
   */
  uint8_t kw2xrf_read_dreg(uint8_t addr);
  
  /**
   * @brief Writes to  a byte from the kw2xrf indirect register.
   *
   * @param[in] addr Address of the register to write into.
   * @param[in] value Value that shall be written.
   */
  void kw2xrf_write_ireg(uint8_t addr, uint8_t value);
  
  /**
   * @brief Reads a byte from the kw2xrf indirect register.
   *
   * @param[in] addr Address of the register to read.
   *
   * @return value in the register
   */
  uint8_t kw2xrf_read_ireg(uint8_t addr);
  
  /**
   * @brief Writes to kw2xrf indirect registers.
   *
   * @param[in] addr Address of the register to write into.
   * @param[in] buf Value that shall be written.
   * @param[in] length Length of the register.
   */
  void kw2xrf_write_iregs(uint8_t addr, uint8_t *buf, uint8_t length);
  
  /**
   * @brief Reads a byte from the kw2xrf indirect register.
   *
   * @param[in] addr Address of the register to read.
   * @param[in] buf Buffer, where the content of the reg shall be written to.
   * @param[in] length Length of the register.
   */
  void kw2xrf_read_iregs(uint8_t addr, uint8_t *buf, uint8_t length);
  
  /**
   * @brief Writes multiple bytes to the kw2xrf fifo.
   *
   * @param[in] data A buffer with the value to write to the fifo.
   * @param[in] data_length The count of bytes which should be written.
   *
   * @return number of bytes written.
   */
  void kw2xrf_write_fifo(uint8_t *data, uint8_t data_length);
  
  /**
   * @brief Reads multiple bytes from the kw2xrf fifo.
   *
   * @param[out] data A buffer to store the value of the fifo.
   * @param[in] data_length The count of bytes which should be read.
   *
   * @return number of bytes read.
   */
  void kw2xrf_read_fifo(uint8_t *data, uint8_t data_length);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif
  /** @} */