forked from things-nyc/arduino-lmic
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #606: don't use defined() in macros
- Loading branch information
1 parent
3411b43
commit 010d82b
Showing
1 changed file
with
102 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,30 +117,6 @@ Revision history: | |
(1 << LMIC_REGION_in866) | \ | ||
0) | ||
|
||
// | ||
// Our input is a -D of one of CFG_eu868, CFG_us915, CFG_as923, CFG_au915, CFG_in866 | ||
// More will be added in the the future. So at this point we create CFG_region with | ||
// following values. These are in order of the sections in the manual. Not all of the | ||
// below are supported yet. | ||
// | ||
// CFG_as923jp is treated as a special case of CFG_as923, so it's not included in | ||
// the below. | ||
// | ||
// TODO([email protected]) consider moving this block to a central file as it's not | ||
// user-editable. | ||
// | ||
# define CFG_LMIC_REGION_MASK \ | ||
((defined(CFG_eu868) << LMIC_REGION_eu868) | \ | ||
(defined(CFG_us915) << LMIC_REGION_us915) | \ | ||
(defined(CFG_cn783) << LMIC_REGION_cn783) | \ | ||
(defined(CFG_eu433) << LMIC_REGION_eu433) | \ | ||
(defined(CFG_au915) << LMIC_REGION_au915) | \ | ||
(defined(CFG_cn490) << LMIC_REGION_cn490) | \ | ||
(defined(CFG_as923) << LMIC_REGION_as923) | \ | ||
(defined(CFG_kr920) << LMIC_REGION_kr920) | \ | ||
(defined(CFG_in866) << LMIC_REGION_in866) | \ | ||
0) | ||
|
||
// the selected region. | ||
// TODO([email protected]) consider moving this block to a central file as it's not | ||
// user-editable. | ||
|
@@ -170,11 +146,94 @@ Revision history: | |
# define CFG_region 0 | ||
#endif | ||
|
||
// a bitmask of EU-like regions -- these are regions which have up to 16 | ||
// channels indidually programmable via downloink. | ||
// | ||
// TODO([email protected]) consider moving this block to a central file as it's not | ||
// user-editable. | ||
// LMIC_CFG_*_ENA -- either 1 or 0 based on whether that region | ||
// is enabled. Note: these must be after the code that special-cases | ||
// CFG_as923jp. | ||
#if defined(CFG_eu868) | ||
# define LMIC_CFG_eu868_ENA 1 | ||
#else | ||
# define LMIC_CFG_eu868_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_us915) | ||
# define LMIC_CFG_us915_ENA 1 | ||
#else | ||
# define LMIC_CFG_us915_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_cn783) | ||
# define LMIC_CFG_cn783_ENA 1 | ||
#else | ||
# define LMIC_CFG_cn783_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_eu433) | ||
# define LMIC_CFG_eu433_ENA 1 | ||
#else | ||
# define LMIC_CFG_eu433_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_au915) | ||
# define LMIC_CFG_au915_ENA 1 | ||
#else | ||
# define LMIC_CFG_au915_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_cn490) | ||
# define LMIC_CFG_cn490_ENA 1 | ||
#else | ||
# define LMIC_CFG_cn490_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_as923) | ||
# define LMIC_CFG_as923_ENA 1 | ||
#else | ||
# define LMIC_CFG_as923_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_kr920) | ||
# define LMIC_CFG_kr920_ENA 1 | ||
#else | ||
# define LMIC_CFG_kr920_ENA 0 | ||
#endif | ||
|
||
#if defined(CFG_in866) | ||
# define LMIC_CFG_in866_ENA 1 | ||
#else | ||
# define LMIC_CFG_in866_ENA 0 | ||
#endif | ||
|
||
/// \brief Bitmask of configured regions | ||
/// | ||
/// Our input is a -D of one of CFG_eu868, CFG_us915, CFG_as923, CFG_au915, CFG_in866 | ||
/// More will be added in the the future. So at this point we create CFG_region with | ||
/// following values. These are in order of the sections in the manual. Not all of the | ||
/// below are supported yet. | ||
/// | ||
/// CFG_as923jp is treated as a special case of CFG_as923, so it's not included in | ||
/// the below. | ||
/// | ||
/// TODO([email protected]) consider moving this block to a central file as it's not | ||
/// user-editable. | ||
/// | ||
# define CFG_LMIC_REGION_MASK \ | ||
((LMIC_CFG_eu868_ENA << LMIC_REGION_eu868) | \ | ||
(LMIC_CFG_us915_ENA << LMIC_REGION_us915) | \ | ||
(LMIC_CFG_cn783_ENA << LMIC_REGION_cn783) | \ | ||
(LMIC_CFG_eu433_ENA << LMIC_REGION_eu433) | \ | ||
(LMIC_CFG_au915_ENA << LMIC_REGION_au915) | \ | ||
(LMIC_CFG_cn490_ENA << LMIC_REGION_cn490) | \ | ||
(LMIC_CFG_as923_ENA << LMIC_REGION_as923) | \ | ||
(LMIC_CFG_kr920_ENA << LMIC_REGION_kr920) | \ | ||
(LMIC_CFG_in866_ENA << LMIC_REGION_in866) | \ | ||
0) | ||
|
||
/// \brief a bitmask of EU-like regions | ||
/// | ||
/// EU-like regions have up to 16 channels individually programmable via downlink. | ||
/// | ||
/// TODO([email protected]) consider moving this block to a central file as it's not | ||
/// user-editable. | ||
#define CFG_LMIC_EU_like_MASK ( \ | ||
(1 << LMIC_REGION_eu868) | \ | ||
/* (1 << LMIC_REGION_us915) | */ \ | ||
|
@@ -187,12 +246,14 @@ Revision history: | |
(1 << LMIC_REGION_in866) | \ | ||
0) | ||
|
||
// a bitmask of` US-like regions -- these are regions with 64 fixed 125 kHz channels | ||
// overlaid by 8 500 kHz channels. The channel frequencies can't be changed, but | ||
// subsets of channels can be selected via masks. | ||
// | ||
// TODO([email protected]) consider moving this block to a central file as it's not | ||
// user-editable. | ||
/// \brief bitmask of` US-like regions | ||
/// | ||
/// US-like regions have 64 fixed 125-kHz channels overlaid by 8 500-kHz | ||
/// channels. The channel frequencies can't be changed, but | ||
/// subsets of channels can be selected via masks. | ||
/// | ||
/// TODO([email protected]) consider moving this block to a central file as it's not | ||
/// user-editable. | ||
#define CFG_LMIC_US_like_MASK ( \ | ||
/* (1 << LMIC_REGION_eu868) | */ \ | ||
(1 << LMIC_REGION_us915) | \ | ||
|
@@ -210,16 +271,19 @@ Revision history: | |
// TODO([email protected]) consider moving this block to a central file as it's not | ||
// user-editable. | ||
// | ||
|
||
/// \brief true if configured region is EU-like, false otherwise. | ||
#define CFG_LMIC_EU_like (!!(CFG_LMIC_REGION_MASK & CFG_LMIC_EU_like_MASK)) | ||
/// \brief true if configured region is US-like, false otherwise. | ||
#define CFG_LMIC_US_like (!!(CFG_LMIC_REGION_MASK & CFG_LMIC_US_like_MASK)) | ||
|
||
// | ||
// The supported LMIC LoRaWAAN spec versions. These need to be numerically ordered, | ||
// The supported LMIC LoRaWAN spec versions. These need to be numerically ordered, | ||
// so that we can (for example) compare | ||
// | ||
// LMIC_LORAWAN_SPEC_VERSION < LMIC_LORAWAN_SPEC_VERSION_1_0_3. | ||
// | ||
#define LMIC_LORAWAN_SPEC_VERSION_1_0_2 0x01000200u | ||
#define LMIC_LORAWAN_SPEC_VERSION_1_0_3 0x01000300u | ||
#define LMIC_LORAWAN_SPEC_VERSION_1_0_2 0x01000200u /// Refers to LoRaWAN spec 1.0.2 | ||
#define LMIC_LORAWAN_SPEC_VERSION_1_0_3 0x01000300u /// Refers to LoRaWAN spec 1.0.3 | ||
|
||
#endif /* _LMIC_CONFIG_PRECONDITIONS_H_ */ |