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 be extended, to also support other
12 * devices, basing on HopeRfs rf69.
14 * The driver can also be extended, to support other modules of
15 * HopeRf with a similar interace - e. g. RFM69HCW, RFM12, RFM95, ...
16 * Copyright (C) 2016 Wolf-Entwicklungen
17 * Marcus Wolf <linux@wolf-entwicklungen.de>
23 #include <linux/types.h>
24 #include "rf69_enum.h"
26 /*---------------------------------------------------------------------------*/
33 /* IOCTL structs and commands */
36 * struct pi433_tx_config
37 * describes the configuration of the radio module for sending
44 * @tx_start_condition:
49 * If the contents of 'pi433_tx_config' ever change
50 * incompatibly, then the ioctl number (see define below) must change.
52 * NOTE: struct layout is the same in 64bit and 32bit userspace.
54 #define PI433_TX_CFG_IOCTL_NR 0
59 enum modulation modulation;
60 enum mod_shaping mod_shaping;
64 enum tx_start_condition tx_start_condition;
69 enum option_on_off enable_preamble;
70 enum option_on_off enable_sync;
71 enum option_on_off enable_length_byte;
72 enum option_on_off enable_address_byte;
73 enum option_on_off enable_crc;
75 __u16 preamble_length;
77 __u8 fixed_message_length;
84 * struct pi433_rx_config
85 * describes the configuration of the radio module for sending
92 * @tx_start_condition:
97 * If the contents of 'pi433_rx_config' ever change
98 * incompatibly, then the ioctl number (see define below) must change
100 * NOTE: struct layout is the same in 64bit and 32bit userspace.
102 #define PI433_RX_CFG_IOCTL_NR 1
103 struct pi433_rx_cfg {
108 enum modulation modulation;
111 enum threshold_decrement threshold_decrement;
112 enum antenna_impedance antenna_impedance;
113 enum lna_gain lna_gain;
114 enum mantisse bw_mantisse; /* normal: 0x50 */
115 __u8 bw_exponent; /* during AFC: 0x8b */
119 enum option_on_off enable_sync;
121 /* should be used in combination with sync, only */
122 enum option_on_off enable_length_byte;
124 /* operational with sync, only */
125 enum address_filtering enable_address_filtering;
127 /* only operational, if sync on and fixed length or length byte is used */
128 enum option_on_off enable_crc;
131 __u8 fixed_message_length;
134 __u8 sync_pattern[8];
136 __u8 broadcast_address;
139 #define PI433_IOC_MAGIC 'r'
141 #define PI433_IOC_RD_TX_CFG \
142 _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
143 #define PI433_IOC_WR_TX_CFG \
144 _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
146 #define PI433_IOC_RD_RX_CFG \
147 _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
148 #define PI433_IOC_WR_RX_CFG \
149 _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])