1 /* SPDX-License-Identifier: GPL-2.0+ */
5 * userspace interface for pi433 radio module
7 * Pi433 is a 433MHz radio module for the Raspberry Pi.
8 * It is based on the HopeRf Module RFM69CW. Therefore, inside of this
9 * driver you'll find an abstraction of the rf69 chip.
11 * If needed this driver could also be extended to support other
12 * devices based on HopeRf rf69 as well as HopeRf modules with a similar
13 * interface such as RFM69HCW, RFM12, RFM95 and so on.
15 * Copyright (C) 2016 Wolf-Entwicklungen
16 * Marcus Wolf <linux@wolf-entwicklungen.de>
22 #include <linux/types.h>
23 #include "rf69_enum.h"
25 /*---------------------------------------------------------------------------*/
32 /* IOCTL structs and commands */
36 * describes the configuration of the radio module for sending data
43 * @tx_start_condition:
48 * If the contents of 'pi433_tx_cfg' ever change
49 * incompatibly, then the ioctl number (see define below) must change.
51 * NOTE: struct layout is the same in 64bit and 32bit userspace.
53 #define PI433_TX_CFG_IOCTL_NR 0
58 enum modulation modulation;
59 enum mod_shaping mod_shaping;
63 enum tx_start_condition tx_start_condition;
68 enum option_on_off enable_preamble;
69 enum option_on_off enable_sync;
70 enum option_on_off enable_length_byte;
71 enum option_on_off enable_address_byte;
72 enum option_on_off enable_crc;
74 __u16 preamble_length;
76 __u8 fixed_message_length;
84 * describes the configuration of the radio module for receiving data
91 * @tx_start_condition:
96 * If the contents of 'pi433_rx_cfg' ever change
97 * incompatibly, then the ioctl number (see define below) must change
99 * NOTE: struct layout is the same in 64bit and 32bit userspace.
101 #define PI433_RX_CFG_IOCTL_NR 1
102 struct pi433_rx_cfg {
107 enum modulation modulation;
110 enum threshold_decrement threshold_decrement;
111 enum antenna_impedance antenna_impedance;
112 enum lna_gain lna_gain;
113 enum mantisse bw_mantisse; /* normal: 0x50 */
114 __u8 bw_exponent; /* during AFC: 0x8b */
118 enum option_on_off enable_sync;
120 /* should be used in combination with sync, only */
121 enum option_on_off enable_length_byte;
123 /* operational with sync, only */
124 enum address_filtering enable_address_filtering;
126 /* only operational, if sync on and fixed length or length byte is used */
127 enum option_on_off enable_crc;
130 __u8 fixed_message_length;
133 __u8 sync_pattern[8];
135 __u8 broadcast_address;
138 #define PI433_IOC_MAGIC 'r'
140 #define PI433_IOC_RD_TX_CFG \
141 _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
142 #define PI433_IOC_WR_TX_CFG \
143 _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
145 #define PI433_IOC_RD_RX_CFG \
146 _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
147 #define PI433_IOC_WR_RX_CFG \
148 _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])