Arduino LMIC
6.0.1
Arduino LoRaWAN(r) MAC in C
Toggle main menu visibility
Loading...
Searching...
No Matches
arduino_lmic_hal_configuration.h
1
/*
2
3
Module: arduino_lmic_hal_configuration.h
4
5
Function:
6
Arduino-LMIC C++ HAL configuration APIs
7
8
Copyright & License:
9
See accompanying LICENSE file.
10
11
Author:
12
Matthijs Kooijman 2015
13
Terry Moore, MCCI November 2018
14
15
*/
16
#pragma once
17
18
#ifndef _arduino_lmic_hal_configuration_h_
19
# define _arduino_lmic_hal_configuration_h_
20
21
#include <stdint.h>
22
#include "lmic/lmic_env.h"
23
24
namespace
Arduino_LMIC {
25
26
/* these types should match the types used by the LMIC */
27
typedef
int32_t ostime_t;
28
29
// this type is used when we need to represent a three-state signal
30
enum class
ThreeState_t : uint8_t {
31
Off = 0,
32
On = 1,
33
HiZ = 2
34
};
35
36
// forward reference
37
class
HalConfiguration_t
;
38
39
//
40
// for legacy reasons, we need a plain-old-data C-like
41
// structure that defines the "pin mapping" for the
42
// common pins. Many clients initialize an instance of
43
// this structure using named-field initialization.
44
//
45
// Be careful of alignment below.
46
struct
HalPinmap_t
{
47
// Use this for any unused pins.
48
static
constexpr
uint8_t UNUSED_PIN = 0xff;
49
static
constexpr
int
NUM_DIO = 3;
50
// for backward compatibility...
51
static
constexpr
uint8_t LMIC_UNUSED_PIN = UNUSED_PIN;
52
53
/* the contents */
54
uint8_t nss;
// byte 0: pin for select
55
uint8_t rxtx;
// byte 1: pin for rx/tx control
56
uint8_t rst;
// byte 2: pin for reset
57
uint8_t dio[NUM_DIO];
// bytes 3..5: pins for DIO0, DOI1, DIO2
58
// true if we must set rxtx for rx_active, false for tx_active
59
uint8_t rxtx_rx_active;
// byte 6: polarity of rxtx active
60
int8_t rssi_cal;
// byte 7: cal in dB -- added to RSSI
61
// measured prior to decision.
62
// Must include noise guardband!
63
uint32_t spi_freq;
// bytes 8..11: SPI freq in Hz.
64
65
// optional pointer to configuration object (bytes 12..15)
66
HalConfiguration_t
*pConfig;
67
};
68
69
class
HalConfiguration_t
70
{
71
public
:
72
HalConfiguration_t() {};
73
74
// these must match the constants in radio.c
75
enum class
TxPowerPolicy_t : uint8_t
76
{
77
RFO,
78
PA_BOOST,
79
PA_BOOST_20dBm
80
};
81
82
virtual
ostime_t setModuleActive(
bool
state) {
83
LMIC_API_PARAMETER(state);
84
85
// by default, if not overridden, do nothing
86
// and return 0 to indicate that the caller
87
// need not delay.
88
return
0;
89
}
90
91
virtual
void
begin(
void
) {}
92
virtual
void
end(
void
) {}
93
virtual
uint8_t queryBusyPin(
void
) {
return
HalPinmap_t::LMIC_UNUSED_PIN; }
94
virtual
bool
queryUsingTcxo(
void
) {
return
false
; }
95
virtual
bool
queryUsingDcdc(
void
) {
return
false
; }
96
virtual
bool
queryUsingDIO2AsRfSwitch(
void
) {
return
false
; }
97
virtual
bool
queryUsingDIO3AsTCXOSwitch(
void
) {
return
false
; }
98
99
// SX126x crystal oscillator trim (registers XTATrim/XTBTrim, 0x0911/0x0912).
100
// Valid trim values are 0x00-0x3F; chip reset default is 0x05 for both.
101
// Return kSX126xXtalTrimUseDefault to leave the chip reset value untouched.
102
static
constexpr
uint8_t kSX126xXtalTrimUseDefault = 0xFF;
103
virtual
uint8_t querySX126xXTATrim(
void
) {
return
kSX126xXtalTrimUseDefault; }
104
virtual
uint8_t querySX126xXTBTrim(
void
) {
return
kSX126xXtalTrimUseDefault; }
105
106
// compute desired transmit power policy. HopeRF needs
107
// (and previous versions of this library always chose)
108
// PA_BOOST mode. So that's our default. Override this
109
// for the Murata module.
110
virtual
TxPowerPolicy_t getTxPowerPolicy(
111
TxPowerPolicy_t policy,
112
int8_t requestedPower,
113
uint32_t frequency
114
)
115
{
116
LMIC_API_PARAMETER(policy);
117
LMIC_API_PARAMETER(requestedPower);
118
LMIC_API_PARAMETER(frequency);
119
// default: use PA_BOOST exclusively
120
return
TxPowerPolicy_t::PA_BOOST;
121
}
122
};
123
124
bool
lmic_hal_init_with_pinmap(
const
HalPinmap_t
*pPinmap);
125
126
};
// end namespace Arduino_LMIC
127
128
#endif
Arduino_LMIC::HalConfiguration_t
Definition
arduino_lmic_hal_configuration.h:70
Arduino_LMIC::HalPinmap_t
Definition
arduino_lmic_hal_configuration.h:46
src
arduino_lmic_hal_configuration.h
Generated on
for Arduino LMIC by
1.18.0