123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- #ifndef __RADIO_H__
- #define __RADIO_H__
- #include<stdint.h>
- #include<stdbool.h>
- #define USE_MODEM_LORA
-
- typedef enum
- {
- MODEM_FSK = 0,
- MODEM_LORA,
- }RadioModems_t;
- typedef enum
- {
- RF_IDLE = 0,
- RF_RX_RUNNING,
- RF_TX_RUNNING,
- RF_CAD,
- }RadioState_t;
- typedef struct
- {
-
- void ( *TxDone )( void );
-
- void ( *TxTimeout )( void );
-
- void ( *RxDone )( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
-
- void ( *RxTimeout )( void );
-
- void ( *RxError )( void );
-
- void ( *FhssChangeChannel )( uint8_t currentChannel );
-
- void ( *CadDone ) ( bool channelActivityDetected );
- }RadioEvents_t;
- struct Radio_s
- {
-
- void ( *Init )( RadioEvents_t *events );
-
- RadioState_t ( *GetStatus )( void );
-
- void ( *SetModem )( RadioModems_t modem );
-
- void ( *SetChannel )( uint32_t freq );
-
- bool ( *IsChannelFree )( RadioModems_t modem, uint32_t freq, int16_t rssiThresh, uint32_t maxCarrierSenseTime );
-
- uint32_t ( *Random )( void );
-
- void ( *SetRxConfig )( RadioModems_t modem, uint32_t bandwidth,
- uint32_t datarate, uint8_t coderate,
- uint32_t bandwidthAfc, uint16_t preambleLen,
- uint16_t symbTimeout, bool fixLen,
- uint8_t payloadLen,
- bool crcOn, bool freqHopOn, uint8_t hopPeriod,
- bool iqInverted, bool rxContinuous );
-
- void ( *SetTxConfig )( RadioModems_t modem, int8_t power, uint32_t fdev,
- uint32_t bandwidth, uint32_t datarate,
- uint8_t coderate, uint16_t preambleLen,
- bool fixLen, bool crcOn, bool freqHopOn,
- uint8_t hopPeriod, bool iqInverted, uint32_t timeout );
-
- bool ( *CheckRfFrequency )( uint32_t frequency );
-
- uint32_t ( *TimeOnAir )( RadioModems_t modem, uint8_t pktLen );
-
- void ( *Send )( uint8_t *buffer, uint8_t size );
-
- void ( *Sleep )( void );
-
- void ( *Standby )( void );
-
- void ( *Rx )( uint32_t timeout );
-
- void ( *StartCad )( void );
-
- void ( *SetTxContinuousWave )( uint32_t freq, int8_t power, uint16_t time );
-
- int16_t ( *Rssi )( RadioModems_t modem );
-
- void ( *Write )( uint16_t addr, uint8_t data );
-
- uint8_t ( *Read )( uint16_t addr );
-
- void ( *WriteBuffer )( uint16_t addr, uint8_t *buffer, uint8_t size );
-
- void ( *ReadBuffer )( uint16_t addr, uint8_t *buffer, uint8_t size );
-
- void ( *SetMaxPayloadLength )( RadioModems_t modem, uint8_t max );
-
- void ( *SetPublicNetwork )( bool enable );
-
- uint32_t ( *GetWakeupTime )( void );
-
- void ( *IrqProcess )( void );
-
-
- void ( *RxBoosted )( uint32_t timeout );
-
- void ( *SetRxDutyCycle ) ( uint32_t rxTime, uint32_t sleepTime );
- };
- extern const struct Radio_s Radio;
- #endif
|