SCPI interface to SX1272 and SX1276

Dependencies:   SX127x lib_gps lib_mma8451q lib_mpl3115a2 lib_sx9500 libscpi mbed

Description

This program implements a SCPI command parser. When connected via the debug virtual comm port, you can command the radio and peripherals to perform specific tasks or to set specific parameters. The serial port defaults to 9600bps N-8-1.

Example

The following exampling causes the NA Mote to transmit a continuous LoRa signal.

Example SCPI Commands

*IDN?
RA:MOD LORA
RA:FREQ 903
RA:PAS PA_BOOST
RA:OCP 170
RA:BGR 7
RA:POW 15
RA:LORA:TXContinuous ON
RA:FI "test"

Commands

SCPI is case-insensitive. Commands can be entered lower case.

  • RAdio
    • :FIfo "text" write to fifo, and transmit packet
    • :FIfo? read from fifo (last received packet)
    • :REGister { address }, {value} write radio register (SCPI takes #H for hex prefix)
    • :REGister? { address } read radio register (SCPI takes #H for hex prefix)
    • :MODulation { FSK | OOK | LORa } set modem type
    • :MODulation? get modem type
    • :OPmode { SLE | STB | FST | TX | FSR | RXC | RXS | CAD } set mode
    • :OPmode? get mode
    • :DIOMap { 0 - 5 }, { 0 - 3 } set DIO pin function {pin number}, {map value}
    • :DIOMap? { 0 - 5 } get DIO pin function {pin number}
    • :DIO? { 0 - 5 } read DIO pin level
    • :RSSI? read received signal strength (if in RXC mode)
    • :PASelect { RFO | PA_BOOST } set RF output pin
    • :PASelect? get RF output pin selected
    • :OCP {mA} set over current protection
    • :OCP? read current limit
    • :POWer {0 to 15} set OutputPower
    • :POWer? get OutputPower
    • :BGR { 0 - 7 } set PA ref current
    • :BGR? get PA ref current
    • :FREQuency {MHz} set FRF
    • :FREQuency? get FRF
    • :LNABoost { OFF | ON } set LNA boost
    • :LNABoost? get LNA boost
    • :LORa
      • :BW {KHz} set lora bandwidth
      • :BW? get lora bandwidth (in KHz)
      • :SF {7 to 12} set spreading factor
      • :SF? get spreading factor
      • :TXContinuous { OFF | ON } set continuous TX (end transmit by turning off)
      • :TXContinuous? get continuous TX
      • :PRELen {n-symbols} set preamble length
      • :PRELen? get preamble length
      • :CR {0-4} set coding rate
      • :CR? get coding rate
      • :LDRO { OFF | ON } set LowDataRateOptimize bit
      • :LDRO? get LowDataRateOptimize bit
      • :CRC { OFF | ON} enable CRC in transmitted packet
      • :CRC? read CRC enabled state
      • :INVRx { OFF | ON } enable receiver spectral invert
      • :INVRx? get receiver inversion state
      • :INVTx { OFF | ON } enable transmitter spectral invert
      • :INVTx? get transmitter inversion state
      • :FEI? get frequency error of last received packet
      • :PKTSnr? get S/N (dB) of last received packet
    • :FSK
      • :DATAMode { CONT | PKT } select continuous/packet mode
      • :DATAMode? get packet mode / continuous
      • :FDev {Hz} set TX frequency deviation
      • :FDev? get TX frequency deviation
      • :BITRate {bps} set bit rate
      • :BITRate? get bit rate
      • :BT { 1.0 | 0.5 | 0.3 | 0.0 } set transmit shaping
      • :BT? get transmit shaping
      • :PRELen {n} set preamble size
      • :PRELen? get preamble size
      • :RXBW {Hz} set receive bandwidth
      • :RXBW? set receive bandwidth
      • :AFCBW {Hz} set receive bandwidth (during preamble)
      • :AFCBW? set receive bandwidth (during preamble)
      • :DCFree { OFF | MAN | WHIT } set DC-free encoding
      • :DCFree? get DC-free encoding
      • :RXTrigger { OFF | RSSI | PRE | BOTH } set RX trigger mode
      • :RXTrigger? get RX trigger selection

radio events

Radio events are reported into the Questionable Data Status Event Register, which is summarized in Bit 3 (QSB) of Status Byte Register.

enabling event and reading event

RA:MOD?
"LORa"
RA:OP?
"RXC"
STAT:QUES:ENAB 512
*STB?
8
STAT:QUES:EVEN?
512
RA:FI?
"4747474747474747"
*STB?
0

Bit 9 of QUEStionable event register indicates DIO0 event occurred upon radio packet reception.

NA Mote-72 specific commands

  • PD2 { OFF | ON } set power amplifier voltage state
  • PD2? get power amplifier voltage state
  • VBAT? read battery voltage
  • GPS
    • :EN { OFF | ON } enable GPS
    • :EN? get GPS enabled state
    • :NUMCoords {n} set count of coordinates received (use to clear count)
    • :NUMCoords? get count of coordinates received
    • :LOngitude {n} set longitude
    • :LOngitude? get longitude
    • :LAtitude {n} set latitude
    • :LAtitude? get latitude
  • MMA MMA8451Q
    • :ID? read ID register (WHO_AM_I == 0x1a)
  • MPL MPL3115A2
    • :ID? read ID register (WHO_AM_I == 0xc4)
  • SX9500
    • :RST reset SX9500
    • :REGister {addr}, {value} write SX9500 register
    • :REGister? {addr} read SX9500 register
Committer:
Wayne Roberts
Date:
Tue May 29 12:45:54 2018 -0700
Revision:
12:60990328c884
Parent:
9:73e03383fd21
update to latest libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ubhat 9:73e03383fd21 1 /*
ubhat 9:73e03383fd21 2 / _____) _ | |
ubhat 9:73e03383fd21 3 ( (____ _____ ____ _| |_ _____ ____| |__
ubhat 9:73e03383fd21 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
ubhat 9:73e03383fd21 5 _____) ) ____| | | || |_| ____( (___| | | |
ubhat 9:73e03383fd21 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
ubhat 9:73e03383fd21 7 (C)2013 Semtech
ubhat 9:73e03383fd21 8
ubhat 9:73e03383fd21 9 Description: Timer objects and scheduling management
ubhat 9:73e03383fd21 10
ubhat 9:73e03383fd21 11 License: Revised BSD License, see LICENSE.TXT file include in the project
ubhat 9:73e03383fd21 12
ubhat 9:73e03383fd21 13 Maintainer: Miguel Luis and Gregory Cristian
ubhat 9:73e03383fd21 14 */
ubhat 9:73e03383fd21 15 #include "timer.h"
ubhat 9:73e03383fd21 16
ubhat 9:73e03383fd21 17 Timer TimeCounter;
ubhat 9:73e03383fd21 18 Ticker LoadTimeCounter;
ubhat 9:73e03383fd21 19
ubhat 9:73e03383fd21 20 volatile uint32_t CurrentTime = 0;
ubhat 9:73e03383fd21 21
ubhat 9:73e03383fd21 22 void TimerResetTimeCounter( void )
ubhat 9:73e03383fd21 23 {
ubhat 9:73e03383fd21 24 CurrentTime = CurrentTime + TimeCounter.read_us( );
ubhat 9:73e03383fd21 25 TimeCounter.reset( );
ubhat 9:73e03383fd21 26 TimeCounter.start( );
ubhat 9:73e03383fd21 27 }
ubhat 9:73e03383fd21 28
ubhat 9:73e03383fd21 29 void TimerTimeCounterInit( void )
ubhat 9:73e03383fd21 30 {
ubhat 9:73e03383fd21 31 TimeCounter.start( );
ubhat 9:73e03383fd21 32 LoadTimeCounter.attach( &TimerResetTimeCounter, 10 );
ubhat 9:73e03383fd21 33 }
ubhat 9:73e03383fd21 34
ubhat 9:73e03383fd21 35 TimerTime_t TimerGetCurrentTime( void )
ubhat 9:73e03383fd21 36 {
ubhat 9:73e03383fd21 37 CurrentTime += TimeCounter.read_us( );
ubhat 9:73e03383fd21 38 TimeCounter.reset( );
ubhat 9:73e03383fd21 39 TimeCounter.start( );
ubhat 9:73e03383fd21 40 return ( ( TimerTime_t )CurrentTime );
ubhat 9:73e03383fd21 41 }
ubhat 9:73e03383fd21 42
ubhat 9:73e03383fd21 43 void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) )
ubhat 9:73e03383fd21 44 {
ubhat 9:73e03383fd21 45 obj->value = 0;
ubhat 9:73e03383fd21 46 obj->Callback = callback;
ubhat 9:73e03383fd21 47 }
ubhat 9:73e03383fd21 48
ubhat 9:73e03383fd21 49 void TimerStart( TimerEvent_t *obj )
ubhat 9:73e03383fd21 50 {
ubhat 9:73e03383fd21 51 obj->Timer.attach_us( obj->Callback, obj->value );
ubhat 9:73e03383fd21 52 }
ubhat 9:73e03383fd21 53
ubhat 9:73e03383fd21 54 void TimerStop( TimerEvent_t *obj )
ubhat 9:73e03383fd21 55 {
ubhat 9:73e03383fd21 56 obj->Timer.detach( );
ubhat 9:73e03383fd21 57 }
ubhat 9:73e03383fd21 58
ubhat 9:73e03383fd21 59 void TimerSetValue( TimerEvent_t *obj, uint32_t value )
ubhat 9:73e03383fd21 60 {
ubhat 9:73e03383fd21 61 obj->value = value;
ubhat 9:73e03383fd21 62 }