1 /*!
2  * \file      RegionBaseUS.h
3  *
4  * \brief     Implementations common with US region.
5  *
6  * \copyright Revised BSD License, see section \ref LICENSE.
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2013-2017 Semtech
16  *
17  *               ___ _____ _   ___ _  _____ ___  ___  ___ ___
18  *              / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
19  *              \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
20  *              |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
21  *              embedded.connectivity.solutions===============
22  *
23  * \endcode
24  *
25  * \author    Miguel Luis ( Semtech )
26  *
27  * \author    Gregory Cristian ( Semtech )
28  *
29  * \author    Daniel Jaeckle ( STACKFORCE )
30  *
31  * \author    Phanindra Kumar Yellapu ( STACKFORCE )
32  *
33  * \defgroup  REGIONBASEUS US region common implementations.
34  * \{
35  */
36 #ifndef __REGIONBASEUS_H__
37 #define __REGIONBASEUS_H__
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43 
44 #include "LoRaMac.h"
45 
46 /*!
47  * \brief Computes the next 125kHz channel used for join requests.
48  *        And it returns all the parameters updated.
49  *
50  * \param [IN]  channelsMaskRemaining pointer to remaining channels.
51  *
52  * \param [IN]  groupsCurrentIndex Index of current channel.
53  *
54  * \param [OUT] newChannelIndex Index of next available channel.
55  *
56  * \retval Status
57  */
58 LoRaMacStatus_t RegionBaseUSComputeNext125kHzJoinChannel( uint16_t* channelsMaskRemaining,
59                                                           uint8_t* groupsCurrentIndex, uint8_t* newChannelIndex );
60 
61 /*!
62  * \brief Verifies if the frequency is in the correct range with a
63  *        specific stepwidth.
64  *
65  * \param [IN]  freq Frequency to verify.
66  *
67  * \param [IN]  minFreq Minimum frequency.
68  *
69  * \param [IN]  maxFreq Maximum frequency.
70  *
71  * \param [IN]  stepwidth Frequency stepwidth.
72  *
73  * \retval True, if the frequency is valid, false if not.
74  */
75 bool RegionBaseUSVerifyFrequencyGroup( uint32_t freq, uint32_t minFreq, uint32_t maxFreq, uint32_t stepwidth );
76 
77 /*!
78  * \brief Calculates the downlink frequency for a given channel. This
79  *        function is used in class B only.
80  *
81  * \param [IN] channel The channel according to the channel plan.
82  *
83  * \param [IN] frequency The base frequency.
84  *
85  * \param [IN] stepwidth The frequency stepwidth.
86  *
87  * \retval The downlink frequency.
88  */
89 uint32_t RegionBaseUSCalcDownlinkFrequency( uint8_t channel, uint32_t frequency,
90                                             uint32_t stepwidth );
91 
92 /*! \} defgroup REGIONBASEUS */
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif // __REGIONBASEUS_H__
99