Skip to content
si4463.h 39.9 KiB
Newer Older
Sebastien Lorquet's avatar
Sebastien Lorquet committed
/****************************************************************************
 * drivers/wireless/generic/si4463.h
 *
 *   Copyright (C) 2017 Sebastien Lorquet. All rights reserved.
 *   Author: Sebastien Lorquet <sebastien@lorquet.fr>
 *
 * 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 <stdint.h>
Sebastien Lorquet's avatar
Sebastien Lorquet committed
#include <nuttx/compiler.h>
#include <nuttx/wqueue.h>

#include <nuttx/wireless/generic/genradio.h>

/* 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                         rxexpected;  /* Total number of bytes in the current packet. can be bigger than the room available in the destination rx buffer. */
  uint32_t                         rxtotaldone; /* How many bytes of current packet have been received so far */

  /* Requested parameters, input to modem calculator */
  uint8_t                          requested_modtype; /* Requested modulation */
  uint32_t                         requested_datarate; /* Requested data rate in milli bps */
  uint32_t                         requested_basefreq; /* Requested base frequency in Hz */
  uint32_t                         requested_deviation; /* Requested FSK deviation in mHz */
  uint32_t                         requested_chanspacing; /* Requested channel spacing in mHz */
  uint32_t                         requested_bt; /* Requested GFSK parameter */
  uint32_t                         requested_rxbw; /* Requested RX bandwidth */
Sebastien Lorquet's avatar
Sebastien Lorquet committed
/* 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

Sebastien Lorquet's avatar
Sebastien Lorquet committed
/* Command and response data structures */

/* POWER ON command */

begin_packed_struct
struct si4463_cmd_pwrup_s
Sebastien Lorquet's avatar
Sebastien Lorquet committed
{
  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<<PWRUP_BOOTOPT_FUNC_SHIFT)

#define PWRUP_XTALOPT_XTAL 0
#define PWRUP_XTALOPT_TCXO (1<<0)

Sebastien Lorquet's avatar
Sebastien Lorquet committed
/* PART INFO response */

begin_packed_struct
struct si4463_rsp_partinfo_s
{
  uint8_t  chiprev;
  uint16_t part;
  uint8_t  pbuild;
  uint16_t id;
  uint8_t  customer;
  uint8_t  romid;
}
end_packed_struct;
  
/* FUNC INFO response */

begin_packed_struct
struct si4463_rsp_funcinfo_s
{
  uint8_t  revext;
  uint8_t  revbranch;
  uint8_t  revint;
  uint16_t patch;
  uint8_t  func;
}
end_packed_struct;

/* SET PROPERTY command */

begin_packed_struct
struct si4463_cmd_setproperty_s
{
  uint8_t group;
  uint8_t num_props;
Sebastien Lorquet's avatar
Sebastien Lorquet committed
  uint8_t start_prop;
  uint8_t data[12];
}
end_packed_struct;

Sebastien Lorquet's avatar
Sebastien Lorquet committed
#define SI4463_SETPROP_DATALEN 12

Sebastien Lorquet's avatar
Sebastien Lorquet committed
/* GET PROPERTY command */

begin_packed_struct
struct si4463_cmd_getproperty_s
{
  uint8_t group;
  uint8_t num_props;
Sebastien Lorquet's avatar
Sebastien Lorquet committed
  uint8_t start_prop;
}
end_packed_struct;

/* GET PROPERTY response */

begin_packed_struct
struct si4463_rsp_getproperty_s
{
  uint8_t data[16];
}
end_packed_struct;

/* GPIO_PIN_CFG command or response */
begin_packed_struct
struct si4463_cmdrsp_gpiopincfg_s
{
  uint8_t gpio[4];
  uint8_t nirq;
  uint8_t sdo;
  uint8_t genconfig;
}
end_packed_struct;

Sebastien Lorquet's avatar
Sebastien Lorquet committed
#define PINCFG_PULL_DIS 0
#define PINCFG_PULL_EN  (1<<6)

Loading full blame...