Arduino LMIC 6.0.1
Arduino LoRaWAN(r) MAC in C
Loading...
Searching...
No Matches
arduino_lmic_hal_configuration.h
1/*
2
3Module: arduino_lmic_hal_configuration.h
4
5Function:
6 Arduino-LMIC C++ HAL configuration APIs
7
8Copyright & License:
9 See accompanying LICENSE file.
10
11Author:
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
24namespace Arduino_LMIC {
25
26/* these types should match the types used by the LMIC */
27typedef int32_t ostime_t;
28
29// this type is used when we need to represent a three-state signal
30enum class ThreeState_t : uint8_t {
31 Off = 0,
32 On = 1,
33 HiZ = 2
34};
35
36// forward reference
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.
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
69class HalConfiguration_t
70 {
71public:
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 // compute desired transmit power policy. HopeRF needs
100 // (and previous versions of this library always chose)
101 // PA_BOOST mode. So that's our default. Override this
102 // for the Murata module.
103 virtual TxPowerPolicy_t getTxPowerPolicy(
104 TxPowerPolicy_t policy,
105 int8_t requestedPower,
106 uint32_t frequency
107 )
108 {
109 LMIC_API_PARAMETER(policy);
110 LMIC_API_PARAMETER(requestedPower);
111 LMIC_API_PARAMETER(frequency);
112 // default: use PA_BOOST exclusively
113 return TxPowerPolicy_t::PA_BOOST;
114 }
115 };
116
117bool lmic_hal_init_with_pinmap(const HalPinmap_t *pPinmap);
118
119}; // end namespace Arduino_LMIC
120
121#endif
Definition arduino_lmic_hal_configuration.h:70
Definition arduino_lmic_hal_configuration.h:46