Version of easy-connect with the u-blox cellular platforms C027 and C030 added.
SimpleSpirit1 Class Reference
Simple Spirit1 Class. More...
#include <SimpleSpirit1.h>
Public Member Functions | |
void | attach_irq_callback (Callback< void(int)> func) |
Attach a function to be called by the Spirit Irq handler when an event has occurred. | |
int | on (void) |
Switch Radio On. | |
int | off (void) |
Switch Radio Off. | |
void | set_channel (uint8_t channel) |
Set Channel. | |
int | send (const void *payload, unsigned int payload_len, bool use_csma_ca=true) |
Send a Buffer. | |
int | read (void *buf, unsigned int bufsize) |
Copy received data into buffer. | |
int | channel_clear (void) |
Perform a Clear-Channel Assessment (CCA) to find out if there is a packet in the air or not. | |
int | get_pending_packet (void) |
Check if the radio driver has just received a packet. | |
bool | is_receiving (void) |
Is radio currently receiving. | |
float | get_last_rssi_dbm (void) |
Get latest value of RSSI (in dBm) | |
uint8_t | get_last_rssi_raw (void) |
Get latest value of RSSI (as Spirit1 raw value) | |
uint8_t | get_last_sqi (void) |
Get latest value of LQI (scaled to 8-bit) | |
void | reset_board () |
Reset Board. | |
Static Public Member Functions | |
static SimpleSpirit1 & | CreateInstance (PinName mosi, PinName miso, PinName sclk, PinName irq, PinName cs, PinName sdn, PinName led=NC) |
Create singleton instance of 'SimpleSpirit1'. | |
static SimpleSpirit1 & | Instance () |
Create singleton instance of 'SimpleSpirit1'. | |
Protected Member Functions | |
void | disable_spirit_irq (void) |
Low Level Instance Methods. | |
void | spi_write_read (uint8_t *pBufferToWrite, uint8_t *pBufferToRead, uint16_t NumBytes) |
Write and read a buffer to/from the SPI peripheral device at the same time in 8-bit data mode using synchronous SPI communication. | |
void | radio_set_xtal_freq (uint32_t freq) |
Radio Instance Methods. | |
void | pkt_basic_init (PktBasicInit *pxPktBasicInit) |
Packet System Instance Methods. | |
void | irq_de_init (SpiritIrqs *pxIrqInit) |
IRQ Instance Methods. | |
void | mgmt_set_freq_base (uint32_t freq) |
Management Instance Methods. | |
void | spirit_gpio_init (SGpioInit *pxGpioInitStruct) |
Spirit GPIO Instance Methods. | |
void | qi_set_sqi_threshold (SqiThreshold xSqiThr) |
Qi Instance Methods. | |
void | timer_set_rx_timeout_stop_condition (RxTimeoutStopCondition xStopCondition) |
Timer Instance Methods. | |
void | csma_ca_state (SpiritFunctionalState xNewState) |
CSMA/CA Instance Methods. | |
void | cmd_strobe (uint8_t cmd) |
Command Instance Methods. | |
StatusBytes | spi_write_linear_fifo (uint8_t cNbBytes, uint8_t *pcBuffer) |
SPI Instance Methods. | |
uint8_t | linear_fifo_read_num_elements_rx_fifo (void) |
Linear FIFO Instance Methods. | |
void | calibration_rco (SpiritFunctionalState xNewState) |
Calibration Instance Methods. | |
void | set_ready_state (void) |
Internal Spirit Methods. | |
StatusBytes | SdkEvalSpiWriteRegisters (uint8_t cRegAddress, uint8_t cNbBytes, uint8_t *pcBuffer) |
Sdk Instance Methods. | |
void | chip_sync_select () |
Helper Instance Methods. | |
void | init () |
Init Instance Method. | |
void | IrqHandler () |
Spirit Irq Callback. | |
SimpleSpirit1 (PinName mosi, PinName miso, PinName sclk, PinName irq, PinName cs, PinName sdn, PinName led) | |
Constructor. | |
~SimpleSpirit1 (void) | |
Destructor. | |
Protected Attributes | |
UnlockedSPI | _spi |
Communication Interface Instance Variables. | |
volatile uint16_t | spirit_tx_len |
Static Variables from Cube Implementation. | |
unsigned int | spirit_on |
Status Variables from Cube Implementation. | |
unsigned int | _nr_of_irq_disables |
Low Level Instance Variables. | |
Static Protected Attributes | |
static SimpleSpirit1 * | _singleton = NULL |
Static Class Variables. | |
Friends | |
StatusBytes | SdkEvalSpiWriteRegisters (uint8_t cRegAddress, uint8_t cNbBytes, uint8_t *pcBuffer) |
Friend Functions. | |
StatusBytes | SdkEvalSpiReadRegisters (uint8_t cRegAddress, uint8_t cNbBytes, uint8_t *pcBuffer) |
Read single or multiple SPIRIT1 register. | |
StatusBytes | SdkEvalSpiCommandStrobes (uint8_t cCommandCode) |
Send a command. | |
StatusBytes | SdkEvalSpiWriteFifo (uint8_t cNbBytes, uint8_t *pcBuffer) |
Write data into TX FIFO. | |
StatusBytes | SdkEvalSpiReadFifo (uint8_t cNbBytes, uint8_t *pcBuffer) |
Read data from RX FIFO. |
Detailed Description
Simple Spirit1 Class.
Synchronization level: implementation is IRQ-save but (intentionally) NOT thread-safe!!!
Example:
#include "mbed.h" #include "SimpleSpirit1.h" static char *send_buf = "Hello World!"; static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(D11, D12, D3, D9, D10, D2); static volatile bool tx_done_flag = false; static void callback_func(int event) { if (event == SimpleSpirit1::TX_DONE) { tx_done_flag = true; } } int main() { myspirit.on(); while(1) { size_t curr_len = strlen((const char*)send_buf); myspirit.send(send_buf, curr_len); while(!tx_done_flag); tx_done_flag = false; } }
Definition at line 98 of file SimpleSpirit1.h.
Constructor & Destructor Documentation
SimpleSpirit1 | ( | PinName | mosi, |
PinName | miso, | ||
PinName | sclk, | ||
PinName | irq, | ||
PinName | cs, | ||
PinName | sdn, | ||
PinName | led | ||
) | [protected] |
Constructor.
Definition at line 34 of file SimpleSpirit1.cpp.
~SimpleSpirit1 | ( | void | ) | [protected] |
Destructor.
Member Function Documentation
void attach_irq_callback | ( | Callback< void(int)> | func ) |
Attach a function to be called by the Spirit Irq handler when an event has occurred.
- Parameters:
-
func A void(int) callback, or 0 to set as none
- Note:
- Function 'func' will be executed in interrupt context!
- Function 'func' will be call with either 'RX_DONE', 'TX_DONE', or 'TX_ERR' as parameter to indicate which event has occurred.
Definition at line 471 of file SimpleSpirit1.h.
void calibration_rco | ( | SpiritFunctionalState | xNewState ) | [protected] |
Calibration Instance Methods.
Definition at line 363 of file SimpleSpirit1.h.
int channel_clear | ( | void | ) |
Perform a Clear-Channel Assessment (CCA) to find out if there is a packet in the air or not.
- Returns:
- 1 if packet has been seen.
Spirit Irq Callback
Definition at line 381 of file SimpleSpirit1.cpp.
void chip_sync_select | ( | ) | [protected] |
Helper Instance Methods.
Definition at line 386 of file SimpleSpirit1.h.
void cmd_strobe | ( | uint8_t | cmd ) | [protected] |
Command Instance Methods.
Definition at line 332 of file SimpleSpirit1.h.
static SimpleSpirit1& CreateInstance | ( | PinName | mosi, |
PinName | miso, | ||
PinName | sclk, | ||
PinName | irq, | ||
PinName | cs, | ||
PinName | sdn, | ||
PinName | led = NC |
||
) | [static] |
Create singleton instance of 'SimpleSpirit1'.
- Parameters:
-
mosi 'PinName' of mosi pin to use miso 'PinName' of miso pin to use sclk 'PinName' of clock pin to use irq 'PinName' of interrupt pin to use cs 'PinName' of chip-select pin pin to use sdn 'PinName' of pin to use for device shutdown
- Returns:
- reference to singleton instance
Definition at line 429 of file SimpleSpirit1.h.
void csma_ca_state | ( | SpiritFunctionalState | xNewState ) | [protected] |
CSMA/CA Instance Methods.
Definition at line 321 of file SimpleSpirit1.h.
void disable_spirit_irq | ( | void | ) | [protected] |
Low Level Instance Methods.
Definition at line 160 of file SimpleSpirit1.h.
float get_last_rssi_dbm | ( | void | ) |
Get latest value of RSSI (in dBm)
Definition at line 529 of file SimpleSpirit1.h.
uint8_t get_last_rssi_raw | ( | void | ) |
Get latest value of RSSI (as Spirit1 raw value)
Definition at line 536 of file SimpleSpirit1.h.
uint8_t get_last_sqi | ( | void | ) |
Get latest value of LQI (scaled to 8-bit)
Definition at line 545 of file SimpleSpirit1.h.
int get_pending_packet | ( | void | ) |
Check if the radio driver has just received a packet.
void init | ( | ) | [protected] |
static SimpleSpirit1& Instance | ( | ) | [static] |
Create singleton instance of 'SimpleSpirit1'.
- Parameters:
-
mosi 'PinName' of mosi pin to use miso 'PinName' of miso pin to use sclk 'PinName' of clock pin to use irq 'PinName' of interrupt pin to use cs 'PinName' of chip-select pin pin to use sdn 'PinName' of pin to use for device shutdown
- Returns:
- reference to singleton instance
Definition at line 455 of file SimpleSpirit1.h.
void irq_de_init | ( | SpiritIrqs * | pxIrqInit ) | [protected] |
IRQ Instance Methods.
Definition at line 251 of file SimpleSpirit1.h.
void IrqHandler | ( | ) | [protected] |
Spirit Irq Callback.
bool is_receiving | ( | void | ) |
Is radio currently receiving.
Definition at line 523 of file SimpleSpirit1.h.
uint8_t linear_fifo_read_num_elements_rx_fifo | ( | void | ) | [protected] |
Linear FIFO Instance Methods.
Definition at line 350 of file SimpleSpirit1.h.
void mgmt_set_freq_base | ( | uint32_t | freq ) | [protected] |
Management Instance Methods.
Definition at line 268 of file SimpleSpirit1.h.
int off | ( | void | ) |
Switch Radio Off.
Definition at line 281 of file SimpleSpirit1.cpp.
int on | ( | void | ) |
Switch Radio On.
Definition at line 305 of file SimpleSpirit1.cpp.
void pkt_basic_init | ( | PktBasicInit * | pxPktBasicInit ) | [protected] |
Packet System Instance Methods.
Definition at line 238 of file SimpleSpirit1.h.
void qi_set_sqi_threshold | ( | SqiThreshold | xSqiThr ) | [protected] |
Qi Instance Methods.
Definition at line 282 of file SimpleSpirit1.h.
void radio_set_xtal_freq | ( | uint32_t | freq ) | [protected] |
Radio Instance Methods.
Definition at line 213 of file SimpleSpirit1.h.
int read | ( | void * | buf, |
unsigned int | bufsize | ||
) |
Copy received data into buffer.
- Parameters:
-
buf pointer to buffer to be filled bufsize size of buffer
- Returns:
- number of bytes copied into the buffer
- Note:
- the buffer should be (at least) of size 'SPIRIT1_MAX_PAYLOAD' (in bytes).
Definition at line 342 of file SimpleSpirit1.cpp.
void reset_board | ( | ) |
Reset Board.
Definition at line 557 of file SimpleSpirit1.h.
StatusBytes SdkEvalSpiWriteRegisters | ( | uint8_t | cRegAddress, |
uint8_t | cNbBytes, | ||
uint8_t * | pcBuffer | ||
) | [protected] |
Sdk Instance Methods.
int send | ( | const void * | payload, |
unsigned int | payload_len, | ||
bool | use_csma_ca = true |
||
) |
Send a Buffer.
- Parameters:
-
payload pointer to buffer to be send payload_len length of payload buffer in bytes use_csma_ca should CSMA/CA be enabled for transmission
- Returns:
- zero in case of success, non-zero error code otherwise
- Note:
- the maximum payload size in bytes allowed is defined by macro 'SPIRIT1_MAX_PAYLOAD'
Definition at line 168 of file SimpleSpirit1.cpp.
void set_channel | ( | uint8_t | channel ) |
Set Channel.
Definition at line 484 of file SimpleSpirit1.h.
void set_ready_state | ( | void | ) | [protected] |
StatusBytes spi_write_linear_fifo | ( | uint8_t | cNbBytes, |
uint8_t * | pcBuffer | ||
) | [protected] |
SPI Instance Methods.
Definition at line 341 of file SimpleSpirit1.h.
void spi_write_read | ( | uint8_t * | pBufferToWrite, |
uint8_t * | pBufferToRead, | ||
uint16_t | NumBytes | ||
) | [protected] |
Write and read a buffer to/from the SPI peripheral device at the same time in 8-bit data mode using synchronous SPI communication.
- Parameters:
-
[in] pBufferToWrite pointer to the buffer of data to send. [out] pBufferToRead pointer to the buffer to read data into. [in] NumBytes number of bytes to read and write.
- Return values:
-
0 if ok. -1 if data format error.
- Note:
- When using the SPI in Interrupt-mode, remember to disable interrupts before calling this function and to enable them again after.
Definition at line 204 of file SimpleSpirit1.h.
void spirit_gpio_init | ( | SGpioInit * | pxGpioInitStruct ) | [protected] |
Spirit GPIO Instance Methods.
Definition at line 277 of file SimpleSpirit1.h.
void timer_set_rx_timeout_stop_condition | ( | RxTimeoutStopCondition | xStopCondition ) | [protected] |
Timer Instance Methods.
Definition at line 308 of file SimpleSpirit1.h.
Field Documentation
unsigned int _nr_of_irq_disables [protected] |
Low Level Instance Variables.
Definition at line 157 of file SimpleSpirit1.h.
SimpleSpirit1 * _singleton = NULL [static, protected] |
Static Class Variables.
Definition at line 100 of file SimpleSpirit1.h.
UnlockedSPI _spi [protected] |
Communication Interface Instance Variables.
Definition at line 103 of file SimpleSpirit1.h.
unsigned int spirit_on [protected] |
Status Variables from Cube Implementation.
Definition at line 152 of file SimpleSpirit1.h.
volatile uint16_t spirit_tx_len [protected] |
Static Variables from Cube Implementation.
Definition at line 143 of file SimpleSpirit1.h.
Generated on Tue Jul 12 2022 15:14:32 by 1.7.2