4 * userspace interface for pi433 radio module
6 * Pi433 is a 433MHz radio module for the Raspberry Pi.
7 * It is based on the HopeRf Module RFM69CW. Therefore inside of this
8 * driver, you'll find an abstraction of the rf69 chip.
10 * If needed, this driver could be extended, to also support other
11 * devices, basing on HopeRfs rf69.
13 * The driver can also be extended, to support other modules of
14 * HopeRf with a similar interace - e. g. RFM69HCW, RFM12, RFM95, ...
15 * Copyright (C) 2016 Wolf-Entwicklungen
16 * Marcus Wolf <linux@wolf-entwicklungen.de>
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
32 #include <linux/types.h>
33 #include "rf69_enum.h"
35 /*---------------------------------------------------------------------------*/
38 /*---------------------------------------------------------------------------*/
40 /* IOCTL structs and commands */
43 * struct pi433_tx_config - describes the configuration of the radio module for sending
50 * @tx_start_condition:
55 * If the contents of 'pi433_tx_config' ever change
56 * incompatibly, then the ioctl number (see define below) must change.
58 * NOTE: struct layout is the same in 64bit and 32bit userspace.
60 #define PI433_TX_CFG_IOCTL_NR 0
66 enum modulation modulation;
67 enum modShaping modShaping;
71 enum txStartCondition tx_start_condition;
77 enum optionOnOff enable_preamble;
78 enum optionOnOff enable_sync;
79 enum optionOnOff enable_length_byte;
80 enum optionOnOff enable_address_byte;
81 enum optionOnOff enable_crc;
83 __u16 preamble_length;
85 __u8 fixed_message_length;
93 * struct pi433_rx_config - describes the configuration of the radio module for sending
100 * @tx_start_condition:
105 * If the contents of 'pi433_rx_config' ever change
106 * incompatibly, then the ioctl number (see define below) must change
108 * NOTE: struct layout is the same in 64bit and 32bit userspace.
110 #define PI433_RX_CFG_IOCTL_NR 1
111 struct pi433_rx_cfg {
116 enum modulation modulation;
119 enum thresholdDecrement thresholdDecrement;
120 enum antennaImpedance antenna_impedance;
121 enum lnaGain lna_gain;
122 enum mantisse bw_mantisse; /* normal: 0x50 */
123 __u8 bw_exponent; /* during AFC: 0x8b */
129 enum optionOnOff enable_sync;
130 enum optionOnOff enable_length_byte; /* should be used in combination with sync, only */
131 enum addressFiltering enable_address_filtering; /* operational with sync, only */
132 enum optionOnOff 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;
144 #define PI433_IOC_MAGIC 'r'
146 #define PI433_IOC_RD_TX_CFG _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
147 #define PI433_IOC_WR_TX_CFG _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
149 #define PI433_IOC_RD_RX_CFG _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
150 #define PI433_IOC_WR_RX_CFG _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])