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
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 /*---------------------------------------------------------------------------*/
42 /* IOCTL structs and commands */
45 * struct pi433_tx_config - describes the configuration of the radio module for sending
52 * @tx_start_condition:
57 * If the contents of 'pi433_tx_config' ever change
58 * incompatibly, then the ioctl number (see define below) must change.
60 * NOTE: struct layout is the same in 64bit and 32bit userspace.
62 #define PI433_TX_CFG_IOCTL_NR 0
67 enum modulation modulation;
68 enum mod_shaping mod_shaping;
72 enum tx_start_condition tx_start_condition;
77 enum option_on_off enable_preamble;
78 enum option_on_off enable_sync;
79 enum option_on_off enable_length_byte;
80 enum option_on_off enable_address_byte;
81 enum option_on_off enable_crc;
83 __u16 preamble_length;
85 __u8 fixed_message_length;
92 * struct pi433_rx_config - describes the configuration of the radio module for sending
99 * @tx_start_condition:
104 * If the contents of 'pi433_rx_config' ever change
105 * incompatibly, then the ioctl number (see define below) must change
107 * NOTE: struct layout is the same in 64bit and 32bit userspace.
109 #define PI433_RX_CFG_IOCTL_NR 1
110 struct pi433_rx_cfg {
115 enum modulation modulation;
118 enum threshold_decrement threshold_decrement;
119 enum antenna_impedance antenna_impedance;
120 enum lna_gain lna_gain;
121 enum mantisse bw_mantisse; /* normal: 0x50 */
122 __u8 bw_exponent; /* during AFC: 0x8b */
126 enum option_on_off enable_sync;
127 enum option_on_off enable_length_byte; /* should be used in combination with sync, only */
128 enum address_filtering enable_address_filtering; /* operational with sync, only */
129 enum option_on_off enable_crc; /* only operational, if sync on and fixed length or length byte is used */
132 __u8 fixed_message_length;
135 __u8 sync_pattern[8];
137 __u8 broadcast_address;
140 #define PI433_IOC_MAGIC 'r'
142 #define PI433_IOC_RD_TX_CFG _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
143 #define PI433_IOC_WR_TX_CFG _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
145 #define PI433_IOC_RD_RX_CFG _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
146 #define PI433_IOC_WR_RX_CFG _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])