Skip to content

Commit a508896

Browse files
Seppo TakaloOlli-Pekka Puolitaival
authored andcommitted
Use NanostackRfPhy::get_default_instance() for finding the driver (#2)
1 parent 5eb3456 commit a508896

File tree

4 files changed

+24
-40
lines changed

4 files changed

+24
-40
lines changed

TEST_APPS/device/nanostack_mac_tester/README.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ You can use this application to test the Nanostack RF driver implementations tha
1515
## Prerequisites
1616

1717
* [Mbed CLI](https://github.com/ARMmbed/mbed-cli).
18-
* Three supported boards with radio shields. For example, FRDM-K64F with FRDM-CR20A radio shield.
19-
* https://os.mbed.com/platforms/FRDM-K64F/
20-
* https://os.mbed.com/components/FRDM-CR20A/
18+
* Mbed OS target board with build in radio, OR RF shield with Mbed OS driver
2119

2220
## Setting up the application
2321

@@ -37,24 +35,15 @@ To add your RF driver:
3735
mbed add https://www.github.com/me/my-rf-driver.git
3836
```
3937

40-
Set `radio-type` in `mbed_app.json` to `OTHER`:
38+
When using RF shield, you need to configure it to be a default RF driver and instruct Mbed OS that RF driver is present. For example, configuring Atmel RF driver to provide default driver:
4139

4240
```
43-
"config":{
44-
"radio-type":{
45-
"value": "ATMEL" --> "value": "OTHER"
46-
}
47-
}
41+
"target_overrides": {
42+
"*": {
43+
"target.device_has_add": ["802_15_4_RF_PHY"],
44+
"atmel-rf.provide-default": true
4845
```
4946

50-
Replace the placeholders in `main.cpp` with your RF driver header file and interface definition:
51-
52-
```
53-
#elif MBED_CONF_APP_RADIO_TYPE == OTHER
54-
#include "YOUR_DRIVER_HEADER.h"
55-
YourDriverInterface rf_phy(...);
56-
#endif
57-
```
5847

5948
### Compile your binary
6049

TEST_APPS/device/nanostack_mac_tester/main.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,12 @@
3333
#define TRACE_GROUP "Main"
3434
#include "mbed-trace/mbed_trace.h"
3535

36-
#if MBED_CONF_APP_RADIO_TYPE == ATMEL
37-
#include "NanostackRfPhyAtmel.h"
38-
NanostackRfPhyAtmel rf_phy(ATMEL_SPI_MOSI, ATMEL_SPI_MISO, ATMEL_SPI_SCLK, ATMEL_SPI_CS,
39-
ATMEL_SPI_RST, ATMEL_SPI_SLP, ATMEL_SPI_IRQ, ATMEL_I2C_SDA, ATMEL_I2C_SCL);
40-
#elif MBED_CONF_APP_RADIO_TYPE == MCR20
41-
#include "NanostackRfPhyMcr20a.h"
42-
NanostackRfPhyMcr20a rf_phy(MCR20A_SPI_MOSI, MCR20A_SPI_MISO, MCR20A_SPI_SCLK, MCR20A_SPI_CS, MCR20A_SPI_RST, MCR20A_SPI_IRQ);
43-
#elif MBED_CONF_APP_RADIO_TYPE == OTHER
44-
#include "YOUR_DRIVER_HEADER.h"
45-
YourDriverInterface rf_phy(...);
46-
#endif //MBED_CONF_APP_RADIO_TYPE
36+
#include "NanostackRfPhy.h"
37+
38+
#if !DEVICE_802_15_4_PHY
39+
#error [NOT_SUPPORTED] No 802.15.4 RF driver found for this target
40+
#endif
41+
4742

4843
extern mac_api_s *mac_interface;
4944
RawSerial pc(USBTX, USBRX);
@@ -94,6 +89,7 @@ static void handle_rx_data(void)
9489

9590
static int mac_prepare(void)
9691
{
92+
NanostackRfPhy &rf_phy = NanostackRfPhy::get_default_instance();
9793
int8_t rf_driver_id = rf_phy.rf_register();
9894
uint8_t rf_eui64[8];
9995

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
{
2-
"config": {
3-
"radio-type":{
4-
"help": "options are ATMEL, MCR20, OTHER",
5-
"value": "ATMEL"
6-
}
7-
},
8-
"macros": ["YOTTA_CFG_MBED_TRACE_LINE_LENGTH=200", "OS_TASKCNT=4", "OS_IDLESTKSIZE=32"],
2+
"macros": ["MBED_TRACE_LINE_LENGTH=200", "OS_TASKCNT=4", "OS_IDLESTKSIZE=32"],
93
"target_overrides": {
104
"*": {
11-
"target.features_add": ["NANOSTACK", "LOWPAN_HOST", "COMMON_PAL"],
5+
"nanostack.configuration": "lowpan_host",
126
"platform.stdio-convert-newlines": true,
137
"platform.stdio-baud-rate": 115200,
148
"mbed-mesh-api.heap-size": 6000,
159
"nanostack-hal.event_loop_thread_stack_size": 2000,
16-
"mbed-trace.enable": true
10+
"mbed-trace.enable": true,
11+
"nsapi.default-stack": "LWIP",
12+
"target.device_has_add": ["802_15_4_PHY"],
13+
"atmel-rf.provide-default": true
1714
}
1815
}
1916
}

tools/test_configs/MACTester.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@
3333
"value": "HeapBlockDevice"
3434
}
3535
},
36-
"macros": ["YOTTA_CFG_MBED_TRACE_LINE_LENGTH=200", "OS_TASKCNT=4", "OS_IDLESTKSIZE=32"],
36+
"macros": ["MBED_TRACE_LINE_LENGTH=200", "OS_TASKCNT=4", "OS_IDLESTKSIZE=32"],
3737
"target_overrides": {
3838
"*": {
39-
"target.features_add": ["NANOSTACK", "LOWPAN_HOST", "COMMON_PAL", "LWIP"],
39+
"nanostack.configuration": "lowpan_host",
4040
"platform.stdio-convert-newlines": true,
4141
"platform.stdio-baud-rate": 115200,
4242
"mbed-mesh-api.heap-size": 6000,
4343
"nanostack-hal.event_loop_thread_stack_size": 2000,
4444
"mbed-trace.enable": true,
45-
"nsapi.default-stack": "LWIP"
45+
"nsapi.default-stack": "LWIP",
46+
"target.device_has_add": ["802_15_4_PHY"],
47+
"atmel-rf.provide-default": true
4648
}
4749
}
4850
}

0 commit comments

Comments
 (0)