SX126x-Arduino
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 
53 // SX126x chip type
54 #define SX1261_CHIP 1
55 #define SX1262_CHIP 2
56 #define SX1268_CHIP 2
57 
58 // Microcontroller - SX126x pin configuration
59 struct hw_config
60 {
61  int CHIP_TYPE = SX1262_CHIP; // Module type, see defines above
62  int PIN_LORA_RESET; // LORA RESET
63  int PIN_LORA_NSS; // LORA SPI CS
64  int PIN_LORA_SCLK; // LORA SPI CLK
65  int PIN_LORA_MISO; // LORA SPI MISO
66  int PIN_LORA_DIO_1; // LORA DIO_1
67  int PIN_LORA_BUSY; // LORA SPI BUSY
68  int PIN_LORA_MOSI; // LORA SPI MOSI
69  int RADIO_TXEN = -1; // LORA ANTENNA TX ENABLE (eByte E22 module only)
70  int RADIO_RXEN = -1; // LORA ANTENNA RX ENABLE (eByte E22 module only)
71  bool USE_DIO2_ANT_SWITCH = false; // Whether DIO2 is used to control the antenna
72  bool USE_DIO3_TCXO = false; // Whether DIO3 is used to control the oscillator
73  bool USE_DIO3_ANT_SWITCH = false; // Whether DIO2 is used to control the antenna
74  bool USE_LDO = false; // Whether SX126x uses LDO or DCDC power regulator
75 };
76 
77 extern "C"
78 {
79 
80  extern hw_config _hwConfig;
81 
84  uint32_t lora_hardware_init(hw_config hwConfig);
85 
88  uint32_t lora_hardware_re_init(hw_config hwConfig);
89 
92  uint32_t lora_isp4520_init(int chipType);
93 
97  void lora_hardware_uninit(void);
98 
103  uint32_t BoardGetRandomSeed(void);
104 
109  void BoardGetUniqueId(uint8_t *id);
110 
113  uint8_t BoardGetBatteryLevel(void);
114 
119  void BoardDisableIrq(void);
120 
125  void BoardEnableIrq(void);
126 };
127 #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:74
lora_hardware_uninit
void lora_hardware_uninit(void)
De-initializes the target board peripherals to decrease power consumption.
Definition: board.cpp:132
hw_config::RADIO_TXEN
int RADIO_TXEN
Definition: board.h:69
BoardEnableIrq
void BoardEnableIrq(void)
Enable interrupts.
hw_config::USE_DIO2_ANT_SWITCH
bool USE_DIO2_ANT_SWITCH
Definition: board.h:71
_hwConfig
hw_config _hwConfig
Definition: board.cpp:40
hw_config::PIN_LORA_MOSI
int PIN_LORA_MOSI
Definition: board.h:68
BoardGetRandomSeed
uint32_t BoardGetRandomSeed(void)
Returns a pseudo random seed generated using the MCU Unique ID.
timer.h
lora_hardware_init
uint32_t lora_hardware_init(hw_config hwConfig)
Initializes the target board peripherals.
Definition: board.cpp:47
hw_config::CHIP_TYPE
int CHIP_TYPE
Definition: board.h:61
hw_config::PIN_LORA_NSS
int PIN_LORA_NSS
Definition: board.h:63
sx126x.h
SX126x driver implementation.
SX1262_CHIP
#define SX1262_CHIP
Definition: board.h:55
hw_config::USE_DIO3_ANT_SWITCH
bool USE_DIO3_ANT_SWITCH
Definition: board.h:73
BoardDisableIrq
void BoardDisableIrq(void)
Disable interrupts.
hw_config::PIN_LORA_DIO_1
int PIN_LORA_DIO_1
Definition: board.h:66
hw_config::PIN_LORA_SCLK
int PIN_LORA_SCLK
Definition: board.h:64
hw_config
Definition: board.h:60
hw_config::USE_DIO3_TCXO
bool USE_DIO3_TCXO
Definition: board.h:72
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:78
hw_config::PIN_LORA_MISO
int PIN_LORA_MISO
Definition: board.h:65
lora_isp4520_init
uint32_t lora_isp4520_init(int chipType)
Initializes the ISP4520 board peripherals.
Definition: board.cpp:109
hw_config::PIN_LORA_RESET
int PIN_LORA_RESET
Definition: board.h:62
BoardGetUniqueId
void BoardGetUniqueId(uint8_t *id)
Gets the board 64 bits unique ID.
hw_config::RADIO_RXEN
int RADIO_RXEN
Definition: board.h:70
hw_config::PIN_LORA_BUSY
int PIN_LORA_BUSY
Definition: board.h:67