1 /*! 2 * \file RegionCN470B26.h 3 * 4 * \brief Specific implementations of Channel plan type B, 26MHz. 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_B26_H__ 34 #define __REGION_CN470_B26_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, 26MHz. 46 */ 47 #define CN470_B26_CHANNELS_MASK_SIZE 3 48 49 /*! 50 * The number of entries in the join accept list. 51 * Channel plan type B, 26MHz. 52 */ 53 #define CN470_B26_JOIN_ACCEPT_LIST_SIZE 3 54 55 /*! 56 * The number of channels available for the beacon. 57 * Channel plan type B, 26MHz. 58 */ 59 #define CN470_B26_BEACON_NB_CHANNELS 1 60 61 /*! 62 * The number of channels available for the ping slots. 63 * Channel plan type B, 26MHz. 64 */ 65 #define CN470_B26_PING_SLOT_NB_CHANNELS 1 66 67 /*! 68 * The first RX channel, downstream group 1. 69 * Channel plan type B, 26MHz. 70 */ 71 #define CN470_B26_FIRST_RX_CHANNEL 500100000 72 73 /*! 74 * The last RX channel, downstream group 1. 75 * Channel plan type B, 26MHz. 76 */ 77 #define CN470_B26_LAST_RX_CHANNEL 504700000 78 79 /*! 80 * The frequency stepwidth between RX channels, 81 * downstream group 1 and 2. 82 * Channel plan type B, 26MHz. 83 */ 84 #define CN470_B26_STEPWIDTH_RX_CHANNEL 200000 85 86 /*! 87 * The first TX channel, upstream group 1. 88 * Channel plan type B, 26MHz. 89 */ 90 #define CN470_B26_FIRST_TX_CHANNEL 480300000 91 92 /*! 93 * The last TX channel, upstream group 1. 94 * Channel plan type B, 26MHz. 95 */ 96 #define CN470_B26_LAST_TX_CHANNEL 489700000 97 98 /*! 99 * The frequency stepwidth between RX channels, 100 * upstream group 1. 101 * Channel plan type B, 26MHz. 102 */ 103 #define CN470_B26_STEPWIDTH_TX_CHANNEL 200000 104 105 /*! 106 * The default frequency for RX window 2, 107 * Channel plan type B, 26MHz. 108 */ 109 #define CN470_B26_RX_WND_2_FREQ 502500000 110 111 /*! 112 * The default frequency for beacon, 113 * Channel plan type B, 26MHz. 114 */ 115 #define CN470_B26_BEACON_FREQ 504900000 116 117 /*! 118 * \brief Calculation of the beacon frequency. 119 * 120 * \param [IN] channel The Beacon channel number. 121 * 122 * \param [IN] joinChannelIndex The join channel index. 123 * 124 * \param [IN] isPingSlot Set to true, if its a ping slot. 125 * 126 * \retval Returns the beacon frequency. 127 */ 128 uint32_t RegionCN470B26GetDownlinkFrequency( uint8_t channel, uint8_t joinChannelIndex, bool isPingSlot ); 129 130 /*! 131 * \brief Performs the update of the channelsMask based on the input parameters 132 * for the Channel plan type B, 26MHz. 133 * 134 * \param [IN] joinChannelIndex The join channel index. 135 * 136 * \retval Returns the offset for the given join channel. 137 */ 138 uint8_t RegionCN470B26GetBeaconChannelOffset( uint8_t joinChannelIndex ); 139 140 /*! 141 * \brief Performs the update of the channelsMask based on the input parameters 142 * for the Channel plan type B, 26MHz. 143 * 144 * \param [IN] channelsMask A pointer to the channels mask. 145 * 146 * \param [IN] chMaskCntl The value of the chMaskCntl field of the LinkAdrReq. 147 * 148 * \param [IN] chanMask The value of the chanMask field of the LinkAdrReq. 149 * 150 * \param [IN] channels A pointer to the available channels. 151 * 152 * \retval Status of the operation. Return 0x07 if the channels mask is valid. 153 */ 154 uint8_t RegionCN470B26LinkAdrChMaskUpdate( uint16_t* channelsMask, uint8_t chMaskCntl, 155 uint16_t chanMask, ChannelParams_t* channels ); 156 157 /*! 158 * \brief Verifies if the frequency provided is valid 159 * for the Channel plan type B, 26MHz. 160 * 161 * \param [IN] frequency The frequency to verify. 162 * 163 * \retval Returns true, if the frequency is valid. 164 */ 165 bool RegionCN470B26VerifyRfFreq( uint32_t frequency ); 166 167 /*! 168 * \brief Initializes all channels, datarates, frequencies and bands 169 * for the Channel plan type B, 26MHz. 170 * 171 * \param [IN] channels A pointer to the available channels. 172 */ 173 void RegionCN470B26InitializeChannels( ChannelParams_t* channels ); 174 175 /*! 176 * \brief Initializes the channels mask and the channels default mask 177 * for the Channel plan type B, 26MHz. 178 * 179 * \param [IN] channelsDefaultMask A pointer to the channels default mask. 180 */ 181 void RegionCN470B26InitializeChannelsMask( uint16_t* channelsDefaultMask ); 182 183 /*! 184 * \brief Computes the frequency for the RX1 window 185 * for the Channel plan type B, 26MHz. 186 * 187 * \param [IN] channel The channel utilized currently. 188 * 189 * \retval Returns the frequency which shall be used. 190 */ 191 uint32_t RegionCN470B26GetRx1Frequency( uint8_t channel ); 192 193 /*! 194 * \brief Computes the frequency for the RX2 window 195 * for the Channel plan type B, 26MHz. 196 * 197 * \param [IN] joinChannelIndex The join channel index. 198 * 199 * \param [IN] isOtaaDevice Set to true, if the device is an OTAA device. 200 * 201 * \retval Returns the frequency which shall be used. 202 */ 203 uint32_t RegionCN470B26GetRx2Frequency( uint8_t joinChannelIndex, bool isOtaaDevice ); 204 205 /*! \} defgroup REGIONCN470 */ 206 207 #ifdef __cplusplus 208 } 209 #endif 210 211 #endif // __REGION_CN470_B26_H__ 212