Skip to content

Instantly share code, notes, and snippets.

@pabigot
Last active April 27, 2020 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pabigot/8057774cc407f5e7b6d04801c4c4743d to your computer and use it in GitHub Desktop.
Save pabigot/8057774cc407f5e7b6d04801c4c4743d to your computer and use it in GitHub Desktop.
test case for zephyrproject/zephyr#23998
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(NONE)
target_sources(app PRIVATE src/main.cxx)
*** Booting Zephyr OS build zephyr-v2.2.0-1466-g1f3c014a1ad3 ***
Hello World! nrf52840dk_nrf52840
Done
0: BLE 2404; LR-WPAN 2405
1: BLE 2406; LR-WPAN 2410
2: BLE 2408; LR-WPAN 2415
3: BLE 2410; LR-WPAN 2420
4: BLE 2412; LR-WPAN 2425
5: BLE 2414; LR-WPAN 2430
6: BLE 2416; LR-WPAN 2435
7: BLE 2418; LR-WPAN 2440
8: BLE 2420; LR-WPAN 2445
9: BLE 2422; LR-WPAN 2450
10: BLE 2424; LR-WPAN 2455
11: BLE 2428; LR-WPAN 2460
12: BLE 2430; LR-WPAN 2465
13: BLE 2432; LR-WPAN 2470
14: BLE 2434; LR-WPAN 2475
15: BLE 2436; LR-WPAN 2480
16: BLE 2438
17: BLE 2440
18: BLE 2442
19: BLE 2444
20: BLE 2446
21: BLE 2448
22: BLE 2450
23: BLE 2452
24: BLE 2454
25: BLE 2456
26: BLE 2458
27: BLE 2460
28: BLE 2462
29: BLE 2464
30: BLE 2466
31: BLE 2468
32: BLE 2470
33: BLE 2472
34: BLE 2474
35: BLE 2476
36: BLE 2478
37: BLE 2402
38: BLE 2426
39: BLE 2480
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <sys/printk.h>
class Channel
{
public:
int freq = 2400; // Frequency [Mhz]
int Pnoise = 174; // Noise [-dbm]
int Psignal = 174; // Siganl [-dbm]
};
class Radio
{
public:
// Comment these Variables out and it is working ---------------
u8_t payload[254]; // Containing Tx or Rx Payload
u8_t len; // Length of actual Payload to send or Received
// END Comment -----------------
Channel BLE_CH[40]; // List of BLE Channels
Channel IEEE802_15_4_CH[16]; // List of IEEE802.15.4 Channels
// Init the Radio
Radio()
{
// ---------------- Not Working Code Start ------------------------
// Init the BLE Channels
for (int i = 0; i <= 10; i++)
{
BLE_CH[i].freq = 2404 + i * 2;
}
for (int i = 0; i <= 25; i++)
{
BLE_CH[i + 11].freq = 2428 + i * 2;
}
BLE_CH[37].freq = 2402;
BLE_CH[38].freq = 2426;
BLE_CH[39].freq = 2480;
// Init the IEEE802.15.4 Channels
for (int i = 0; i <= 15; i++)
{
IEEE802_15_4_CH[i].freq = 2405 + i * 5;
}
// ----------------- Not Working Code END --------------------------
}
};
void main(void)
{
printk("Hello World! %s\n", CONFIG_BOARD);
Radio radio;
printk("Done\n");
for (u8_t ci = 0U; ci < ARRAY_SIZE(radio.BLE_CH); ++ci) {
printk("%2u: BLE %u", ci, radio.BLE_CH[ci].freq);
if (ci < ARRAY_SIZE(radio.IEEE802_15_4_CH)) {
printk("; LR-WPAN %u\n", radio.IEEE802_15_4_CH[ci].freq);
} else {
printk("\n");
}
}
}
CONFIG_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC=y
CONFIG_LIB_CPLUSPLUS=y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment