/**************************************************************************** * drivers/wireless/generic/si4463.h * * Copyright (C) 2017 Sebastien Lorquet. All rights reserved. * Author: Sebastien Lorquet * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ #ifndef __DRIVERS_WIRELESS_GENERIC_SI4463_H #define __DRIVERS_WIRELESS_GENERIC_SI4463_H #include #include #include #include /* A SI4463 device instance */ struct si4463_dev_s { struct genradio_dev_s genradio; /* The public device instance */ FAR struct spi_dev_s *spi; /* Underlying SPI bus */ int spiid; /* Device identifier within type SPIDEVTYPE_GENRADIO */ struct work_s irqwork; /* Interrupt continuation work queue support */ FAR const struct si4463_lower_s *lower; /* Low-level MCU-specific support */ uint32_t xtal; /* Frequency of the attached oscillator */ uint32_t realdev; /* Real value of deviation so it can be recomputed when the base freq changes */ uint8_t freq_set:1; /* Flag: Set to 1 if frequency is set */ uint8_t outdiv; /* VCO output divider backup */ }; /* Commands */ #define SI4463_CMD_POWER_UP 0x02 #define SI4463_CMD_NOP 0x00 #define SI4463_CMD_PART_INFO 0x01 #define SI4463_CMD_FUNC_INFO 0x10 #define SI4463_CMD_SET_PROPERTY 0x11 #define SI4463_CMD_GET_PROPERTY 0x12 #define SI4463_CMD_GPIO_PIN_CFG 0x13 #define SI4463_CMD_FIFO_INFO 0x15 #define SI4463_CMD_GET_INT_STATUS 0x20 #define SI4463_CMD_REQUEST_DEVICE_STATE 0x33 #define SI4463_CMD_CHANGE_STATE 0x34 #define SI4463_CMD_READ_CMD_BUFF 0x44 #define SI4463_CMD_FRR_A_READ 0x50 #define SI4463_CMD_FRR_B_READ 0x51 #define SI4463_CMD_FRR_C_READ 0x53 #define SI4463_CMD_FRR_D_READ 0x57 #define SI4463_CMD_IRCAL 0x17 #define SI4463_CMD_IRCAL_MANUAL 0x1A #define SI4463_CMD_START_TX 0x31 #define SI4463_CMD_TX_HOP 0x37 #define SI4463_CMD_WRITE_TX_FIFO 0x66 #define SI4463_CMD_PACKET_INFO 0x16 #define SI4463_CMD_GET_MODEM_STATUS 0x22 #define SI4463_CMD_START_RX 0x32 #define SI4463_CMD_RX_HOP 0x36 #define SI4463_CMD_READ_RX_FIFO 0x77 #define SI4463_CMD_GET_ADC_READING 0x14 #define SI4463_CMD_GET_PH_STATUS 0x21 #define SI4463_CMD_GET_CHIP_STATUS 0x23 /* Command and response data structures */ /* POWER ON command */ begin_packed_struct struct si4463_cmd_pwrup_s { uint8_t boot_options; uint8_t xtal_options; uint32_t xo_freq; } end_packed_struct; #define PWRUP_BOOTOPT_NO_PATCH 0 #define PWRUP_BOOTOPT_PATCH (1<<7) #define PWRUP_BOOTOPT_FUNC_SHIFT 0 #define PWRUP_BOOTOPT_FUNC_PRO (0x01<