kw2xrf_spi.h
3.83 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* 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] dev device descriptor
*
* @return 0 on success
* @return -1 on error
*/
int kw2xrf_spi_init(kw2xrf_t *dev);
/**
* @brief Writes a byte to the kw2xrf register.
*
* @param[in] dev device descriptor
* @param[in] addr Address of the register to write.
* @param[in] value The value to write in the register.
*/
void kw2xrf_write_dreg(kw2xrf_t *dev, uint8_t addr, uint8_t value);
/**
* @brief Reads a byte from the kw2xrf register.
*
* @param[in] dev device descriptor
* @param[in] addr Address of the register to read.
* @return Value of the register.
*/
uint8_t kw2xrf_read_dreg(kw2xrf_t *dev, uint8_t addr);
/**
* @brief Writes to kw2xrf direct registers.
*
* @param[in] dev device descriptor
* @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_dregs(kw2xrf_t *dev, uint8_t addr, uint8_t *buf, uint8_t length);
/**
* @brief Reads a byte from the kw2xrf indirect register.
*
* @param[in] dev device descriptor
* @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_dregs(kw2xrf_t *dev, uint8_t addr, uint8_t *buf, uint8_t length);
/**
* @brief Writes to a byte from the kw2xrf indirect register.
*
* @param[in] dev device descriptor
* @param[in] addr Address of the register to write into.
* @param[in] value Value that shall be written.
*/
void kw2xrf_write_ireg(kw2xrf_t *dev, uint8_t addr, uint8_t value);
/**
* @brief Reads a byte from the kw2xrf indirect register.
*
* @param[in] dev device descriptor
* @param[in] addr Address of the register to read.
*
* @return value in the register
*/
uint8_t kw2xrf_read_ireg(kw2xrf_t *dev, uint8_t addr);
/**
* @brief Writes to kw2xrf indirect registers.
*
* @param[in] dev device descriptor
* @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(kw2xrf_t *dev, uint8_t addr, uint8_t *buf, uint8_t length);
/**
* @brief Reads a byte from the kw2xrf indirect register.
*
* @param[in] dev device descriptor
* @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(kw2xrf_t *dev, uint8_t addr, uint8_t *buf, uint8_t length);
/**
* @brief Writes multiple bytes to the kw2xrf fifo.
*
* @param[in] dev device descriptor
* @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(kw2xrf_t *dev, uint8_t *data, uint8_t data_length);
/**
* @brief Reads multiple bytes from the kw2xrf fifo.
*
* @param[in] dev device descriptor
* @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(kw2xrf_t *dev, uint8_t *data, uint8_t data_length);
#ifdef __cplusplus
}
#endif
#endif /* KW2XRF_SPI_H */
/** @} */