1 /*! 2 * \file RegionCN470B20.h 3 * 4 * \brief Specific implementations of Channel plan type B, 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_B20_H__ 34 #define __REGION_CN470_B20_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 B, 20MHz. 46 */ 47 #define CN470_B20_CHANNELS_MASK_SIZE 4 48 49 /*! 50 * The number of entries in the join accept list. 51 * Channel plan type B, 20MHz. 52 */ 53 #define CN470_B20_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 B, 20MHz. 59 */ 60 #define CN470_B20_BEACON_NB_CHANNELS 1 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 B, 20MHz. 66 */ 67 #define CN470_B20_PING_SLOT_NB_CHANNELS 32 68 69 /*! 70 * The first RX channel, downstream group 1. 71 * Channel plan type B, 20MHz. 72 */ 73 #define CN470_B20_FIRST_RX1_CHANNEL 476900000 74 75 /*! 76 * The last RX channel, downstream group 1. 77 * Channel plan type B, 20MHz. 78 */ 79 #define CN470_B20_LAST_RX1_CHANNEL 483100000 80 81 /*! 82 * The frequency stepwidth between RX channels, 83 * downstream group 1. 84 * Channel plan type B, 20MHz. 85 */ 86 #define CN470_B20_STEPWIDTH_RX1_CHANNEL 200000 87 88 /*! 89 * The first RX channel, downstream group 2. 90 * Channel plan type B, 20MHz. 91 */ 92 #define CN470_B20_FIRST_RX2_CHANNEL 496900000 93 94 /*! 95 * The last RX channel, downstream group 2. 96 * Channel plan type B, 20MHz. 97 */ 98 #define CN470_B20_LAST_RX2_CHANNEL 503100000 99 100 /*! 101 * The frequency stepwidth between RX channels, 102 * downstream group 2. 103 * Channel plan type B, 20MHz. 104 */ 105 #define CN470_B20_STEPWIDTH_RX2_CHANNEL 200000 106 107 /*! 108 * The first TX channel, upstream group 1. 109 * Channel plan type B, 20MHz. 110 */ 111 #define CN470_B20_FIRST_TX1_CHANNEL CN470_B20_FIRST_RX1_CHANNEL 112 113 /*! 114 * The last TX channel, upstream group 1. 115 * Channel plan type B, 20MHz. 116 */ 117 #define CN470_B20_LAST_TX1_CHANNEL CN470_B20_LAST_RX1_CHANNEL 118 119 /*! 120 * The frequency stepwidth between RX channels, 121 * upstream group 1. 122 * Channel plan type B, 20MHz. 123 */ 124 #define CN470_B20_STEPWIDTH_TX1_CHANNEL CN470_B20_STEPWIDTH_RX1_CHANNEL 125 126 /*! 127 * The first TX channel, upstream group 2. 128 * Channel plan type B, 20MHz. 129 */ 130 #define CN470_B20_FIRST_TX2_CHANNEL CN470_B20_FIRST_RX2_CHANNEL 131 132 /*! 133 * The last TX channel, upstream group 2. 134 * Channel plan type B, 20MHz. 135 */ 136 #define CN470_B20_LAST_TX2_CHANNEL CN470_B20_LAST_RX2_CHANNEL 137 138 /*! 139 * The frequency stepwidth between RX channels, 140 * upstream group 2. 141 * Channel plan type B, 20MHz. 142 */ 143 #define CN470_B20_STEPWIDTH_TX2_CHANNEL CN470_B20_STEPWIDTH_RX2_CHANNEL 144 145 /*! 146 * The default frequency for RX window 2, when its 147 * an ABP device. 148 * Channel plan type B, 20MHz. 149 */ 150 #define CN470_B20_RX_WND_2_FREQ_ABP 498300000 151 152 /*! 153 * The channel plan frequencies for RX window 2, 154 * when its an OTAA device. 155 * Channel plan type B, 20MHz. 156 */ 157 #define CN470_B20_RX_WND_2_FREQ_OTAA { 478300000, 498300000 } 158 159 /*! 160 * \brief Calculation of the beacon frequency. 161 * 162 * \param [IN] channel The Beacon channel number. 163 * 164 * \param [IN] joinChannelIndex The join channel index. 165 * 166 * \param [IN] isPingSlot Set to true, if its a ping slot. 167 * 168 * \retval Returns the beacon frequency. 169 */ 170 uint32_t RegionCN470B20GetDownlinkFrequency( uint8_t channel, uint8_t joinChannelIndex, bool isPingSlot ); 171 172 /*! 173 * \brief Performs the update of the channelsMask based on the input parameters 174 * for the Channel plan type B, 20MHz. 175 * 176 * \param [IN] joinChannelIndex The join channel index. 177 * 178 * \retval Returns the offset for the given join channel. 179 */ 180 uint8_t RegionCN470B20GetBeaconChannelOffset( uint8_t joinChannelIndex ); 181 182 /*! 183 * \brief Performs the update of the channelsMask based on the input parameters 184 * for the Channel plan type B, 20MHz. 185 * 186 * \param [IN] channelsMask A pointer to the channels mask. 187 * 188 * \param [IN] chMaskCntl The value of the chMaskCntl field of the LinkAdrReq. 189 * 190 * \param [IN] chanMask The value of the chanMask field of the LinkAdrReq. 191 * 192 * \param [IN] channels A pointer to the available channels. 193 * 194 * \retval Status of the operation. Return 0x07 if the channels mask is valid. 195 */ 196 uint8_t RegionCN470B20LinkAdrChMaskUpdate( uint16_t* channelsMask, uint8_t chMaskCntl, 197 uint16_t chanMask, ChannelParams_t* channels ); 198 199 /*! 200 * \brief Verifies if the frequency provided is valid 201 * for the Channel plan type B, 20MHz. 202 * 203 * \param [IN] frequency The frequency to verify. 204 * 205 * \retval Returns true, if the frequency is valid. 206 */ 207 bool RegionCN470B20VerifyRfFreq( uint32_t frequency ); 208 209 /*! 210 * \brief Initializes all channels, datarates, frequencies and bands 211 * for the Channel plan type B, 20MHz. 212 * 213 * \param [IN] channels A pointer to the available channels. 214 */ 215 void RegionCN470B20InitializeChannels( ChannelParams_t* channels ); 216 217 /*! 218 * \brief Initializes the channels default mask 219 * for the Channel plan type B, 20MHz. 220 * 221 * \param [IN] channelsDefaultMask A pointer to the channels default mask. 222 */ 223 void RegionCN470B20InitializeChannelsMask( uint16_t* channelsDefaultMask ); 224 225 /*! 226 * \brief Computes the frequency for the RX1 window 227 * for the Channel plan type B, 20MHz. 228 * 229 * \param [IN] channel The channel utilized currently. 230 * 231 * \retval Returns the frequency which shall be used. 232 */ 233 uint32_t RegionCN470B20GetRx1Frequency( uint8_t channel ); 234 235 /*! 236 * \brief Computes the frequency for the RX2 window 237 * for the Channel plan type B, 20MHz. 238 * 239 * \param [IN] joinChannelIndex The join channel index. 240 * 241 * \param [IN] isOtaaDevice Set to true, if the device is an OTAA device. 242 * 243 * \retval Returns the frequency which shall be used. 244 */ 245 uint32_t RegionCN470B20GetRx2Frequency( uint8_t joinChannelIndex, bool isOtaaDevice ); 246 247 /*! \} defgroup REGIONCN470 */ 248 249 #ifdef __cplusplus 250 } 251 #endif 252 253 #endif // __REGION_CN470_B20_H__ 254