wayne roberts / SX1232

Dependents:   chat_sx1232

Embed: (wiki syntax)

« Back to documentation index

SX1232 Class Reference

SX1232 Class Reference

FSK radio transceiver for 800/900MHz. More...

#include <sx1232.h>

Public Member Functions

 SX1232 (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName dio_0)
 Create SX1232 instance.
void set_rx_dcc_bw_hz (uint32_t dccValue, uint32_t bw_hz)
 set receiver bandwidth
uint32_t get_rx_bw_hz (uint8_t addr)
 get receiver bandwidth
void set_frf_MHz (float MHz)
 set center operating frequency
float get_frf_MHz (void)
 get center operating frequency
void set_bitrate (uint32_t bps)
 set over-the-air bitrate
uint32_t get_bitrate (void)
 get over-the-air bitrte
void set_tx_fdev_hz (uint32_t hz)
 set transmitted frequency deviation
uint32_t get_tx_fdev_hz (void)
 get transmitted frequency deviation
void enable_afc (char enable)
 enable AFC with preamble detector
void set_RegPayloadLength (uint16_t len)
 write payload length
uint16_t get_PayloadLength (void)
 read payload length
void start_tx (uint8_t len)
 transmit a packet
void start_rx (void)
 start receive mode
int read_fifo (void)
 Called by main program when indicated by service_action variable, to pull recevied packet from radio FIFO.
void hw_reset (void)
 reset radio using pin
void init (void)
 initialise SX1232 class to radio
uint8_t read_reg (uint8_t addr)
 read register from radio
void write_reg (uint8_t addr, uint8_t data)
 write register to radio

Data Fields

volatile service_action_e service_action
 set from ISR to indicate an action to be performed from main loop
uint8_t tx_buf [64]
 RF transmit packet buffer.
uint8_t rx_buf [64]
 RF receive packet buffer.
RegOpMode_t RegOpMode
 operating mode
RegDioMapping1_t RegDioMapping1
 pin assignments
RegDioMapping2_t RegDioMapping2
 pin assignments
RegPktConfig1_t RegPktConfig1
 packet format configuration
RegPktConfig2_t RegPktConfig2
 packet mode control and payload length MSB
uint8_t RegPayloadLength
 payload length LSByte
RegFifoThreshold_t RegFifoThreshold
 TxStartCondition.
RegSyncConfig_t RegSyncConfig
 AutoRestartRx configuration and start-of-frame control.
RegPreambleDetect_t RegPreambleDetect
 receiver preamble detector control
uint8_t RegPreambleMsb
 TX preamble length.
uint8_t RegPreambleLsb
 TX preamble length.
RegPaConfig_t RegPaConfig
 transmitter power configuration
RegRxConfig_t RegRxConfig
 AFC/AGC configuration.
RegTimerResol_t RegTimerResol
 sequencer timing
uint8_t RegRssiThresh
 receiver: trigger level for RSSI interrupt
RegSeqConfig1_t RegSeqConfig1
 sequencer control
RegSeqConfig2_t RegSeqConfig2
 sequencer control
RegAfcFei_t RegAfcFei
 AFC clearing control and manual AFC trigger.

Detailed Description

FSK radio transceiver for 800/900MHz.

Compared with ADF7023 in Xbee PRO 900: Receiver bandwidth configurable to narrower operation, for performance at lower bitrates. Transmit power option to +20dBm. Superior blocking immunity in receiver. http://www.semtech.com/apps/product.php?pn=sx1232

Definition at line 351 of file sx1232.h.


Constructor & Destructor Documentation

SX1232 ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs,
PinName  rst,
PinName  dio_0 
)

Create SX1232 instance.

Parameters:
mosiSPI master-out pin
misoSPI master-in pin
sclkSPI clock pin
csSPI chip-select pin
rstradio hardware reset pin
dio_0interrupt pin from radio

Definition at line 19 of file sx1232.cpp.


Member Function Documentation

void enable_afc ( char  enable )

enable AFC with preamble detector

Note:
AFC generally used when crystal tolerance is worse than receiver bandwidth. Narrower bandwidths require better ppm on crystal, without AFC.
this enables with RxTrigger on preamble detect without RSSI threshold.
other option is to also use RSSI threshold, but requires calibration from ambient RSSI on vacant channel.

Definition at line 305 of file sx1232.cpp.

uint32_t get_bitrate ( void   )

get over-the-air bitrte

Returns:
bits per second

Definition at line 163 of file sx1232.cpp.

float get_frf_MHz ( void   )

get center operating frequency

Returns:
operating frequency in MHz

Definition at line 138 of file sx1232.cpp.

uint16_t get_PayloadLength ( void   )

read payload length

Definition at line 283 of file sx1232.cpp.

uint32_t get_rx_bw_hz ( uint8_t  addr )

get receiver bandwidth

Returns:
the receiver bandwidth in Hz

Definition at line 262 of file sx1232.cpp.

uint32_t get_tx_fdev_hz ( void   )

get transmitted frequency deviation

Returns:
transmitter frequency deviation in Hz

Definition at line 184 of file sx1232.cpp.

void hw_reset ( void   )

reset radio using pin

Definition at line 74 of file sx1232.cpp.

void init ( void   )

initialise SX1232 class to radio

Note:
this is called from class instantiation, but must also be manually called after hardware reset

Definition at line 36 of file sx1232.cpp.

int read_fifo ( void   )

Called by main program when indicated by service_action variable, to pull recevied packet from radio FIFO.

Returns:
count of bytes received
Note:
received packet in rx_buf[]

Definition at line 86 of file sx1232.cpp.

uint8_t read_reg ( uint8_t  addr )

read register from radio

Parameters:
addrregister address
Returns:
the value read from the register

Definition at line 355 of file sx1232.cpp.

void set_bitrate ( uint32_t  bps )

set over-the-air bitrate

Parameters:
bpsbits per second
Note:
TX frequency deviation must be set according to desired modulation index
you cannot change bitrate while in receive mode

Definition at line 153 of file sx1232.cpp.

void set_frf_MHz ( float  MHz )

set center operating frequency

Parameters:
MHzoperating frequency in MHz

Definition at line 195 of file sx1232.cpp.

void set_RegPayloadLength ( uint16_t  len )

write payload length

Note:
PayloadLength is maximum 255 in variable-length packet format, or fixed-length maximum of 2047 bytes.
if PacketFormat is fixed-length, then PayloadLength of 0 enables unlimited length mode.
In variable length mode, this sets maximum allowed received packet length.
Parameters:
lenPayloadLength

Definition at line 297 of file sx1232.cpp.

void set_rx_dcc_bw_hz ( uint32_t  dccValue,
uint32_t  bw_hz 
)

set receiver bandwidth

Note:
Value is selected to frequency deviation and bit-rate (occupied bandwidth)
Narrower bandwidths may require AFC, depending on reference crystal accuracy
RX start-up time is slower at narrower bandwidths
you cannot change bandwith while in receive mode
usable range is 2.6KHz to 250KHz

Definition at line 235 of file sx1232.cpp.

void set_tx_fdev_hz ( uint32_t  hz )

set transmitted frequency deviation

Parameters:
hzfrequency deviation in Hz
Note:
occupied bandwith is primarily determined by fdev; set receiver bandwidth appropriately
usable range is 600Hz to 200KHz

Definition at line 174 of file sx1232.cpp.

void start_rx ( void   )

start receive mode

Note:
the variable service_action needs to be monitored to indicate read_fifo() needs to be called to pull packet from FIFO.

Definition at line 441 of file sx1232.cpp.

void start_tx ( uint8_t  len )

transmit a packet

Parameters:
lensize of packet, variable-length format only. unused in fixed-length format.
Note:
Limited to 64 bytes. Lengths greater than 64 require flow control (radio FIFO size)

Definition at line 413 of file sx1232.cpp.

void write_reg ( uint8_t  addr,
uint8_t  data 
)

write register to radio

Parameters:
addrregister address
databyte to write

Definition at line 372 of file sx1232.cpp.


Field Documentation

RegAfcFei_t RegAfcFei

AFC clearing control and manual AFC trigger.

Definition at line 531 of file sx1232.h.

RegDioMapping1_t RegDioMapping1

pin assignments

Definition at line 480 of file sx1232.h.

RegDioMapping2_t RegDioMapping2

pin assignments

Definition at line 483 of file sx1232.h.

RegFifoThreshold_t RegFifoThreshold

TxStartCondition.

Definition at line 495 of file sx1232.h.

RegOpMode_t RegOpMode

operating mode

Definition at line 477 of file sx1232.h.

RegPaConfig_t RegPaConfig

transmitter power configuration

Definition at line 510 of file sx1232.h.

payload length LSByte

Definition at line 492 of file sx1232.h.

RegPktConfig1_t RegPktConfig1

packet format configuration

Definition at line 486 of file sx1232.h.

RegPktConfig2_t RegPktConfig2

packet mode control and payload length MSB

Definition at line 489 of file sx1232.h.

RegPreambleDetect_t RegPreambleDetect

receiver preamble detector control

Definition at line 501 of file sx1232.h.

uint8_t RegPreambleLsb

TX preamble length.

Definition at line 507 of file sx1232.h.

uint8_t RegPreambleMsb

TX preamble length.

Definition at line 504 of file sx1232.h.

uint8_t RegRssiThresh

receiver: trigger level for RSSI interrupt

Definition at line 522 of file sx1232.h.

RegRxConfig_t RegRxConfig

AFC/AGC configuration.

Definition at line 513 of file sx1232.h.

RegSeqConfig1_t RegSeqConfig1

sequencer control

Definition at line 525 of file sx1232.h.

RegSeqConfig2_t RegSeqConfig2

sequencer control

Definition at line 528 of file sx1232.h.

RegSyncConfig_t RegSyncConfig

AutoRestartRx configuration and start-of-frame control.

Definition at line 498 of file sx1232.h.

RegTimerResol_t RegTimerResol

sequencer timing

Definition at line 519 of file sx1232.h.

uint8_t rx_buf[64]

RF receive packet buffer.

Definition at line 474 of file sx1232.h.

volatile service_action_e service_action

set from ISR to indicate an action to be performed from main loop

Definition at line 468 of file sx1232.h.

uint8_t tx_buf[64]

RF transmit packet buffer.

Definition at line 471 of file sx1232.h.