Library files for InAir9 module containing SX1272
Fork of SX1272Lib by
Diff: sx1272/sx1272.h
- Revision:
- 4:90bd79f1b458
- Parent:
- 3:5baff45eb3c5
--- a/sx1272/sx1272.h Thu Mar 10 10:20:44 2016 +0000 +++ b/sx1272/sx1272.h Fri May 13 14:49:34 2016 +0000 @@ -23,7 +23,18 @@ /*! * Radio wakeup time from SLEEP mode */ -#define RADIO_WAKEUP_TIME 1000 // [us] +#define RADIO_OSC_STARTUP 1000 // [us] + +/*! + * Radio PLL lock and Mode Ready delay which can vary with the temperature + */ +#define RADIO_SLEEP_TO_RX 2000 // [us] + +/*! + * Radio complete Wake-up Time with margin for temperature compensation + */ +#define RADIO_WAKEUP_TIME ( RADIO_OSC_STARTUP + RADIO_SLEEP_TO_RX ) + /*! * SX1272 definitions @@ -64,34 +75,34 @@ InterruptIn dio3; InterruptIn dio4; DigitalIn dio5; - + bool isRadioActive; - + uint8_t boardConnected; //1 = SX1272MB1DCS; 0 = SX1272MB1DAS - + uint8_t *rxtxBuffer; uint8_t currentOpMode; - + /*! * Hardware DIO IRQ functions */ DioIrqHandler *dioIrq; - + /*! * Tx and Rx timers */ Timeout txTimeoutTimer; Timeout rxTimeoutTimer; Timeout rxTimeoutSyncWord; - + /*! * rxTx: [1: Tx, 0: Rx] */ uint8_t rxTx; - + RadioSettings_t settings; - + static const FskBandwidth_t FskBandwidths[] ; protected: @@ -124,7 +135,7 @@ * @param status Radio status. [RF_IDLE, RX_RUNNING, TX_RUNNING] */ virtual RadioState GetStatus( void ); - + /*! * @brief Configures the SX1272 with the given modem * @@ -138,7 +149,7 @@ * @param [IN] freq Channel RF frequency */ virtual void SetChannel( uint32_t freq ); - + /*! * @brief Sets the channels configuration * @@ -149,7 +160,7 @@ * @retval isFree [true: Channel is free, false: Channel is not free] */ virtual bool IsChannelFree( RadioModems_t modem, uint32_t freq, int16_t rssiThresh ); - + /*! * @brief Generates a 32 bits random value based on the RSSI readings * @@ -161,7 +172,7 @@ * @retval randomValue 32 bits random value */ virtual uint32_t Random( void ); - + /*! * @brief Sets the reception parameters * @@ -204,7 +215,7 @@ uint8_t payloadLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, bool rxContinuous ); - + /*! * @brief Sets the transmission parameters * @@ -239,7 +250,7 @@ uint8_t coderate, uint16_t preambleLen, bool fixLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, uint32_t timeout ); - + /*! * @brief Computes the packet time on air for the given payload * @@ -251,7 +262,7 @@ * @retval airTime Computed airTime for the given packet payload length */ virtual double TimeOnAir ( RadioModems_t modem, uint8_t pktLen ); - + /*! * @brief Sends the buffer of size. Prepares the packet to be sent and sets * the radio in transmission @@ -260,7 +271,7 @@ * @param [IN]: size Buffer size */ virtual void Send( uint8_t *buffer, uint8_t size ); - + /*! * @brief Sets the radio in sleep mode */ @@ -270,33 +281,33 @@ * @brief Sets the radio in standby mode */ virtual void Standby( void ); - + /*! * @brief Sets the radio in reception mode for the given time * @param [IN] timeout Reception timeout [us] * [0: continuous, others timeout] */ virtual void Rx( uint32_t timeout ); - + /*! * @brief Sets the radio in transmission mode for the given time * @param [IN] timeout Transmission timeout [us] * [0: continuous, others timeout] */ virtual void Tx( uint32_t timeout ); - + /*! * @brief Start a Channel Activity Detection */ virtual void StartCad( void ); - + /*! * @brief Reads the current RSSI value * * @retval rssiValue Current RSSI value in [dBm] */ virtual int16_t GetRssi ( RadioModems_t modem ); - + /*! * @brief Writes the radio register at the specified address * @@ -304,7 +315,7 @@ * @param [IN]: data New register value */ virtual void Write ( uint8_t addr, uint8_t data ) = 0; - + /*! * @brief Reads the radio register at the specified address * @@ -312,7 +323,7 @@ * @retval data Register value */ virtual uint8_t Read ( uint8_t addr ) = 0; - + /*! * @brief Writes multiple radio registers starting at address * @@ -321,7 +332,7 @@ * @param [IN] size Number of registers to be written */ virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0; - + /*! * @brief Reads multiple radio registers starting at address * @@ -330,7 +341,7 @@ * @param [IN] size Number of registers to be read */ virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0; - + /*! * @brief Writes the buffer contents to the SX1272 FIFO * @@ -350,7 +361,7 @@ * @brief Resets the SX1272 */ virtual void Reset( void ) = 0; - + /*! * @brief Sets the maximum payload length. * @@ -358,11 +369,11 @@ * @param [IN] max Maximum payload length in bytes */ virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max ); - + //------------------------------------------------------------------------- // Board relative functions //------------------------------------------------------------------------- - + protected: /*! * @brief Initializes the radio I/Os pins interface @@ -378,7 +389,7 @@ * @brief Initializes the radio SPI */ virtual void SpiInit( void ) = 0; - + /*! * @brief Initializes DIO IRQ handlers * @@ -428,7 +439,7 @@ * @param [IN] rxTx [1: Tx, 0: Rx] */ virtual void SetAntSw( uint8_t rxTx ) = 0; - + /*! * @brief Checks if the given RF frequency is supported by the hardware * @@ -483,7 +494,7 @@ * @brief Tx & Rx timeout timer callback */ virtual void OnTimeoutIrq( void ); - + /*! * Returns the known FSK bandwidth registers value *