Si4463 Radio Library for AVR and Arduino  1.0
Data Structures | Macros | Enumerations | Functions
Si446x.h File Reference
#include <stdint.h>
#include "Si446x_config.h"

Go to the source code of this file.

Data Structures

struct  si446x_info_t
 Data structure for storing chip info from Si446x_getInfo() More...
 

Macros

#define SI446X_MAX_PACKET_LEN   128
 Maximum packet length. More...
 
#define SI446X_MAX_TX_POWER   127
 Maximum TX power (+20dBm/100mW) More...
 
#define SI446X_WUT_RUN   1
 Wake the microcontroller when the WUT expires. More...
 
#define SI446X_WUT_BATT   2
 Take a battery measurement when the WUT expires. More...
 
#define SI446X_WUT_RX   4
 Go into RX mode for LDC time (not supported yet!) More...
 
#define SI446X_GPIO_PULL_EN   0x40
 Pullup enable for GPIO pins. More...
 
#define SI446X_GPIO_PULL_DIS   0x00
 Pullup disable for GPIO pins. More...
 
#define SI446X_NIRQ_PULL_EN   0x40
 Pullup enable for NIRQ pin. More...
 
#define SI446X_NIRQ_PULL_DIS   0x00
 Pullup disable for NIRQ pin. More...
 
#define SI446X_SDO_PULL_EN   0x40
 Pullup enable for SDO pin. More...
 
#define SI446X_SDO_PULL_DIS   0x00
 Pullup disable for SDO pin. More...
 
#define SI446X_PIN_PULL_EN   0x40
 Pullup enable for any pin. More...
 
#define SI446X_PIN_PULL_DIS   0x00
 Pullup disable for any pin. More...
 
#define SI446X_GPIO_DRV_HIGH   0x00
 GPIO drive strength high. More...
 
#define SI446X_GPIO_DRV_MED_HIGH   0x20
 GPIO drive strength medium-high. More...
 
#define SI446X_GPIO_DRV_MED_LOW   0x40
 GPIO drive strength medium-low. More...
 
#define SI446X_GPIO_DRV_LOW   0x60
 GPIO drive strength low. More...
 
#define SI446X_PROP_GROUP_GLOBAL   0x00
 Property group global. More...
 
#define SI446X_PROP_GROUP_INT   0x01
 Property group interrupts. More...
 
#define SI446X_PROP_GROUP_FRR   0x02
 Property group fast response registers. More...
 
#define SI446X_PROP_GROUP_PREAMBLE   0x10
 Property group preamble. More...
 
#define SI446X_PROP_GROUP_SYNC   0x11
 Property group sync. More...
 
#define SI446X_PROP_GROUP_PKT   0x12
 Property group packet config. More...
 
#define SI446X_PROP_GROUP_MODEM   0x20
 Property group modem. More...
 
#define SI446X_PROP_GROUP_MODEM_CHFLT   0x21
 Property group RX coefficients. More...
 
#define SI446X_PROP_GROUP_PA   0x22
 Property group power amp. More...
 
#define SI446X_PROP_GROUP_SYNTH   0x23
 Property group synthesizer. More...
 
#define SI446X_PROP_GROUP_MATCH   0x30
 Property group address match. More...
 
#define SI446X_PROP_GROUP_FREQ_CONTROL   0x40
 Property group frequency control. More...
 
#define SI446X_PROP_GROUP_RX_HOP   0x50
 Property group RX hop. More...
 
#define SI446X_PROP_GROUP_PTI   0xF0
 Property group packet trace interface. More...
 
#define SI446X_CBS_SENT   _BV(5+8)
 Enable/disable packet sent callback. More...
 
#define SI446X_CBS_RXBEGIN   _BV(0)
 Enable/disable packet receive begin callback. More...
 
#define SI446X_NO_INTERRUPT()
 Disable Si446x interrupts for code inside this block. More...
 

Enumerations

enum  si446x_gpio_mode_t {
  SI446X_GPIO_MODE_DONOTHING = 0x00, SI446X_GPIO_MODE_TRISTATE = 0x01, SI446X_GPIO_MODE_DRIVE0 = 0x02, SI446X_GPIO_MODE_DRIVE1 = 0x03,
  SI446X_GPIO_MODE_INPUT = 0x04, SI446X_GPIO_MODE_32K_CLK = 0x05, SI446X_GPIO_MODE_BOOT_CLK = 0x06, SI446X_GPIO_MODE_DIV_CLK = 0x07,
  SI446X_GPIO_MODE_CTS = 0x08, SI446X_GPIO_MODE_INV_CTS = 0x09, SI446X_GPIO_MODE_CMD_OVERLAP = 0x0A, SI446X_GPIO_MODE_SDO = 0x0B,
  SI446X_GPIO_MODE_POR = 0x0C, SI446X_GPIO_MODE_CAL_WUT = 0x0D, SI446X_GPIO_MODE_WUT = 0x0E, SI446X_GPIO_MODE_EN_PA = 0x0F,
  SI446X_GPIO_MODE_TX_DATA_CLK = 0x10, SI446X_GPIO_MODE_RX_DATA_CLK = 0x11, SI446X_GPIO_MODE_EN_LNA = 0x12, SI446X_GPIO_MODE_TX_DATA = 0x13,
  SI446X_GPIO_MODE_RX_DATA = 0x14, SI446X_GPIO_MODE_RX_RAW_DATA = 0x15, SI446X_GPIO_MODE_ANTENNA_1_SW = 0x16, SI446X_GPIO_MODE_ANTENNA_2_SW = 0x17,
  SI446X_GPIO_MODE_VALID_PREAMBLE = 0x18, SI446X_GPIO_MODE_INVALID_PREAMBLE = 0x19, SI446X_GPIO_MODE_SYNC_WORD_DETECT = 0x1A, SI446X_GPIO_MODE_CCA = 0x1B,
  SI446X_GPIO_MODE_IN_SLEEP = 0x1C, SI446X_GPIO_MODE_PKT_TRACE = 0x1D, SI446X_GPIO_MODE_TX_RX_DATA_CLK = 0x1F, SI446X_GPIO_MODE_TX_STATE = 0x20,
  SI446X_GPIO_MODE_RX_STATE = 0x21, SI446X_GPIO_MODE_RX_FIFO_FULL = 0x22, SI446X_GPIO_MODE_TX_FIFO_EMPTY = 0x23, SI446X_GPIO_MODE_LOW_BATT = 0x24,
  SI446X_GPIO_MODE_CCA_LATCH = 0x25, SI446X_GPIO_MODE_HOPPED = 0x26, SI446X_GPIO_MODE_HOP_TABLE_WRAP = 0x27
}
 GPIO pin modes (see the Si446x API docs for what they all mean) More...
 
enum  si446x_nirq_mode_t {
  SI446X_NIRQ_MODE_DONOTHING = 0x00, SI446X_NIRQ_MODE_TRISTATE = 0x01, SI446X_NIRQ_MODE_DRIVE0 = 0x02, SI446X_NIRQ_MODE_DRIVE1 = 0x03,
  SI446X_NIRQ_MODE_INPUT = 0x04, SI446X_NIRQ_MODE_DIV_CLK = 0x07, SI446X_NIRQ_MODE_CTS = 0x08, SI446X_NIRQ_MODE_SDO = 0x0B,
  SI446X_NIRQ_MODE_POR = 0x0C, SI446X_NIRQ_MODE_EN_PA = 0x0F, SI446X_NIRQ_MODE_TX_DATA_CLK = 0x10, SI446X_NIRQ_MODE_RX_DATA_CLK = 0x11,
  SI446X_NIRQ_MODE_EN_LNA = 0x12, SI446X_NIRQ_MODE_TX_DATA = 0x13, SI446X_NIRQ_MODE_RX_DATA = 0x14, SI446X_NIRQ_MODE_RX_RAW_DATA = 0x15,
  SI446X_NIRQ_MODE_ANTENNA_1_SW = 0x16, SI446X_NIRQ_MODE_ANTENNA_2_SW = 0x17, SI446X_NIRQ_MODE_VALID_PREAMBLE = 0x18, SI446X_NIRQ_MODE_INVALID_PREAMBLE = 0x19,
  SI446X_NIRQ_MODE_SYNC_WORD_DETECT = 0x1A, SI446X_NIRQ_MODE_CCA = 0x1B, SI446X_NIRQ_MODE_PKT_TRACE = 0x1D, SI446X_NIRQ_MODE_TX_RX_DATA_CLK = 0x1F,
  SI446X_NIRQ_MODE_NIRQ = 0x27
}
 NIRQ pin modes (see the Si446x API docs for what they all mean) More...
 
enum  si446x_sdo_mode_t {
  SI446X_SDO_MODE_DONOTHING = 0x00, SI446X_SDO_MODE_TRISTATE = 0x01, SI446X_SDO_MODE_DRIVE0 = 0x02, SI446X_SDO_MODE_DRIVE1 = 0x03,
  SI446X_SDO_MODE_INPUT = 0x04, SI446X_SDO_MODE_32K_CLK = 0x05, SI446X_SDO_MODE_DIV_CLK = 0x07, SI446X_SDO_MODE_CTS = 0x08,
  SI446X_SDO_MODE_SDO = 0x0B, SI446X_SDO_MODE_POR = 0x0C, SI446X_SDO_MODE_WUT = 0x0E, SI446X_SDO_MODE_EN_PA = 0x0F,
  SI446X_SDO_MODE_TX_DATA_CLK = 0x10, SI446X_SDO_MODE_RX_DATA_CLK = 0x11, SI446X_SDO_MODE_EN_LNA = 0x12, SI446X_SDO_MODE_TX_DATA = 0x13,
  SI446X_SDO_MODE_RX_DATA = 0x14, SI446X_SDO_MODE_RX_RAW_DATA = 0x15, SI446X_SDO_MODE_ANTENNA_1_SW = 0x16, SI446X_SDO_MODE_ANTENNA_2_SW = 0x17,
  SI446X_SDO_MODE_VALID_PREAMBLE = 0x18, SI446X_SDO_MODE_INVALID_PREAMBLE = 0x19, SI446X_SDO_MODE_SYNC_WORD_DETECT = 0x1A, SI446X_SDO_MODE_CCA = 0x1B
}
 SDO pin modes (see the Si446x API docs for what they all mean) More...
 
enum  si446x_gpio_t {
  SI446X_GPIO0 = 0, SI446X_GPIO1 = 1, SI446X_GPIO2 = 2, SI446X_GPIO3 = 3,
  SI446X_NIRQ = 4, SI446X_SDO = 5
}
 GPIOs for passing to Si446x_writeGPIO(), or for masking when reading from Si446x_readGPIO() More...
 
enum  si446x_state_t {
  SI446X_STATE_NOCHANGE = 0x00, SI446X_STATE_SLEEP = 0x01, SI446X_STATE_SPI_ACTIVE = 0x02, SI446X_STATE_READY = 0x03,
  SI446X_STATE_READY2 = 0x04, SI446X_STATE_TX_TUNE = 0x05, SI446X_STATE_RX_TUNE = 0x06, SI446X_STATE_TX = 0x07,
  SI446X_STATE_RX = 0x08
}
 Radio states, returned from Si446x_getState() More...
 

Functions

void Si446x_init (void)
 Initialise, must be called before anything else! More...
 
void Si446x_getInfo (si446x_info_t *info)
 Get chip info, see si446x_info_t. More...
 
int16_t Si446x_getRSSI (void)
 Get the current RSSI, the chip needs to be in receive mode for this to work. More...
 
void Si446x_setTxPower (uint8_t pwr)
 Set the transmit power. The output power does not follow the pwr value, see the Si446x datasheet for a pretty graph. More...
 
void Si446x_setupCallback (uint16_t callbacks, uint8_t state)
 Enable or disable callbacks. This is mainly to configure what events should wake the microcontroller up. More...
 
void Si446x_read (void *buff, uint8_t len)
 Read received data from FIFO. More...
 
uint8_t Si446x_TX (void *packet, uint8_t len, uint8_t channel, si446x_state_t onTxFinish)
 Transmit a packet. More...
 
void Si446x_RX (uint8_t channel)
 Enter receive mode. More...
 
void Si446x_setLowBatt (uint16_t voltage)
 Set the low battery voltage alarm. More...
 
void Si446x_setupWUT (uint8_t r, uint16_t m, uint8_t ldc, uint8_t config)
 Configure the wake up timer. More...
 
void Si446x_disableWUT (void)
 Disable the wake up timer. More...
 
uint8_t Si446x_sleep (void)
 Enter sleep mode. More...
 
si446x_state_t Si446x_getState (void)
 Get the radio status. More...
 
uint16_t Si446x_adc_gpio (uint8_t pin)
 Read pin ADC value. More...
 
uint16_t Si446x_adc_battery (void)
 Read supply voltage. More...
 
float Si446x_adc_temperature (void)
 Read temperature. More...
 
void Si446x_writeGPIO (si446x_gpio_t pin, uint8_t value)
 Configure GPIO/NIRQ/SDO pin. More...
 
uint8_t Si446x_readGPIO (void)
 Read GPIO pin states. More...
 
uint8_t Si446x_dump (void *buff, uint8_t group)
 Get all values of a property group. More...
 
void Si446x_SERVICE (void)
 If interrupts are disabled (::SI446X_INTERRUPTS in Si446x_config.h) then this function should be called as often as possible to process any events. More...
 
uint8_t Si446x_irq_off (void)
 When using interrupts use this to disable them for the Si446x. More...
 
void Si446x_irq_on (uint8_t origVal)
 When using interrupts use this to re-enable them for the Si446x. More...
 

Macro Definition Documentation

◆ SI446X_CBS_RXBEGIN

#define SI446X_CBS_RXBEGIN   _BV(0)

Enable/disable packet receive begin callback.

◆ SI446X_CBS_SENT

#define SI446X_CBS_SENT   _BV(5+8)

Enable/disable packet sent callback.

◆ SI446X_GPIO_DRV_HIGH

#define SI446X_GPIO_DRV_HIGH   0x00

GPIO drive strength high.

◆ SI446X_GPIO_DRV_LOW

#define SI446X_GPIO_DRV_LOW   0x60

GPIO drive strength low.

◆ SI446X_GPIO_DRV_MED_HIGH

#define SI446X_GPIO_DRV_MED_HIGH   0x20

GPIO drive strength medium-high.

◆ SI446X_GPIO_DRV_MED_LOW

#define SI446X_GPIO_DRV_MED_LOW   0x40

GPIO drive strength medium-low.

◆ SI446X_GPIO_PULL_DIS

#define SI446X_GPIO_PULL_DIS   0x00

Pullup disable for GPIO pins.

◆ SI446X_GPIO_PULL_EN

#define SI446X_GPIO_PULL_EN   0x40

Pullup enable for GPIO pins.

◆ SI446X_MAX_PACKET_LEN

#define SI446X_MAX_PACKET_LEN   128

Maximum packet length.

◆ SI446X_MAX_TX_POWER

#define SI446X_MAX_TX_POWER   127

Maximum TX power (+20dBm/100mW)

◆ SI446X_NIRQ_PULL_DIS

#define SI446X_NIRQ_PULL_DIS   0x00

Pullup disable for NIRQ pin.

◆ SI446X_NIRQ_PULL_EN

#define SI446X_NIRQ_PULL_EN   0x40

Pullup enable for NIRQ pin.

◆ SI446X_NO_INTERRUPT

#define SI446X_NO_INTERRUPT ( )
Value:
for(uint8_t si446x_irq __attribute__((__cleanup__(_Si446x_iRestore))) = Si446x_irq_off(), \
si446x_tmp = 1; si446x_tmp ; si446x_tmp = 0)
uint8_t Si446x_irq_off(void)
When using interrupts use this to disable them for the Si446x.

Disable Si446x interrupts for code inside this block.

When communicating with other SPI devices on the same bus as the radio then you should wrap those sections in a SI446X_NO_INTERRUPT() block, this will stop the Si446x interrupt from running and trying to use the bus at the same time. This macro is based on the code from avr/atomic.h, and wraps the Si446x_irq_off() and Si446x_irq_on() functions instead of messing with global interrupts. It is safe to return, break or continue inside an SI446X_NO_INTERRUPT() block.

Example:

Si446x_RX(63);
SI446X_NO_INTERRUPT()
{
OLED.write("blah", 2, 10); // Communicate with SPI OLED display
}

◆ SI446X_PIN_PULL_DIS

#define SI446X_PIN_PULL_DIS   0x00

Pullup disable for any pin.

◆ SI446X_PIN_PULL_EN

#define SI446X_PIN_PULL_EN   0x40

Pullup enable for any pin.

◆ SI446X_PROP_GROUP_FREQ_CONTROL

#define SI446X_PROP_GROUP_FREQ_CONTROL   0x40

Property group frequency control.

◆ SI446X_PROP_GROUP_FRR

#define SI446X_PROP_GROUP_FRR   0x02

Property group fast response registers.

◆ SI446X_PROP_GROUP_GLOBAL

#define SI446X_PROP_GROUP_GLOBAL   0x00

Property group global.

◆ SI446X_PROP_GROUP_INT

#define SI446X_PROP_GROUP_INT   0x01

Property group interrupts.

◆ SI446X_PROP_GROUP_MATCH

#define SI446X_PROP_GROUP_MATCH   0x30

Property group address match.

◆ SI446X_PROP_GROUP_MODEM

#define SI446X_PROP_GROUP_MODEM   0x20

Property group modem.

◆ SI446X_PROP_GROUP_MODEM_CHFLT

#define SI446X_PROP_GROUP_MODEM_CHFLT   0x21

Property group RX coefficients.

◆ SI446X_PROP_GROUP_PA

#define SI446X_PROP_GROUP_PA   0x22

Property group power amp.

◆ SI446X_PROP_GROUP_PKT

#define SI446X_PROP_GROUP_PKT   0x12

Property group packet config.

◆ SI446X_PROP_GROUP_PREAMBLE

#define SI446X_PROP_GROUP_PREAMBLE   0x10

Property group preamble.

◆ SI446X_PROP_GROUP_PTI

#define SI446X_PROP_GROUP_PTI   0xF0

Property group packet trace interface.

◆ SI446X_PROP_GROUP_RX_HOP

#define SI446X_PROP_GROUP_RX_HOP   0x50

Property group RX hop.

◆ SI446X_PROP_GROUP_SYNC

#define SI446X_PROP_GROUP_SYNC   0x11

Property group sync.

◆ SI446X_PROP_GROUP_SYNTH

#define SI446X_PROP_GROUP_SYNTH   0x23

Property group synthesizer.

◆ SI446X_SDO_PULL_DIS

#define SI446X_SDO_PULL_DIS   0x00

Pullup disable for SDO pin.

◆ SI446X_SDO_PULL_EN

#define SI446X_SDO_PULL_EN   0x40

Pullup enable for SDO pin.

◆ SI446X_WUT_BATT

#define SI446X_WUT_BATT   2

Take a battery measurement when the WUT expires.

◆ SI446X_WUT_RUN

#define SI446X_WUT_RUN   1

Wake the microcontroller when the WUT expires.

◆ SI446X_WUT_RX

#define SI446X_WUT_RX   4

Go into RX mode for LDC time (not supported yet!)

Enumeration Type Documentation

◆ si446x_gpio_mode_t

GPIO pin modes (see the Si446x API docs for what they all mean)

Enumerator
SI446X_GPIO_MODE_DONOTHING 
SI446X_GPIO_MODE_TRISTATE 
SI446X_GPIO_MODE_DRIVE0 
SI446X_GPIO_MODE_DRIVE1 
SI446X_GPIO_MODE_INPUT 
SI446X_GPIO_MODE_32K_CLK 
SI446X_GPIO_MODE_BOOT_CLK 
SI446X_GPIO_MODE_DIV_CLK 
SI446X_GPIO_MODE_CTS 
SI446X_GPIO_MODE_INV_CTS 
SI446X_GPIO_MODE_CMD_OVERLAP 
SI446X_GPIO_MODE_SDO 
SI446X_GPIO_MODE_POR 
SI446X_GPIO_MODE_CAL_WUT 
SI446X_GPIO_MODE_WUT 
SI446X_GPIO_MODE_EN_PA 
SI446X_GPIO_MODE_TX_DATA_CLK 
SI446X_GPIO_MODE_RX_DATA_CLK 
SI446X_GPIO_MODE_EN_LNA 
SI446X_GPIO_MODE_TX_DATA 
SI446X_GPIO_MODE_RX_DATA 
SI446X_GPIO_MODE_RX_RAW_DATA 
SI446X_GPIO_MODE_ANTENNA_1_SW 
SI446X_GPIO_MODE_ANTENNA_2_SW 
SI446X_GPIO_MODE_VALID_PREAMBLE 
SI446X_GPIO_MODE_INVALID_PREAMBLE 
SI446X_GPIO_MODE_SYNC_WORD_DETECT 
SI446X_GPIO_MODE_CCA 
SI446X_GPIO_MODE_IN_SLEEP 
SI446X_GPIO_MODE_PKT_TRACE 
SI446X_GPIO_MODE_TX_RX_DATA_CLK 
SI446X_GPIO_MODE_TX_STATE 
SI446X_GPIO_MODE_RX_STATE 
SI446X_GPIO_MODE_RX_FIFO_FULL 
SI446X_GPIO_MODE_TX_FIFO_EMPTY 
SI446X_GPIO_MODE_LOW_BATT 
SI446X_GPIO_MODE_CCA_LATCH 
SI446X_GPIO_MODE_HOPPED 
SI446X_GPIO_MODE_HOP_TABLE_WRAP 

◆ si446x_gpio_t

GPIOs for passing to Si446x_writeGPIO(), or for masking when reading from Si446x_readGPIO()

Enumerator
SI446X_GPIO0 

GPIO 1.

SI446X_GPIO1 

GPIO 2.

SI446X_GPIO2 

GPIO 3.

SI446X_GPIO3 

GPIO 4.

SI446X_NIRQ 

NIRQ.

SI446X_SDO 

SDO.

◆ si446x_nirq_mode_t

NIRQ pin modes (see the Si446x API docs for what they all mean)

Enumerator
SI446X_NIRQ_MODE_DONOTHING 
SI446X_NIRQ_MODE_TRISTATE 
SI446X_NIRQ_MODE_DRIVE0 
SI446X_NIRQ_MODE_DRIVE1 
SI446X_NIRQ_MODE_INPUT 
SI446X_NIRQ_MODE_DIV_CLK 
SI446X_NIRQ_MODE_CTS 
SI446X_NIRQ_MODE_SDO 
SI446X_NIRQ_MODE_POR 
SI446X_NIRQ_MODE_EN_PA 
SI446X_NIRQ_MODE_TX_DATA_CLK 
SI446X_NIRQ_MODE_RX_DATA_CLK 
SI446X_NIRQ_MODE_EN_LNA 
SI446X_NIRQ_MODE_TX_DATA 
SI446X_NIRQ_MODE_RX_DATA 
SI446X_NIRQ_MODE_RX_RAW_DATA 
SI446X_NIRQ_MODE_ANTENNA_1_SW 
SI446X_NIRQ_MODE_ANTENNA_2_SW 
SI446X_NIRQ_MODE_VALID_PREAMBLE 
SI446X_NIRQ_MODE_INVALID_PREAMBLE 
SI446X_NIRQ_MODE_SYNC_WORD_DETECT 
SI446X_NIRQ_MODE_CCA 
SI446X_NIRQ_MODE_PKT_TRACE 
SI446X_NIRQ_MODE_TX_RX_DATA_CLK 
SI446X_NIRQ_MODE_NIRQ 

◆ si446x_sdo_mode_t

SDO pin modes (see the Si446x API docs for what they all mean)

Enumerator
SI446X_SDO_MODE_DONOTHING 
SI446X_SDO_MODE_TRISTATE 
SI446X_SDO_MODE_DRIVE0 
SI446X_SDO_MODE_DRIVE1 
SI446X_SDO_MODE_INPUT 
SI446X_SDO_MODE_32K_CLK 
SI446X_SDO_MODE_DIV_CLK 
SI446X_SDO_MODE_CTS 
SI446X_SDO_MODE_SDO 
SI446X_SDO_MODE_POR 
SI446X_SDO_MODE_WUT 
SI446X_SDO_MODE_EN_PA 
SI446X_SDO_MODE_TX_DATA_CLK 
SI446X_SDO_MODE_RX_DATA_CLK 
SI446X_SDO_MODE_EN_LNA 
SI446X_SDO_MODE_TX_DATA 
SI446X_SDO_MODE_RX_DATA 
SI446X_SDO_MODE_RX_RAW_DATA 
SI446X_SDO_MODE_ANTENNA_1_SW 
SI446X_SDO_MODE_ANTENNA_2_SW 
SI446X_SDO_MODE_VALID_PREAMBLE 
SI446X_SDO_MODE_INVALID_PREAMBLE 
SI446X_SDO_MODE_SYNC_WORD_DETECT 
SI446X_SDO_MODE_CCA 

◆ si446x_state_t

Radio states, returned from Si446x_getState()

Enumerator
SI446X_STATE_NOCHANGE 
SI446X_STATE_SLEEP 

This will never be returned since SPI activity will wake the radio into SI446X_STATE_SPI_ACTIVE.

SI446X_STATE_SPI_ACTIVE 
SI446X_STATE_READY 
SI446X_STATE_READY2 

Will return as SI446X_STATE_READY.

SI446X_STATE_TX_TUNE 

Will return as SI446X_STATE_TX.

SI446X_STATE_RX_TUNE 

Will return as SI446X_STATE_RX.

SI446X_STATE_TX 
SI446X_STATE_RX 

Function Documentation

◆ Si446x_adc_battery()

uint16_t Si446x_adc_battery ( void  )

Read supply voltage.

Returns
Supply voltage in millivolts

◆ Si446x_adc_gpio()

uint16_t Si446x_adc_gpio ( uint8_t  pin)

Read pin ADC value.

Parameters
[pin]The GPIO pin number (0 - 3)
Returns
ADC value (0 - 2048, where 2048 is 3.6V)

◆ Si446x_adc_temperature()

float Si446x_adc_temperature ( void  )

Read temperature.

Returns
Temperature in C

◆ Si446x_disableWUT()

void Si446x_disableWUT ( void  )

Disable the wake up timer.

Returns
(none)

◆ Si446x_dump()

uint8_t Si446x_dump ( void *  buff,
uint8_t  group 
)

Get all values of a property group.

Parameters
[buff]Pointer to memory to place group values, if this is NULL then nothing will be dumped, just the group size is returned
[group]The group to dump
Returns
Size of the property group

◆ Si446x_getInfo()

void Si446x_getInfo ( si446x_info_t info)

Get chip info, see si446x_info_t.

See also
si446x_info_t
Parameters
[info]Pointer to allocated si446x_info_t struct to place data into
Returns
(none)

◆ Si446x_getRSSI()

int16_t Si446x_getRSSI ( void  )

Get the current RSSI, the chip needs to be in receive mode for this to work.

Returns
The current RSSI in dBm (usually between -130 and 0)

◆ Si446x_getState()

si446x_state_t Si446x_getState ( void  )

Get the radio status.

See also
si446x_state_t
Returns
The current radio status

◆ Si446x_init()

void Si446x_init ( void  )

Initialise, must be called before anything else!

Returns
(none)

◆ Si446x_irq_off()

uint8_t Si446x_irq_off ( void  )

When using interrupts use this to disable them for the Si446x.

Ideally you should wrap sensitive sections with SI446X_NO_INTERRUPT() instead, as it automatically deals with this function and Si446x_irq_on()

See also
Si446x_irq_on() and SI446X_NO_INTERRUPT()
Returns
The previous interrupt status; 1 if interrupt was enabled, 0 if it was already disabled

◆ Si446x_irq_on()

void Si446x_irq_on ( uint8_t  origVal)

When using interrupts use this to re-enable them for the Si446x.

Ideally you should wrap sensitive sections with SI446X_NO_INTERRUPT() instead, as it automatically deals with this function and Si446x_irq_off()

See also
Si446x_irq_off() and SI446X_NO_INTERRUPT()
Parameters
[origVal]The original interrupt status returned from Si446x_irq_off()
Returns
(none)

◆ Si446x_read()

void Si446x_read ( void *  buff,
uint8_t  len 
)

Read received data from FIFO.

Parameters
[buff]Pointer to buffer to place data
[len]Number of bytes to read, make sure not to read more bytes than what the FIFO has stored. The number of bytes that can be read is passed in the ::SI446X_CB_RXCOMPLETE() callback.
Returns
(none)

◆ Si446x_readGPIO()

uint8_t Si446x_readGPIO ( void  )

Read GPIO pin states.

Returns
The pin states. Use si446x_gpio_t to mask the value to get the state for the desired pin.

◆ Si446x_RX()

void Si446x_RX ( uint8_t  channel)

Enter receive mode.

Entering RX mode will abort any transmissions happening at the time

Parameters
[channel]Channel to listen to (0 - 255)
Returns
(none)

◆ Si446x_SERVICE()

void Si446x_SERVICE ( void  )

If interrupts are disabled (::SI446X_INTERRUPTS in Si446x_config.h) then this function should be called as often as possible to process any events.

Returns
(none)

◆ Si446x_setLowBatt()

void Si446x_setLowBatt ( uint16_t  voltage)

Set the low battery voltage alarm.

The ::SI44653_CB_LOWBATT() callback will be ran when the supply voltage drops below this value. The WUT must be configured with Si446x_setupWUT() to enable periodically checking the battery level.

Parameters
[voltage]The low battery threshold in millivolts (1050 - 3050).
Returns
(none)

◆ Si446x_setTxPower()

void Si446x_setTxPower ( uint8_t  pwr)

Set the transmit power. The output power does not follow the pwr value, see the Si446x datasheet for a pretty graph.

0 = -32dBm (<1uW)
7 = 0dBm (1mW)
12 = 5dBm (3.2mW)
22 = 10dBm (10mW)
40 = 15dBm (32mW)
100 = 20dBm (100mW)

Parameters
[pwr]A value from 0 to 127
Returns
(none)

◆ Si446x_setupCallback()

void Si446x_setupCallback ( uint16_t  callbacks,
uint8_t  state 
)

Enable or disable callbacks. This is mainly to configure what events should wake the microcontroller up.

Parameters
[callbacks]The callbacks to configure (multiple callbacks should be bitewise OR'd together)
[state]Enable or disable the callbacks passed in callbacks parameter (1 = Enable, 0 = Disable)
Returns
(none)

◆ Si446x_setupWUT()

void Si446x_setupWUT ( uint8_t  r,
uint16_t  m,
uint8_t  ldc,
uint8_t  config 
)

Configure the wake up timer.

This function will also reset the timer.

The Wake Up Timer (WUT) can be used to periodically run a number of features:
SI446X_WUT_RUN Simply wake up the microcontroller when the WUT expires and run the ::SI446X_CB_WUT() callback.
SI446X_WUT_BATT Check battery voltage - If the battery voltage is below the threshold set by Si446x_setLowBatt() then wake up the microcontroller and run the ::SI44653_CB_LOWBATT() callback.
SI446X_WUT_RX Enter receive mode for a length of time determinded by the ldc and r parameters (NOT SUPPORTED YET! dont use this option)

For more info see the GLOBAL_WUT_M, GLOBAL_WUT_R and GLOBAL_WUT_LDC properties in the Si446x API docs.

Note
When first turning on the WUT this function will take around 300us to complete
Parameters
[r]Exponent value for WUT and LDC (Maximum valus is 20)
[m]Mantissia value for WUT
[ldc]Mantissia value for LDC (NOT SUPPORTED YET, just pass 0 for now)
[config]Which WUT features to enable SI446X_WUT_RUN SI446X_WUT_BATT SI446X_WUT_RX These can be bitwise OR'ed together to enable multiple features.
Returns
(none)

◆ Si446x_sleep()

uint8_t Si446x_sleep ( void  )

Enter sleep mode.

If WUT is enabled then the radio will keep the internal 32KHz RC enabled with a current consumption of 740nA, otherwise the current consumption will be 40nA without WUT. Sleep will fail if the radio is currently transmitting.

Note
Any SPI communications with the radio will wake the radio into SI446X_STATE_SPI_ACTIVE mode. Si446x_sleep() will need to called again to put it back into sleep mode.
Returns
0 on failure (busy transmitting something), 1 on success

◆ Si446x_TX()

uint8_t Si446x_TX ( void *  packet,
uint8_t  len,
uint8_t  channel,
si446x_state_t  onTxFinish 
)

Transmit a packet.

Parameters
[packet]Pointer to packet data
[len]Number of bytes to transmit, maximum of SI446X_MAX_PACKET_LEN
[channel]Channel to transmit data on (0 - 255)
[onTxFinish]What state to enter when the packet has finished transmitting. Usually SI446X_STATE_SLEEP or SI446X_STATE_RX
Returns
0 on failure (already transmitting), 1 on success (has begun transmitting)

◆ Si446x_writeGPIO()

void Si446x_writeGPIO ( si446x_gpio_t  pin,
uint8_t  value 
)

Configure GPIO/NIRQ/SDO pin.

Note
NIRQ and SDO pins should not be changed, unless you really know what you're doing. 2 of the GPIO pins (usually 0 and 1) are also usually used for the RX/TX RF switch and should also be left alone.
Parameters
[pin]The pin, this can only take a single pin (don't use bitwise OR), see si446x_gpio_t
[value]The new pin mode, this can be bitwise OR'd with the SI446X_PIN_PULL_EN option, see si446x_gpio_mode_t si446x_nirq_mode_t si446x_sdo_mode_t
Returns
(none)