SX126x-Arduino  2.0.1
board.h
Go to the documentation of this file.
1 /*
2  / _____) _ | |
3 ( (____ _____ ____ _| |_ _____ ____| |__
4  \____ \| ___ | (_ _) ___ |/ ___) _ \
5  _____) ) ____| | | || |_| ____( (___| | | |
6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
7  (C)2013 Semtech
8 
9 Description: Target board general functions implementation
10 
11 License: Revised BSD License, see LICENSE.TXT file include in the project
12 
13 Maintainer: Miguel Luis and Gregory Cristian
14 */
15 
16 /******************************************************************************
17  * @file board.h
18  * @author Insight SiP
19  * @version V2.0.0
20  * @date 30-january-2019
21  * @brief Board (module) specific functions declaration.
22  *
23  * @attention
24  * THIS SOFTWARE IS PROVIDED BY INSIGHT SIP "AS IS" AND ANY EXPRESS
25  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL INSIGHT SIP OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  *****************************************************************************/
36 
37 #ifndef __BOARD_H__
38 #define __BOARD_H__
39 
40 #include <Arduino.h>
41 
42 #include <stdbool.h>
43 #include <stdlib.h>
44 #include <stdio.h>
45 #include <string.h>
46 #include <stdint.h>
47 
48 #include "radio/radio.h"
49 #include "radio/sx126x/sx126x.h"
51 #include "timer.h"
52 #include "sx126x-debug.h"
53 
54 // SX126x chip type
55 #define SX1261_CHIP 1
56 #define SX1262_CHIP 2
57 #define SX1268_CHIP 2
58 
59 // Microcontroller - SX126x pin configuration
60 struct hw_config
61 {
62  int CHIP_TYPE = SX1262_CHIP; // Module type, see defines above
63  int PIN_LORA_RESET; // LORA RESET
64  int PIN_LORA_NSS; // LORA SPI CS
65  int PIN_LORA_SCLK; // LORA SPI CLK
66  int PIN_LORA_MISO; // LORA SPI MISO
67  int PIN_LORA_DIO_1; // LORA DIO_1
68  int PIN_LORA_BUSY; // LORA SPI BUSY
69  int PIN_LORA_MOSI; // LORA SPI MOSI
70  int RADIO_TXEN = -1; // LORA ANTENNA TX ENABLE (eByte E22 module only)
71  int RADIO_RXEN = -1; // LORA ANTENNA RX ENABLE (eByte E22 module only)
72  bool USE_DIO2_ANT_SWITCH = false; // Whether DIO2 is used to control the antenna
73  bool USE_DIO3_TCXO = false; // Whether DIO3 is used to control the oscillator
74  bool USE_DIO3_ANT_SWITCH = false; // Whether DIO2 is used to control the antenna
75  bool USE_LDO = false; // Whether SX126x uses LDO or DCDC power regulator
76  bool USE_RXEN_ANT_PWR = false; // Whether RX_EN is used as antenna power
77 };
78 
79 extern "C"
80 {
81 
82  extern hw_config _hwConfig;
83 
88  uint32_t lora_hardware_init(hw_config hwConfig);
89 
94  uint32_t lora_hardware_re_init(hw_config hwConfig);
95 
100  uint32_t lora_isp4520_init(int chipType);
101 
104  uint32_t lora_rak4630_init(void);
105 
109  void lora_hardware_uninit(void);
110 
115  uint32_t BoardGetRandomSeed(void);
116 
121  void BoardGetUniqueId(uint8_t *id);
122 
125  uint8_t BoardGetBatteryLevel(void);
126 
131  void BoardDisableIrq(void);
132 
137  void BoardEnableIrq(void);
138 
143  bool start_lora_task(void);
144 };
145 #endif // __BOARD_H__
radio.h
Radio driver API definition.
sx126x-board.h
BoardGetBatteryLevel
uint8_t BoardGetBatteryLevel(void)
Get batttery value TO BE IMPLEMENTED.
hw_config::USE_LDO
bool USE_LDO
Definition: board.h:75
lora_hardware_uninit
void lora_hardware_uninit(void)
De-initializes the target board peripherals to decrease power consumption.
Definition: board.cpp:279
hw_config::RADIO_TXEN
int RADIO_TXEN
Definition: board.h:70
BoardEnableIrq
void BoardEnableIrq(void)
Enable interrupts.
start_lora_task
bool start_lora_task(void)
Initialize LoRa handler task (ESP32 & nRF52)
hw_config::USE_DIO2_ANT_SWITCH
bool USE_DIO2_ANT_SWITCH
Definition: board.h:72
_hwConfig
hw_config _hwConfig
Definition: board.cpp:49
hw_config::PIN_LORA_MOSI
int PIN_LORA_MOSI
Definition: board.h:69
BoardGetRandomSeed
uint32_t BoardGetRandomSeed(void)
Returns a pseudo random seed generated using the MCU Unique ID.
hw_config::USE_RXEN_ANT_PWR
bool USE_RXEN_ANT_PWR
Definition: board.h:76
timer.h
lora_hardware_init
uint32_t lora_hardware_init(hw_config hwConfig)
Initializes the target board peripherals.
Definition: board.cpp:56
hw_config::CHIP_TYPE
int CHIP_TYPE
Definition: board.h:62
sx126x-debug.h
Unified debug output for all platforms Set LIB_DEBUG to 1 to enable debug output.
hw_config::PIN_LORA_NSS
int PIN_LORA_NSS
Definition: board.h:64
sx126x.h
SX126x driver implementation.
SX1262_CHIP
#define SX1262_CHIP
Definition: board.h:56
hw_config::USE_DIO3_ANT_SWITCH
bool USE_DIO3_ANT_SWITCH
Definition: board.h:74
BoardDisableIrq
void BoardDisableIrq(void)
Disable interrupts.
hw_config::PIN_LORA_DIO_1
int PIN_LORA_DIO_1
Definition: board.h:67
hw_config::PIN_LORA_SCLK
int PIN_LORA_SCLK
Definition: board.h:65
hw_config
Definition: board.h:61
hw_config::USE_DIO3_TCXO
bool USE_DIO3_TCXO
Definition: board.h:73
lora_hardware_re_init
uint32_t lora_hardware_re_init(hw_config hwConfig)
Initializes the target board peripherals after deep sleep wake up.
Definition: board.cpp:103
hw_config::PIN_LORA_MISO
int PIN_LORA_MISO
Definition: board.h:66
lora_isp4520_init
uint32_t lora_isp4520_init(int chipType)
Initializes the ISP4520 board peripherals.
Definition: board.cpp:149
hw_config::PIN_LORA_RESET
int PIN_LORA_RESET
Definition: board.h:63
BoardGetUniqueId
void BoardGetUniqueId(uint8_t *id)
Gets the board 64 bits unique ID.
lora_rak4630_init
uint32_t lora_rak4630_init(void)
Initializes the RAK4630 board peripherals.
Definition: board.cpp:194
hw_config::RADIO_RXEN
int RADIO_RXEN
Definition: board.h:71
hw_config::PIN_LORA_BUSY
int PIN_LORA_BUSY
Definition: board.h:68