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>
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
33 #include <linux/types.h>
34 #include "rf69_enum.h"
36 /*---------------------------------------------------------------------------*/
43 /* IOCTL structs and commands */
46 * struct pi433_tx_config
47 * describes the configuration of the radio module for sending
54 * @tx_start_condition:
59 * If the contents of 'pi433_tx_config' ever change
60 * incompatibly, then the ioctl number (see define below) must change.
62 * NOTE: struct layout is the same in 64bit and 32bit userspace.
64 #define PI433_TX_CFG_IOCTL_NR 0
69 enum modulation modulation;
70 enum mod_shaping mod_shaping;
74 enum tx_start_condition tx_start_condition;
79 enum option_on_off enable_preamble;
80 enum option_on_off enable_sync;
81 enum option_on_off enable_length_byte;
82 enum option_on_off enable_address_byte;
83 enum option_on_off enable_crc;
85 __u16 preamble_length;
87 __u8 fixed_message_length;
94 * struct pi433_rx_config
95 * describes the configuration of the radio module for sending
102 * @tx_start_condition:
107 * If the contents of 'pi433_rx_config' ever change
108 * incompatibly, then the ioctl number (see define below) must change
110 * NOTE: struct layout is the same in 64bit and 32bit userspace.
112 #define PI433_RX_CFG_IOCTL_NR 1
113 struct pi433_rx_cfg {
118 enum modulation modulation;
121 enum threshold_decrement threshold_decrement;
122 enum antenna_impedance antenna_impedance;
123 enum lna_gain lna_gain;
124 enum mantisse bw_mantisse; /* normal: 0x50 */
125 __u8 bw_exponent; /* during AFC: 0x8b */
129 enum option_on_off enable_sync;
130 enum option_on_off enable_length_byte; /* should be used in combination with sync, only */
131 enum address_filtering enable_address_filtering; /* operational with sync, only */
132 enum option_on_off enable_crc; /* only operational, if sync on and fixed length or length byte is used */
135 __u8 fixed_message_length;
138 __u8 sync_pattern[8];
140 __u8 broadcast_address;
143 #define PI433_IOC_MAGIC 'r'
145 #define PI433_IOC_RD_TX_CFG _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
146 #define PI433_IOC_WR_TX_CFG _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
148 #define PI433_IOC_RD_RX_CFG _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
149 #define PI433_IOC_WR_RX_CFG _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])