Skip to content

Commit

Permalink
Fix #606: don't use defined() in macros
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Feb 23, 2021
1 parent 3411b43 commit 44f2bad
Showing 1 changed file with 71 additions and 12 deletions.
83 changes: 71 additions & 12 deletions src/lmic/lmic_config_preconditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,62 @@ Revision history:
(1 << LMIC_REGION_in866) | \
0)

// LMIC_CFG_*_ENA -- either 1 or 0 based on whether that region
// is enabled.
#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

//
// 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
Expand All @@ -129,16 +185,16 @@ Revision history:
// TODO(tmm@mcci.com) 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) | \
# 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)

// the selected region.
Expand Down Expand Up @@ -171,7 +227,7 @@ Revision history:
#endif

// a bitmask of EU-like regions -- these are regions which have up to 16
// channels indidually programmable via downloink.
// channels individually programmable via downlink.
//
// TODO(tmm@mcci.com) consider moving this block to a central file as it's not
// user-editable.
Expand Down Expand Up @@ -210,11 +266,14 @@ Revision history:
// TODO(tmm@mcci.com) 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.
Expand Down

0 comments on commit 44f2bad

Please sign in to comment.