1 /*!
2  * \file      RegionCN470B26.c
3  *
4  * \brief
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 #include "RegionCN470.h"
32 #include "RegionBaseUS.h"
33 #include "RegionCN470A26.h"
34 #include "RegionCN470B26.h"
35 
RegionCN470B26GetDownlinkFrequency(uint8_t channel,uint8_t joinChannelIndex,bool isPingSlot)36 uint32_t RegionCN470B26GetDownlinkFrequency( uint8_t channel, uint8_t joinChannelIndex, bool isPingSlot )
37 {
38     return CN470_B26_BEACON_FREQ;
39 }
40 
RegionCN470B26GetBeaconChannelOffset(uint8_t joinChannelIndex)41 uint8_t RegionCN470B26GetBeaconChannelOffset( uint8_t joinChannelIndex )
42 {
43     return 0;
44 }
45 
RegionCN470B26LinkAdrChMaskUpdate(uint16_t * channelsMask,uint8_t chMaskCntl,uint16_t chanMask,ChannelParams_t * channels)46 uint8_t RegionCN470B26LinkAdrChMaskUpdate( uint16_t* channelsMask, uint8_t chMaskCntl,
47                                            uint16_t chanMask, ChannelParams_t* channels )
48 {
49     return RegionCN470A26LinkAdrChMaskUpdate( channelsMask, chMaskCntl,
50                                                  chanMask, channels );
51 }
52 
RegionCN470B26VerifyRfFreq(uint32_t freq)53 bool RegionCN470B26VerifyRfFreq( uint32_t freq )
54 {
55     // Downstream group 1
56     if( RegionBaseUSVerifyFrequencyGroup( freq, CN470_B26_FIRST_RX_CHANNEL,
57                                           CN470_B26_LAST_RX_CHANNEL,
58                                           CN470_B26_STEPWIDTH_RX_CHANNEL ) == false )
59     {
60         return false;
61     }
62     return true;
63 }
64 
RegionCN470B26InitializeChannels(ChannelParams_t * channels)65 void RegionCN470B26InitializeChannels( ChannelParams_t* channels )
66 {
67     // Upstream group 1
68     for( uint8_t i = 0; i < 48; i++ )
69     {
70         channels[i].Frequency = CN470_B26_FIRST_TX_CHANNEL + i * CN470_B26_STEPWIDTH_RX_CHANNEL;
71         channels[i].DrRange.Value = ( CN470_TX_MAX_DATARATE << 4 ) | CN470_TX_MIN_DATARATE;
72         channels[i].Band = 0;
73     }
74 }
75 
RegionCN470B26InitializeChannelsMask(uint16_t * channelsDefaultMask)76 void RegionCN470B26InitializeChannelsMask( uint16_t* channelsDefaultMask )
77 {
78     RegionCN470A26InitializeChannelsMask( channelsDefaultMask );
79 }
80 
RegionCN470B26GetRx1Frequency(uint8_t channel)81 uint32_t RegionCN470B26GetRx1Frequency( uint8_t channel )
82 {
83     return ( CN470_B26_FIRST_RX_CHANNEL + ( ( channel % 24 ) * CN470_B26_STEPWIDTH_RX_CHANNEL ) );
84 }
85 
RegionCN470B26GetRx2Frequency(uint8_t joinChannelIndex,bool isOtaaDevice)86 uint32_t RegionCN470B26GetRx2Frequency( uint8_t joinChannelIndex, bool isOtaaDevice )
87 {
88     return CN470_B26_RX_WND_2_FREQ;
89 }
90 
91