1 /*!
2  * \file      lr1110.h
3  *
4  * \brief     LR1110 driver implementation
5  *
6  * \copyright Revised BSD License, see file LICENSE.txt
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2019-2019 Semtech
16  *
17  * \endcode
18  */
19 
20 #ifndef __LR1110_H__
21 #define __LR1110_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <stdint.h>
28 #include <stdbool.h>
29 #include <math.h>
30 #include "gpio.h"
31 #include "spi.h"
32 #include "radio.h"
33 #include "lr1110_hal.h"
34 #include "lr1110_radio_types.h"
35 
36 /*!
37  * \brief The type describing the modulation parameters for every packet types
38  */
39 typedef struct
40 {
41     lr1110_radio_packet_types_t packet_type;  //!< Packet to which the modulation parameters are referring to.
42     struct
43     {
44         lr1110_radio_modulation_param_gfsk_t gfsk;
45         lr1110_radio_modulation_param_lora_t lora;
46     }modulation;  //!< Holds the modulation parameters structure
47 } lr1110_modulation_params_t;
48 
49 /*!
50  * \brief The type describing the packet parameters for every packet types
51  */
52 typedef struct
53 {
54     lr1110_radio_packet_types_t packet_type;  //!< Packet to which the packet parameters are referring to.
55     struct
56     {
57         lr1110_radio_packet_param_gfsk_t gfsk;
58         lr1110_radio_packet_param_lora_t lora;
59     }packet;  //!< Holds the packet parameters structure
60 } lr1110_packet_params_t;
61 
62 /*!
63  * \brief Radio operating modes
64  */
65 typedef enum lr1110_hal_operating_mode_e
66 {
67     LR1110_HAL_OP_MODE_SLEEP = 0x00,  //! The radio is in sleep mode
68     LR1110_HAL_OP_MODE_STDBY_RC,      //! The radio is in standby mode with RC oscillator
69     LR1110_HAL_OP_MODE_STDBY_XOSC,    //! The radio is in standby mode with XOSC oscillator
70     LR1110_HAL_OP_MODE_FS,            //! The radio is in frequency synthesis mode
71     LR1110_HAL_OP_MODE_TX,            //! The radio is in transmit mode
72     LR1110_HAL_OP_MODE_RX,            //! The radio is in receive single mode
73     LR1110_HAL_OP_MODE_RX_C,          //! The radio is in receive continuous mode
74     LR1110_HAL_OP_MODE_RX_DC,         //! The radio is in receive duty cycle mode
75     LR1110_HAL_OP_MODE_CAD            //! The radio is in channel activity detection mode
76 } lr1110_hal_operating_mode_t;
77 
78 /*!
79  * Radio hardware and global parameters
80  */
81 typedef struct lr1110_s
82 {
83     Gpio_t                      reset;
84     Gpio_t                      busy;
85     Gpio_t                      dio_1;
86     Spi_t                       spi;
87     lr1110_hal_operating_mode_t op_mode;
88     lr1110_modulation_params_t  modulation_params;
89     lr1110_packet_params_t      packet_params;
90 } lr1110_t;
91 
92 /*!
93  * Hardware IO IRQ callback function definition
94  */
95 typedef void ( *lr1110_dio_irq_handler )( void* context );
96 
97 /*!
98  * Get radio operating mode
99  *
100  * \remark Must be implemented by the upper layer
101  *
102  * \param [in] context Radio implementation parameters
103  * \retval     op_mode Radio current operating mode
104  */
105 lr1110_hal_operating_mode_t lr1110_hal_get_operating_mode( const void* context );
106 
107 /*!
108  * Set radio operating mode
109  *
110  * \remark Must be implemented by the upper layer
111  *
112  * \param [in] context Radio implementation parameters
113  * \param [in] op_mode Radio operating mode
114  */
115 void lr1110_hal_set_operating_mode( const void* context, const lr1110_hal_operating_mode_t op_mode );
116 
117 #endif  // __LR1110_H__
118