1 /* 2 * include/linux/TODO 3 * 4 * userspace interface for pi433 radio module 5 * 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. 9 * 10 * If needed, this driver could be extended, to also support other 11 * devices, basing on HopeRfs rf69. 12 * 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> 17 * 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. 22 * 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. 27 */ 28 29 #ifndef PI433_H 30 #define PI433_H 31 32 #include <linux/types.h> 33 #include "rf69_enum.h" 34 35 /*---------------------------------------------------------------------------*/ 36 37 38 /*---------------------------------------------------------------------------*/ 39 40 /* IOCTL structs and commands */ 41 42 /** 43 * struct pi433_tx_config - describes the configuration of the radio module for sending 44 * @frequency: 45 * @bit_rate: 46 * @modulation: 47 * @data_mode: 48 * @preamble_length: 49 * @sync_pattern: 50 * @tx_start_condition: 51 * @payload_length: 52 * @repetitions: 53 * 54 * ATTENTION: 55 * If the contents of 'pi433_tx_config' ever change 56 * incompatibly, then the ioctl number (see define below) must change. 57 * 58 * NOTE: struct layout is the same in 64bit and 32bit userspace. 59 */ 60 #define PI433_TX_CFG_IOCTL_NR 0 61 struct pi433_tx_cfg 62 { 63 __u32 frequency; 64 __u16 bit_rate; 65 __u32 dev_frequency; 66 enum modulation modulation; 67 enum modShaping modShaping; 68 69 enum paRamp pa_ramp; 70 71 enum txStartCondition tx_start_condition; 72 73 __u16 repetitions; 74 75 76 /* packet format */ 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; 82 83 __u16 preamble_length; 84 __u8 sync_length; 85 __u8 fixed_message_length; 86 87 __u8 sync_pattern[8]; 88 __u8 address_byte; 89 }; 90 91 92 /** 93 * struct pi433_rx_config - describes the configuration of the radio module for sending 94 * @frequency: 95 * @bit_rate: 96 * @modulation: 97 * @data_mode: 98 * @preamble_length: 99 * @sync_pattern: 100 * @tx_start_condition: 101 * @payload_length: 102 * @repetitions: 103 * 104 * ATTENTION: 105 * If the contents of 'pi433_rx_config' ever change 106 * incompatibly, then the ioctl number (see define below) must change 107 * 108 * NOTE: struct layout is the same in 64bit and 32bit userspace. 109 */ 110 #define PI433_RX_CFG_IOCTL_NR 1 111 struct pi433_rx_cfg { 112 __u32 frequency; 113 __u16 bit_rate; 114 __u32 dev_frequency; 115 116 enum modulation modulation; 117 118 __u8 rssi_threshold; 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 */ 124 enum dagc dagc; 125 126 127 128 /* packet format */ 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 */ 133 134 __u8 sync_length; 135 __u8 fixed_message_length; 136 __u32 bytes_to_drop; 137 138 __u8 sync_pattern[8]; 139 __u8 node_address; 140 __u8 broadcast_address; 141 }; 142 143 144 #define PI433_IOC_MAGIC 'r' 145 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)]) 148 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)]) 151 152 #endif /* PI433_H */ 153