1 /*! 2 * \file RegionCN470A20.h 3 * 4 * \brief Specific implementations of channel plan type A, 20MHz. 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 Daniel Jaeckle ( STACKFORCE ) 28 * 29 * \defgroup REGIONCN470 30 * 31 * \{ 32 */ 33 #ifndef __REGION_CN470_A20_H__ 34 #define __REGION_CN470_A20_H__ 35 36 #ifdef __cplusplus 37 extern "C" 38 { 39 #endif 40 41 #include "region/Region.h" 42 43 /*! 44 * The maximum number of channels. 45 * Channel plan type A, 20MHz. 46 */ 47 #define CN470_A20_CHANNELS_MASK_SIZE 4 48 49 /*! 50 * The number of entries in the join accept list. 51 * Channel plan type A, 20MHz. 52 */ 53 #define CN470_A20_JOIN_ACCEPT_LIST_SIZE 4 54 55 /*! 56 * This is a number which is used to calculate the 57 * beacon channel in case of frequency hopping. 58 * Channel plan type A, 20MHz. 59 */ 60 #define CN470_A20_BEACON_NB_CHANNELS 8 61 62 /*! 63 * This is a number which is used to calculate the 64 * ping slot channel in case of frequency hopping. 65 * Channel plan type A, 20MHz. 66 */ 67 #define CN470_A20_PING_SLOT_NB_CHANNELS 8 68 69 /*! 70 * The first RX channel, downstream group 1 and 2. 71 * Channel plan type A, 20MHz. 72 */ 73 #define CN470_A20_FIRST_RX_CHANNEL 483900000 74 75 /*! 76 * The last RX channel, downstream group 1 and 2. 77 * Channel plan type A, 20MHz. 78 */ 79 #define CN470_A20_LAST_RX_CHANNEL 496500000 80 81 /*! 82 * The frequency stepwidth between RX channels, 83 * downstream group 1 and 2. 84 * Channel plan type A, 20MHz. 85 */ 86 #define CN470_A20_STEPWIDTH_RX_CHANNEL 200000 87 88 /*! 89 * The first TX channel, upstream group 1. 90 * Channel plan type A, 20MHz. 91 */ 92 #define CN470_A20_FIRST_TX1_CHANNEL 470300000 93 94 /*! 95 * The frequency stepwidth between RX channels, 96 * upstream group 1. 97 * Channel plan type A, 20MHz. 98 */ 99 #define CN470_A20_STEPWIDTH_TX1_CHANNEL 200000 100 101 /*! 102 * The first TX channel, upstream group 2. 103 * Channel plan type A, 20MHz. 104 */ 105 #define CN470_A20_FIRST_TX2_CHANNEL 503500000 106 107 /*! 108 * The last TX channel, upstream group 2. 109 * Channel plan type A, 20MHz. 110 */ 111 #define CN470_A20_LAST_TX2_CHANNEL 509700000 112 113 /*! 114 * The frequency stepwidth between RX channels, 115 * upstream group 2. 116 * Channel plan type A, 20MHz. 117 */ 118 #define CN470_A20_STEPWIDTH_TX2_CHANNEL 200000 119 120 /*! 121 * The default frequency for RX window 2, when its 122 * an ABP device. 123 * Channel plan type A, 20MHz. 124 */ 125 #define CN470_A20_RX_WND_2_FREQ_ABP 486900000 126 127 /*! 128 * The channel plan frequencies for RX window 2, 129 * when its an OTAA device. 130 * Channel plan type A, 20MHz. 131 */ 132 #define CN470_A20_RX_WND_2_FREQ_OTAA { 485300000, 486900000, 488500000, 490100000, \ 133 491700000, 493300000, 494000000, 496500000 } 134 135 /*! 136 * \brief Calculation of the beacon frequency. 137 * 138 * \param [IN] channel The Beacon channel number. 139 * 140 * \param [IN] joinChannelIndex The join channel index. 141 * 142 * \param [IN] isPingSlot Set to true, if its a ping slot. 143 * 144 * \retval Returns the beacon frequency. 145 */ 146 uint32_t RegionCN470A20GetDownlinkFrequency( uint8_t channel, uint8_t joinChannelIndex, bool isPingSlot ); 147 148 /*! 149 * \brief Performs the update of the channelsMask based on the input parameters 150 * for the channel plan type A, 20MHz. 151 * 152 * \param [IN] joinChannelIndex The join channel index. 153 * 154 * \retval Returns the offset for the given join channel. 155 */ 156 uint8_t RegionCN470A20GetBeaconChannelOffset( uint8_t joinChannelIndex ); 157 158 /*! 159 * \brief Performs the update of the channelsMask based on the input parameters 160 * for the channel plan type A, 20MHz. 161 * 162 * \param [IN] channelsMask A pointer to the channels mask. 163 * 164 * \param [IN] chMaskCntl The value of the chMaskCntl field of the LinkAdrReq. 165 * 166 * \param [IN] chanMask The value of the chanMask field of the LinkAdrReq. 167 * 168 * \param [IN] channels A pointer to the available channels. 169 * 170 * \retval Status of the operation. Return 0x07 if the channels mask is valid. 171 */ 172 uint8_t RegionCN470A20LinkAdrChMaskUpdate( uint16_t* channelsMask, uint8_t chMaskCntl, 173 uint16_t chanMask, ChannelParams_t* channels ); 174 175 /*! 176 * \brief Verifies if the frequency provided is valid 177 * for the channel plan type A, 20MHz. 178 * 179 * \param [IN] frequency The frequency to verify. 180 * 181 * \retval Returns true, if the frequency is valid. 182 */ 183 bool RegionCN470A20VerifyRfFreq( uint32_t frequency ); 184 185 /*! 186 * \brief Initializes all channels, datarates, frequencies and bands 187 * for the channel plan type A, 20MHz. 188 * 189 * \param [IN] channels A pointer to the available channels. 190 */ 191 void RegionCN470A20InitializeChannels( ChannelParams_t* channels ); 192 193 /*! 194 * \brief Initializes the channels default mask 195 * for the channel plan type A, 20MHz. 196 * 197 * \param [IN] channelsDefaultMask A pointer to the channels default mask. 198 */ 199 void RegionCN470A20InitializeChannelsMask( uint16_t* channelsDefaultMask ); 200 201 /*! 202 * \brief Computes the frequency for the RX1 window 203 * for the channel plan type A, 20MHz. 204 * 205 * \param [IN] channel The channel utilized currently. 206 * 207 * \retval Returns the frequency which shall be used. 208 */ 209 uint32_t RegionCN470A20GetRx1Frequency( uint8_t channel ); 210 211 /*! 212 * \brief Computes the frequency for the RX2 window 213 * for the channel plan type A, 20MHz. 214 * 215 * \param [IN] joinChannelIndex The join channel index. 216 * 217 * \param [IN] isOtaaDevice Set to true, if the device is an OTAA device. 218 * 219 * \retval Returns the frequency which shall be used. 220 */ 221 uint32_t RegionCN470A20GetRx2Frequency( uint8_t joinChannelIndex, bool isOtaaDevice ); 222 223 /*! \} defgroup REGIONCN470 */ 224 225 #ifdef __cplusplus 226 } 227 #endif 228 229 #endif // __REGION_CN470_A20_H__ 230