1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * include/linux/TODO 4 * 5 * userspace interface for pi433 radio module 6 * 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. 10 * 11 * If needed, this driver could be extended, to also support other 12 * devices, basing on HopeRfs rf69. 13 * 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> 18 */ 19 20 #ifndef PI433_H 21 #define PI433_H 22 23 #include <linux/types.h> 24 #include "rf69_enum.h" 25 26 /*---------------------------------------------------------------------------*/ 27 28 enum option_on_off { 29 OPTION_OFF, 30 OPTION_ON 31 }; 32 33 /* IOCTL structs and commands */ 34 35 /** 36 * struct pi433_tx_config 37 * describes the configuration of the radio module for sending 38 * @frequency: 39 * @bit_rate: 40 * @modulation: 41 * @data_mode: 42 * @preamble_length: 43 * @sync_pattern: 44 * @tx_start_condition: 45 * @payload_length: 46 * @repetitions: 47 * 48 * ATTENTION: 49 * If the contents of 'pi433_tx_config' ever change 50 * incompatibly, then the ioctl number (see define below) must change. 51 * 52 * NOTE: struct layout is the same in 64bit and 32bit userspace. 53 */ 54 #define PI433_TX_CFG_IOCTL_NR 0 55 struct pi433_tx_cfg { 56 __u32 frequency; 57 __u16 bit_rate; 58 __u32 dev_frequency; 59 enum modulation modulation; 60 enum mod_shaping mod_shaping; 61 62 enum pa_ramp pa_ramp; 63 64 enum tx_start_condition tx_start_condition; 65 66 __u16 repetitions; 67 68 /* packet format */ 69 enum option_on_off enable_preamble; 70 enum option_on_off enable_sync; 71 enum option_on_off enable_length_byte; 72 enum option_on_off enable_address_byte; 73 enum option_on_off enable_crc; 74 75 __u16 preamble_length; 76 __u8 sync_length; 77 __u8 fixed_message_length; 78 79 __u8 sync_pattern[8]; 80 __u8 address_byte; 81 }; 82 83 /** 84 * struct pi433_rx_config 85 * describes the configuration of the radio module for sending 86 * @frequency: 87 * @bit_rate: 88 * @modulation: 89 * @data_mode: 90 * @preamble_length: 91 * @sync_pattern: 92 * @tx_start_condition: 93 * @payload_length: 94 * @repetitions: 95 * 96 * ATTENTION: 97 * If the contents of 'pi433_rx_config' ever change 98 * incompatibly, then the ioctl number (see define below) must change 99 * 100 * NOTE: struct layout is the same in 64bit and 32bit userspace. 101 */ 102 #define PI433_RX_CFG_IOCTL_NR 1 103 struct pi433_rx_cfg { 104 __u32 frequency; 105 __u16 bit_rate; 106 __u32 dev_frequency; 107 108 enum modulation modulation; 109 110 __u8 rssi_threshold; 111 enum threshold_decrement threshold_decrement; 112 enum antenna_impedance antenna_impedance; 113 enum lna_gain lna_gain; 114 enum mantisse bw_mantisse; /* normal: 0x50 */ 115 __u8 bw_exponent; /* during AFC: 0x8b */ 116 enum dagc dagc; 117 118 /* packet format */ 119 enum option_on_off enable_sync; 120 121 /* should be used in combination with sync, only */ 122 enum option_on_off enable_length_byte; 123 124 /* operational with sync, only */ 125 enum address_filtering enable_address_filtering; 126 127 /* only operational, if sync on and fixed length or length byte is used */ 128 enum option_on_off enable_crc; 129 130 __u8 sync_length; 131 __u8 fixed_message_length; 132 __u32 bytes_to_drop; 133 134 __u8 sync_pattern[8]; 135 __u8 node_address; 136 __u8 broadcast_address; 137 }; 138 139 #define PI433_IOC_MAGIC 'r' 140 141 #define PI433_IOC_RD_TX_CFG \ 142 _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)]) 143 #define PI433_IOC_WR_TX_CFG \ 144 _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)]) 145 146 #define PI433_IOC_RD_RX_CFG \ 147 _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)]) 148 #define PI433_IOC_WR_RX_CFG \ 149 _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)]) 150 151 #endif /* PI433_H */ 152