In this article:
Hardware interface related API.
Module pins
Module I/O pin definitions.
enum
ModulePinDef
Values | Descriptions |
---|---|
PIN_BAND | read-only |
PIN_ADC1 | |
PIN_ADC0 | |
PIN_PULSE1 | |
PIN_PULSE0 | |
PIN_UART0_RTS | |
PIN_GPIO2 | |
PIN_GPIO3 | |
PIN_RF_EN | read-only |
PIN_SPI_CS | |
PIN_SPI_SCK | |
PIN_SPI_MISO | |
PIN_SPI_MOSI | |
PIN_GPIO0_WKUP | |
PIN_GPIO4 | |
PIN_GPIO5 | |
PIN_GPIO6 | |
PIN_GPIO1_WKUP | |
PIN_UART1_RX | |
PIN_UART1_TX | |
PIN_I2C_SCL | |
PIN_I2C_SDA | |
PIN_GPIO8 | |
PIN_GPIO7 | |
PIN_UART0_CTS | |
PIN_UART0_TX | |
PIN_UART0_RX | |
PIN_LEUART_RX | |
PIN_LEUART_TX | |
PIN_MAX |
Module pin definitions.
ADC
PinNum can be PIN_ADC0 or PIN_ADC1.
enum
ADCReference
Values | Descriptions |
---|---|
ADC_REF_VIO | use VIO_REF as reference voltage |
ADC_REF_2V5 | use 2.5V as reference voltage |
ADC_REF_1V25 | use 1.25V as reference voltage |
Reference voltages.
int
ADCGetVoltage
(uint8_t PinNum,
ADCReference
Reference,uint32_t * mV)
Get the converted voltage (mV) from the MCU ADC port.
Returns 0 if read succeeds and -1 if read fails.
int
ADCGetValue
(uint8_t PinNum,
ADCReference
Reference,uint16_t * Value)
Get raw value from the ADC port (0 - 0xFFF).
Returns 0 if read succeeds and -1 if read fails.
I²C master
enum
I2COption
Values | Descriptions |
---|---|
I2C_DEFAULT_OPTIONS | |
I2C_FAST_MODE | ~400 kbit/s, default standard mode (~100 kbit/s) |
I²C options, can be ORed.
int
I2CInit
(void)
Initialise I²C bus.
Returns 0 if initialisation succeeds and -1 if initialisation fails.
int
I2CInitEx
(uint32_t Option)
Initialise I²C bus with options.
Returns 0 if initialisation succeeds and -1 if initialisation fails.
void
I2CDeinit
(void)
Deinitialise I²C bus.
int
I2CWrite
(uint16_t DeviceAddress,const uint8_t * Command,size_t CommandLength)
Write to an I²C device synchronously.
Returns 0 if write succeeds and -1 if read fails.
int
I2CRead
(uint16_t DeviceAddress,const uint8_t * Command,size_t CommandLength,uint8_t * Rx,size_t RxLength)
Read from an I²C device.
Returns 0 if read succeeds and -1 if read fails.
SPI master
enum
SPIBaudrate
Values | Descriptions |
---|---|
SPI_BAUDRATE_DEFAULT | default SPI baudrate |
SPI_BAUDRATE_MAX | maximum SPI baudrate |
SPI baudrate.
int
SPIInit
(uint32_t BaudRate)
Initialise SPI master.
Returns 0 if initialisation succeeds and -1 if initialisation fails.
void
SPIDeinit
(void)
Deinitialise SPI master.
int
SPIWrite
(const uint8_t * Tx,size_t Length)
Write to an SPI device synchronously.
Returns 0 if write succeeds and -1 if write fails.
int
SPITransfer
(const uint8_t * Tx,uint8_t * Rx,size_t Length)
SPI data transfer.
Returns 0 if transfer succeeds and -1 if transfer fails.
GPIO
PinNum can be any pin in ModulePinDef.
enum
GPIOLevel
Values | Descriptions |
---|---|
GPIO_LOW | |
GPIO_HIGH |
GPIO level.
enum
GPIOPull
Values | Descriptions |
---|---|
GPIO_NO_PULL | no module internal pull up or pull down |
GPIO_PULL_UP | module internal pull up |
GPIO_PULL_DOWN | module internal pull down |
GPIO internal pull up/down.
int
GPIOSetModeInput
(uint8_t PinNum,
GPIOPull
Pull)
Set a GPIO to input mode and the internal pull up/down.
Returns 0 if succeeded and -1 if failed.
int
GPIOSetModeOutput
(uint8_t PinNum)
Set a GPIO to output mode.
Returns 0 if succeeded and -1 if failed.
int
GPIOSetHigh
(uint8_t PinNum)
Set a GPIO output high.
Returns 0 if succeeded and -1 if failed.
int
GPIOSetLow
(uint8_t PinNum)
Set a GPIO output low.
Returns 0 if succeeded and -1 if failed.
int
GPIOGet
(uint8_t PinNum)
Get input level of a GPIO.
Returns GPIOLevel if succeeded and -1 if failed.
int
GPIOSetWakeupLevel
(uint8_t PinNum,
GPIOLevel
Level)
Set level polarity of a GPIO pin with wakeup capability for next wakeup.
Make sure to set the GPIO to input mode. Returns 0 if succeeded and -1 if failed.
int
GPIODisableWakeup
(uint8_t PinNum)
Disable wakeup capability of a GPIO pin.
UART
enum
UARTInterface
Values | Descriptions |
---|---|
UART_0 | can be used for firmware update via the bootloader |
UART_1 | used by GNSS |
LEUART | low energy, only supports baudrate up to 9600 |
UART interfaces.
void *
UARTInit
(
UARTInterface
UARTNum,uint32_t BaudRate,uint32_t Options)
Initialise a uart interface, options are not supported and should be 0.
UARTNum is the UART number defined by enum UARTInterface. Returns the handle if succeeded and NULL if failed.
void
UARTDeinit
(void * Handle)
Deintialise a UART interface.
int
UARTWrite
(void * Handle,const uint8_t * Tx,size_t Length)
Write to a UART interface synchronously.
Returns 0 if write succeeds and -1 if read fails.
int
UARTRead
(void * Handle,uint8_t * Rx,size_t Length)
Read from input buffer of a UART interface.
The buffer size is 50 bytes. Returns number of bytes read back and -1 if read fails.
Pulse counter
enum
PulseCounterOption
Values | Descriptions |
---|---|
PCNT_DEFAULT_OPTIONS | |
PCNT_EDGE_FALLING | count on falling edge, default rising edge |
PCNT_DEBOUNCE_DISABLE | disable hardware debouncing, default enabled for about 160us |
PCNT_PULL_UP | enable pull-up, default pull-down |
Pulse counter bit-wise options, can be ORed.
int
PulseCounterInit
(uint32_t Limit,uint32_t Options)
Initialise the pulse counter and configure the event generation logic.
Event is generated when pulse count hits multiple of Limit. Limit can be set to 0 to 256, or multiple of 256. Set Limit to 0 to disable event generation. Options are used to configure the pulse counter. Set option to 0 to count on rising edge, and enable debouncing. Returns 0 if succeeded and -1 if failed.
uint64_t
PulseCounterGet
(void)
Get the total count of the pulse counter.
Returns the total count.
void
PulseCounterDeinit
(void)
Deinitialise the pulse counter.
Satellite radio RF test
enum
RFTestTxType
Values | Descriptions |
---|---|
TX_TYPE_TONE | transmit tone, i.e. CW |
TX_TYPE_PRBS | transmit pseudorandom binary sequence |
RF test Tx type.
int
RFTestTxStart
(uint32_t Frequency,uint8_t TxType,bool IsBurst)
Start the RF Tx test.
The default LED is on when transmitting. The antenna port should be connected to a load when testing. Frequency
is in Hertz. TxType
can be tone or pseudorandom binary sequence defined by RFTestTxType. When testing in burst mode, the radio is on for 260ms and off for 1740ms. Otherwise the radio transmits continuously. Returns 0 if succeeded and -1 if failed.
void
RFTestTxStop
(void)
Stop the RF Tx test.
int
RFTestRxStart
(uint32_t Frequency)
Turn on the satellite radio receiver.
Frequency
is in Hertz. Returns 0 if succeeded and -1 if failed.
int
RFTestRxRSSI
(int32_t * RSSI)
Get current RSSI from radio receiver.
RSSI
is in dBm. Returns 0 if succeeded and -1 if failed.
void
RFTestRxStop
(void)
Stop the RF Rx test.
Satellite radio statistics
void
RxStatsGet
(void * Stats)
Get satellite radio receiver (downlink) statistics. Two values are returned in SDK 2+:
/// Rx stats type, both counters exclude messages sent to the device by the user
typedef struct {
uint16_t attempts; ///< Number of attempts made to receive a packet
uint16_t successes; ///< Number of successful packets
} RxStats_t;
and three in SDK 1.5.6:
typedef struct {
uint16_t attempts; ///< Number of attempts made to receive a packet
uint16_t unverified; ///< Number of packets failed signature verification
uint16_t verified; ///< Number of successful packets
} RxStats_t;
User NVRAM (persistent storage)
#define
NVRAM_MEM_SIZE
2048
void
NvramClear
()
Clear the NVRAM.
NVRAM should be cleared before overwriting the existing contents. The NVRAM is filled with 0xFF after being cleared.
int
NvramWrite
(uint32_t Offset,const uint8_t * Buf,size_t Length)
Write buffer contents to NVRAM, starting from offset.
Returns 0 if succeeded and -1 if failed.