Skip to content
si4463.h 40 KiB
Newer Older
Sebastien Lorquet's avatar
Sebastien Lorquet committed
/****************************************************************************
 * drivers/wireless/generic/si4463.h
 *
 *   Copyright (C) 2017-2018 Sebastien Lorquet. All rights reserved.
Sebastien Lorquet's avatar
Sebastien Lorquet committed
 *   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>

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)

#define PINCFG_DONOTHING              0
#define PINCFG_TRISTATE               1
#define PINCFG_DRIVE0                 2
#define PINCFG_DRIVE1                 3
#define PINCFG_INPUT                  4
#define PINCFG_32K_CLK                5
#define PINCFG_BOOT_CLK               6
Sebastien Lorquet's avatar
Sebastien Lorquet committed
#define PINCFG_DIV_CLK                7
#define PINCFG_CTS                    8
#define PINCFG_INV_CTS                9
#define PINCFG_CMD_OVERLAP           10
Sebastien Lorquet's avatar
Sebastien Lorquet committed
#define PINCFG_SDO                   11
#define PINCFG_POR                   12
#define PINCFG_CAL_WUT               13
Sebastien Lorquet's avatar
Sebastien Lorquet committed
#define PINCFG_WUT                   14
#define PINCFG_EN_PA                 15
#define PINCFG_TX_DATA_CLK           16
#define PINCFG_RX_DATA_CLK           17
#define PINCFG_EN_LNA                18
#define PINCFG_TX_DATA               19
#define PINCFG_RX_DATA               20
#define PINCFG_RX_RAW_DATA           21
#define PINCFG_ANTENNA_1_SW          22
Loading full blame...