1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * userspace interface for pi433 radio module
5 * Pi433 is a 433MHz radio module for the Raspberry Pi.
6 * It is based on the HopeRf Module RFM69CW. Therefore, inside of this
7 * driver you'll find an abstraction of the rf69 chip.
9 * If needed this driver could also be extended to support other
10 * devices based on HopeRf rf69 as well as HopeRf modules with a similar
11 * interface such as RFM69HCW, RFM12, RFM95 and so on.
13 * Copyright (C) 2016 Wolf-Entwicklungen
20 #include <linux/types.h>
21 #include "rf69_enum.h"
23 /*---------------------------------------------------------------------------*/
30 /* IOCTL structs and commands */
34 * describes the configuration of the radio module for sending data
41 * @tx_start_condition:
46 * If the contents of 'pi433_tx_cfg' ever change
47 * incompatibly, then the ioctl number (see define below) must change.
49 * NOTE: struct layout is the same in 64bit and 32bit userspace.
51 #define PI433_TX_CFG_IOCTL_NR 0
56 enum modulation modulation;
57 enum mod_shaping mod_shaping;
61 enum tx_start_condition tx_start_condition;
66 enum option_on_off enable_preamble;
67 enum option_on_off enable_sync;
68 enum option_on_off enable_length_byte;
69 enum option_on_off enable_address_byte;
70 enum option_on_off enable_crc;
72 __u16 preamble_length;
74 __u8 fixed_message_length;
82 * describes the configuration of the radio module for receiving data
89 * @tx_start_condition:
94 * If the contents of 'pi433_rx_cfg' ever change
95 * incompatibly, then the ioctl number (see define below) must change
97 * NOTE: struct layout is the same in 64bit and 32bit userspace.
99 #define PI433_RX_CFG_IOCTL_NR 1
100 struct pi433_rx_cfg {
105 enum modulation modulation;
108 enum threshold_decrement threshold_decrement;
109 enum antenna_impedance antenna_impedance;
110 enum lna_gain lna_gain;
111 enum mantisse bw_mantisse; /* normal: 0x50 */
112 __u8 bw_exponent; /* during AFC: 0x8b */
116 enum option_on_off enable_sync;
118 /* should be used in combination with sync, only */
119 enum option_on_off enable_length_byte;
121 /* operational with sync, only */
122 enum address_filtering enable_address_filtering;
124 /* only operational, if sync on and fixed length or length byte is used */
125 enum option_on_off enable_crc;
128 __u8 fixed_message_length;
131 __u8 sync_pattern[8];
133 __u8 broadcast_address;
136 #define PI433_IOC_MAGIC 'r'
138 #define PI433_IOC_RD_TX_CFG \
139 _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
140 #define PI433_IOC_WR_TX_CFG \
141 _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
143 #define PI433_IOC_RD_RX_CFG \
144 _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
145 #define PI433_IOC_WR_RX_CFG \
146 _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])