px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_nrf905.h
1#ifndef __PX_NRF905_H__
2#define __PX_NRF905_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2013 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_nrf905.h : Nordic Semiconductor nRF905 Transceiver driver
16 Author(s): Pieter Conradie
17 Creation Date: 2013-07-28
18
19============================================================================= */
20
21/**
22 * @ingroup DEVICES_COMMS
23 * @defgroup PX_NRF905 px_nrf905.h : Nordic Semiconductor nRF905 RF Transceiver driver
24 *
25 * File(s):
26 * - devices/comms/inc/px_nrf905.h
27 * - devices/comms/src/px_nrf905.c
28 *
29 * Reference:
30 * - [Nordic nRF905] (https://www.nordicsemi.com/eng/Products/Sub-1-GHz-RF/nRF905) datasheet
31 *
32 * @{
33 */
34
35/* _____STANDARD INCLUDES____________________________________________________ */
36
37/* _____PROJECT INCLUDES_____________________________________________________ */
38#include "px_defs.h"
39#include "px_spi.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44/* _____DEFINITIONS__________________________________________________________ */
45/// Maximum SPI Clock rate
46#define PX_NRF905_MAX_SPI_CLOCK_HZ 10000000ul
47/// SPI Clock / Data phase
48#define PX_NRF905_SPI_MODE PX_SPI_MODE0
49/// SPI Data order
50#define PX_NRF905_SPI_DATA_ORDER PX_SPI_DATA_ORDER_MSB
51
52/// Size of each data block
53#define PX_NRF905_MIN_PAYLOAD_SIZE 1
54#define PX_NRF905_MAX_PAYLOAD_SIZE 32
55
56/// @name RF - Configuration register settings
57/// @{
58#define PX_NRF905_HFREQ_PLL_433MHZ 0 ///< 433 MHz
59#define PX_NRF905_HFREQ_PLL_868_915MHZ 1 ///< 868 / 915 MHz
60
61#define PX_NRF905_PA_PWR_M10DBM 0 ///< -10 dBm
62#define PX_NRF905_PA_PWR_M2DBM 1 ///< -2 dBm
63#define PX_NRF905_PA_PWR_P6DBM 2 ///< +6 dBm
64#define PX_NRF905_PA_PWR_P10DBM 3 ///< +10 dBm
65
66#define PX_NRF905_RX_RED_PWR_NORMAL 0 ///< Normal operation
67#define PX_NRF905_RX_RED_PWR_ACTIVE 1 ///< Reduced power
68
69#define PX_NRF905_AUTO_RETRAN_NO 0 ///< No retransmission
70#define PX_NRF905_AUTO_RETRAN_YES 1 ///< Retransmission of data packet
71
72#define PX_NRF905_UP_CLK_FREQ_4MHZ 0 ///< 4 MHz
73#define PX_NRF905_UP_CLK_FREQ_2MHZ 1 ///< 2 MHz
74#define PX_NRF905_UP_CLK_FREQ_1MHZ 2 ///< 1 MHz
75#define PX_NRF905_UP_CLK_FREQ_500KHZ 3 ///< 500 kHz
76
77#define PX_NRF905_UP_CLK_EN_NO 0 ///< No external clock signal available
78#define PX_NRF905_UP_CLK_EN_YES 1 ///< External clock signal enabled
79
80#define PX_NRF905_XOF_4MHZ 0 ///< 4 MHz
81#define PX_NRF905_XOF_8MHZ 1 ///< 8 MHz
82#define PX_NRF905_XOF_12MHZ 2 ///< 12 MHz
83#define PX_NRF905_XOF_16MHZ 3 ///< 16 MHz
84#define PX_NRF905_XOF_20MHZ 4 ///< 20 MHz
85
86#define PX_NRF905_CRC_EN_NO 0 ///< Disable CRC check
87#define PX_NRF905_CRC_EN_YES 1 ///< Enable CRC check
88
89#define PX_NRF905_CRC_MODE_8BITS 0 ///< 8-bit CRC check
90#define PX_NRF905_CRC_MODE_16BITS 1 ///< 16-bit CRC check
91/// @}
92
93/* _____TYPE DEFINITIONS_____________________________________________________ */
94/// NRF905 Configuration register map
95typedef struct
96{
97 // Byte 0
98 uint8_t ch_no_7_0; ///< Set center frequency (together with HFREQ_PLL)
99
100 // Byte 1
101 uint8_t ch_no_8 : 1; ///< Set center frequency (together with HFREQ_PLL)
102 uint8_t hfreq_pll : 1; ///< Set PLL in 433 or 868/915MHz mode
103 uint8_t pa_pwr : 2; ///< Output power
104 uint8_t rx_red_pwr : 1; ///< Reduce current in RX mode by 1.6mA (sensitivity also is reduced)
105 uint8_t auto_retran : 1; ///< Retransmit contents in TX register if TRX_CE and TXEN are high
106 uint8_t reserved1 : 2;
107
108 // Byte 2
109 uint8_t rx_afw : 3; ///< RX-address width
110 uint8_t reserved2 : 1;
111 uint8_t tx_afw : 3; ///< TX-address width
112 uint8_t reserved3 : 1;
113
114 // Byte 3
115 uint8_t rx_pw : 6; ///< RX-payload width
116 uint8_t reserved4 : 2;
117
118 // Byte 4
119 uint8_t tx_pw : 6; ///< TX-payload width
120 uint8_t reserved5 : 2;
121
122 // Byte 5
123 uint8_t rx_adr_0; ///< RX address identity byte 0
124 uint8_t rx_adr_1; ///< RX address identity byte 1
125 uint8_t rx_adr_2; ///< RX address identity byte 2
126 uint8_t rx_adr_3; ///< RX address identity byte 3
127
128 // Byte 9
129 uint8_t up_clk_freq : 2; ///< Output clock frequency
130 uint8_t up_clk_en : 1; ///< Output clock enable
131 uint8_t xof : 3; ///< Crystal oscillator frequency
132 uint8_t px_crc_en : 1; ///< CRC – check enable
133 uint8_t px_crc_mode : 1; ///< CRC – mode
135
136/* _____GLOBAL VARIABLES_____________________________________________________ */
137
138/* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */
139void px_nrf905_init (px_spi_handle_t * handle);
140uint8_t px_nrf905_cfg_wr (const px_nrf905_cfg_reg_t * cfg, uint8_t start_byte);
141uint8_t px_nrf905_cfg_rd (px_nrf905_cfg_reg_t * cfg, uint8_t start_byte);
142
143uint8_t px_nrf905_tx_payload_wr(const void * data, uint8_t nr_of_bytes);
144uint8_t px_nrf905_tx_payload_rd(void * data, uint8_t nr_of_bytes);
145uint8_t px_nrf905_rx_payload_rd(void * data, uint8_t nr_of_bytes);
146
147uint8_t px_nrf905_channel_cfg (uint16_t channel_no, uint8_t hfreq_pll, uint8_t pa_pwr);
148
149/* _____MACROS_______________________________________________________________ */
150
151#ifdef __cplusplus
152}
153#endif
154
155/// @}
156#endif
uint8_t rx_pw
RX-payload width.
Definition: px_nrf905.h:115
uint8_t rx_adr_0
RX address identity byte 0.
Definition: px_nrf905.h:123
uint8_t tx_pw
TX-payload width.
Definition: px_nrf905.h:119
uint8_t rx_adr_2
RX address identity byte 2.
Definition: px_nrf905.h:125
uint8_t up_clk_freq
Output clock frequency.
Definition: px_nrf905.h:129
uint8_t xof
Crystal oscillator frequency.
Definition: px_nrf905.h:131
uint8_t rx_adr_1
RX address identity byte 1.
Definition: px_nrf905.h:124
uint8_t ch_no_8
Set center frequency (together with HFREQ_PLL)
Definition: px_nrf905.h:101
uint8_t auto_retran
Retransmit contents in TX register if TRX_CE and TXEN are high.
Definition: px_nrf905.h:105
uint8_t up_clk_en
Output clock enable.
Definition: px_nrf905.h:130
uint8_t rx_adr_3
RX address identity byte 3.
Definition: px_nrf905.h:126
uint8_t rx_red_pwr
Reduce current in RX mode by 1.6mA (sensitivity also is reduced)
Definition: px_nrf905.h:104
uint8_t pa_pwr
Output power.
Definition: px_nrf905.h:103
uint8_t tx_afw
TX-address width.
Definition: px_nrf905.h:111
uint8_t ch_no_7_0
Set center frequency (together with HFREQ_PLL)
Definition: px_nrf905.h:98
uint8_t rx_afw
RX-address width.
Definition: px_nrf905.h:109
uint8_t px_crc_en
CRC – check enable.
Definition: px_nrf905.h:132
uint8_t px_crc_mode
CRC – mode.
Definition: px_nrf905.h:133
uint8_t hfreq_pll
Set PLL in 433 or 868/915MHz mode.
Definition: px_nrf905.h:102
NRF905 Configuration register map.
Definition: px_nrf905.h:96
Define SPI handle.
Definition: px_spi.h:126