Skip to content

Commit 342ca76

Browse files
author
Jarkko Paso
committed
FHSS: Fixed IAR warnings from channel functions
1 parent 359c7b9 commit 342ca76

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

source/Service_Libs/fhss/channel_functions.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
#include "nsconfig.h"
18+
#include "common_functions.h"
1819

1920
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
2021

@@ -182,9 +183,9 @@ int32_t dh1cf_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t n
182183
{
183184
int32_t channel_number;
184185
uint32_t key[3];
185-
key[0] = (uint32_t)slot_number;
186-
key[1] = mac[4] << 24 | mac[5] << 16 | mac[6] << 8 | mac[7];
187-
key[2] = mac[0] << 24 | mac[1] << 16 | mac[2] << 8 | mac[3];
186+
key[0] = (uint32_t) slot_number;
187+
key[1] = common_read_32_bit(&mac[4]);
188+
key[2] = common_read_32_bit(&mac[0]);
188189
channel_number = dh1cf_hashword(key, 3, 0) % number_of_channels;
189190
return channel_number;
190191
}
@@ -193,8 +194,8 @@ int32_t dh1cf_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t n
193194
{
194195
int32_t channel_number;
195196
uint32_t key[3];
196-
key[0] = (uint32_t)slot_number;
197-
key[1] = bsi << 16;
197+
key[0] = (uint32_t) slot_number;
198+
key[1] = (uint32_t) bsi << 16;
198199
key[2] = 0;
199200
channel_number = dh1cf_hashword(key, 3, 0) % number_of_channels;
200201
return channel_number;

test/nanostack/unittest/service_libs/channel_functions/test_channel_functions.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
#include "Service_Libs/fhss/channel_functions.h"
1919
#include "test_channel_functions.h"
2020

21+
uint32_t common_read_32_bit(const uint8_t data_buf[__static 4])
22+
{
23+
uint32_t temp_32;
24+
temp_32 = (uint32_t)(*data_buf++) << 24;
25+
temp_32 += (uint32_t)(*data_buf++) << 16;
26+
temp_32 += (uint32_t)(*data_buf++) << 8;
27+
temp_32 += *data_buf++;
28+
return temp_32;
29+
}
30+
2131
const int32_t test_HopSequenceTable[129] = { 4, 93, 31, 84, 55, 3, 116, 123,
2232
41, 68, 105, 28, 25, 71, 33, 66,
2333
122, 20, 112, 125, 118, 11, 69, 89,

0 commit comments

Comments
 (0)