linux/drivers/staging/pi433/pi433_if.h
<<
>>
Prefs
   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
  28enum 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
  55struct 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
 103struct 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        enum option_on_off      enable_length_byte;       /* should be used in combination with sync, only */
 121        enum address_filtering  enable_address_filtering; /* operational with sync, only */
 122        enum option_on_off      enable_crc;               /* only operational, if sync on and fixed length or length byte is used */
 123
 124        __u8                    sync_length;
 125        __u8                    fixed_message_length;
 126        __u32                   bytes_to_drop;
 127
 128        __u8                    sync_pattern[8];
 129        __u8                    node_address;
 130        __u8                    broadcast_address;
 131};
 132
 133#define PI433_IOC_MAGIC                 'r'
 134
 135#define PI433_IOC_RD_TX_CFG     _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
 136#define PI433_IOC_WR_TX_CFG     _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)])
 137
 138#define PI433_IOC_RD_RX_CFG     _IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
 139#define PI433_IOC_WR_RX_CFG     _IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, char[sizeof(struct pi433_rx_cfg)])
 140
 141#endif /* PI433_H */
 142