Skip to content

Commit 01446f3

Browse files
committed
[EFR32] Initial radio driver
First check-in of the EFR32 radio driver for Nanostack
1 parent c0301b1 commit 01446f3

21 files changed

+4635
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Unless specifically indicated otherwise in a file, files are licensed
2+
under the Apache 2.0 license, as can be found in: apache-2.0.txt
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Example 802.15.4 RF driver for Silicon Labs EFR32 Wireless SoCs #
2+
3+
Support for:
4+
* EFR32MG1X
5+
6+
This driver is used with the mbed 6LoWPAN stack.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
3+
Apache License
4+
5+
Version 2.0, January 2004
6+
7+
http://www.apache.org/licenses/
8+
9+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
10+
11+
1. Definitions.
12+
13+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
14+
15+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
16+
17+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
18+
19+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
20+
21+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
22+
23+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
24+
25+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
26+
27+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
28+
29+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
30+
31+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
32+
33+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
34+
35+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
36+
37+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
38+
39+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
40+
You must cause any modified files to carry prominent notices stating that You changed the files; and
41+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
43+
44+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
45+
46+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
47+
48+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
49+
50+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
51+
52+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
53+
54+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
55+
56+
END OF TERMS AND CONDITIONS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/***************************************************************************//**
2+
* @file buffer_pool_allocator.c
3+
* @brief The source for a simple memory allocator that statically creates pools
4+
* of fixed size buffers to allocate from.
5+
* @copyright Copyright 2015 Silicon Laboratories, Inc. http://www.silabs.com
6+
******************************************************************************/
7+
8+
#include <stdlib.h>
9+
10+
#include "buffer_pool_allocator.h"
11+
12+
#include "em_int.h"
13+
14+
#ifdef CONFIGURATION_HEADER
15+
#include CONFIGURATION_HEADER
16+
#endif
17+
18+
// -----------------------------------------------------------------------------
19+
// Configuration Macros
20+
// -----------------------------------------------------------------------------
21+
22+
// Default to a ping-pong buffer pool with a size of 128 (127 MTU + 1 length) bytes per buffer
23+
#ifndef BUFFER_POOL_SIZE
24+
#define BUFFER_POOL_SIZE 2
25+
#endif
26+
#ifndef MAX_BUFFER_SIZE
27+
#define MAX_BUFFER_SIZE 128
28+
#endif
29+
30+
#define INVALID_BUFFER_OBJ ((void*)0xFFFFFFFF)
31+
32+
typedef struct {
33+
uint8_t refCount;
34+
uint8_t data[MAX_BUFFER_SIZE];
35+
} BufferPoolObj_t;
36+
37+
static BufferPoolObj_t memoryObjs[BUFFER_POOL_SIZE];
38+
39+
void* memoryAllocate(uint32_t size)
40+
{
41+
uint32_t i = 0;
42+
void *handle = INVALID_BUFFER_OBJ;
43+
44+
// We can't support sizes greater than the maximum heap buffer size
45+
if(size > MAX_BUFFER_SIZE) {
46+
return INVALID_BUFFER_OBJ;
47+
}
48+
49+
INT_Disable();
50+
for(i = 0; i < BUFFER_POOL_SIZE; i++)
51+
{
52+
if(memoryObjs[i].refCount == 0)
53+
{
54+
memoryObjs[i].refCount = 1;
55+
handle = (void*)i;
56+
break;
57+
}
58+
}
59+
INT_Enable();
60+
61+
return handle;
62+
}
63+
64+
void *memoryPtrFromHandle(void *handle)
65+
{
66+
void *ptr = NULL;
67+
68+
// Make sure we were given a valid handle
69+
if((handle == INVALID_BUFFER_OBJ) || ((uint32_t)handle > BUFFER_POOL_SIZE))
70+
{
71+
return NULL;
72+
}
73+
74+
INT_Disable();
75+
if(memoryObjs[(uint32_t)handle].refCount > 0)
76+
{
77+
ptr = memoryObjs[(uint32_t)handle].data;
78+
}
79+
INT_Enable();
80+
81+
return ptr;
82+
}
83+
84+
void memoryFree(void *handle)
85+
{
86+
INT_Disable();
87+
if(memoryPtrFromHandle(handle) != NULL)
88+
{
89+
memoryObjs[(uint32_t)handle].refCount--;
90+
}
91+
INT_Enable();
92+
}
93+
94+
void memoryTakeReference(void *handle)
95+
{
96+
INT_Disable();
97+
if(memoryPtrFromHandle(handle) != NULL)
98+
{
99+
memoryObjs[(uint32_t)handle].refCount++;
100+
}
101+
INT_Enable();
102+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/***************************************************************************//**
2+
* @file buffer_pool_allocator.h
3+
* @brief This is a simple memory allocator that uses a build time defined pool
4+
* of constant sized buffers. It's a very simple allocator, but one that can
5+
* be easily used in any application.
6+
*
7+
* @copyright Copyright 2015 Silicon Laboratories, Inc. http://www.silabs.com
8+
******************************************************************************/
9+
10+
#ifndef BUFFER_POOL_ALLOCATOR_H__
11+
#define BUFFER_POOL_ALLOCATOR_H__
12+
13+
// Get the standard include types
14+
#include <stdint.h>
15+
16+
/**
17+
* Allocate a buffer with at least the number of bytes specified. If there is
18+
* not enough space then this function will return NULL.
19+
* @param size The number of bytes to allocate for this buffer
20+
* @return Returns a handle to a buffer at least size bytes long or NULL if no
21+
* buffer could be allocated.
22+
*/
23+
void* memoryAllocate(uint32_t size);
24+
25+
/**
26+
* Free the buffer pointed to by handle. This will only decrement the reference
27+
* counter for this buffer. The memory is not freed until the reference counter
28+
* reaches zero.
29+
* @param handle The handle to free. Must match the value returned by
30+
* the memoryAllocate() function.
31+
*/
32+
void memoryFree(void *handle);
33+
34+
/**
35+
* Take a memory handle and get the data pointer associated with it. This will
36+
* return NULL if passed an invalid or unallocated handle.
37+
* @param handle The handle to get the pointer for. Must match the value
38+
* returned by the memoryAllocate() function.
39+
*/
40+
void *memoryPtrFromHandle(void *handle);
41+
42+
/**
43+
* Increment the reference counter on the memory pointed to by handle. After
44+
* doing this there will have to be an additional call to memoryFree() to
45+
* release the memory.
46+
* @param handle The handle to the object which needs its reference count
47+
* increased. Must match the value returned by the memoryAllocate() function.
48+
*/
49+
void memoryTakeReference(void *handle);
50+
51+
#endif // BUFFER_POOL_ALLOCATOR_H__
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/***************************************************************************//**
2+
* @file rail_integration.c
3+
* @brief Simple code to link this memory manager with a RAIL application by
4+
* implementing the appropriate callbacks.
5+
* @copyright Copyright 2015 Silicon Laboratories, Inc. http://www.silabs.com
6+
******************************************************************************/
7+
8+
#include <stdint.h>
9+
#include "rail.h"
10+
#include "buffer_pool_allocator.h"
11+
12+
/// Rely on the pool allocator's allocate function to get memory
13+
void *RAILCb_AllocateMemory(uint32_t size)
14+
{
15+
return memoryAllocate(size);
16+
}
17+
18+
/// Use the pool allocator's free function to return the memory to the pool
19+
void RAILCb_FreeMemory(void *ptr)
20+
{
21+
memoryFree(ptr);
22+
}
23+
24+
/// Get the memory pointer for this handle and offset into it as requested
25+
void *RAILCb_BeginWriteMemory(void *handle,
26+
uint32_t offset,
27+
uint32_t *available)
28+
{
29+
return ((uint8_t*)memoryPtrFromHandle(handle)) + offset;
30+
}
31+
32+
/// We don't need to track the completion of a memory write so do nothing
33+
void RAILCb_EndWriteMemory(void *handle, uint32_t offset, uint32_t size)
34+
{
35+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2016 Silicon Laboratories, Inc. http://www.silabs.com
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Licensed under the Apache License, Version 2.0 (the License); you may
5+
* not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef NANOSTACK_PHY_EFR32_H_
18+
#define NANOSTACK_PHY_EFR32_H_
19+
20+
#include "mbed.h"
21+
#include "NanostackRfPhy.h"
22+
23+
class NanostackRfPhyEfr32 : public NanostackRfPhy {
24+
public:
25+
NanostackRfPhyEfr32();
26+
~NanostackRfPhyEfr32();
27+
int8_t rf_register();
28+
void rf_unregister();
29+
void get_mac_address(uint8_t *mac);
30+
void set_mac_address(uint8_t *mac);
31+
uint32_t get_driver_version();
32+
};
33+
34+
#endif /* NANOSTACK_PHY_EFR32_H_ */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/***************************************************************************//**
2+
* @brief RAIL Configuration
3+
* @copyright Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
4+
******************************************************************************/
5+
//=============================================================================
6+
//
7+
// WARNING: Auto-Generated Radio Config - DO NOT EDIT
8+
//
9+
//=============================================================================
10+
#include <stdint.h>
11+
12+
const uint32_t ieee802154_config_base[] = {
13+
0x01010FF4UL, 0x00000000UL,
14+
0x01010FF8UL, 0x0003C000UL,
15+
0x01010FFCUL, 0x0003C00EUL,
16+
0x00010004UL, 0x00157001UL,
17+
0x00010008UL, 0x0000007FUL,
18+
0x00010018UL, 0x00000000UL,
19+
0x0001001CUL, 0x00000000UL,
20+
0x00010028UL, 0x00000000UL,
21+
0x0001002CUL, 0x00000000UL,
22+
0x00010030UL, 0x00000000UL,
23+
0x00010034UL, 0x00000000UL,
24+
0x0001003CUL, 0x00000000UL,
25+
0x00010040UL, 0x000007A0UL,
26+
0x00010048UL, 0x00000000UL,
27+
0x00010054UL, 0x00000000UL,
28+
0x00010058UL, 0x00000000UL,
29+
0x000100A0UL, 0x00004000UL,
30+
0x000100A4UL, 0x00004CFFUL,
31+
0x000100A8UL, 0x00004100UL,
32+
0x000100ACUL, 0x00004DFFUL,
33+
0x00012000UL, 0x00000704UL,
34+
0x00012010UL, 0x00000000UL,
35+
0x00012018UL, 0x00008408UL,
36+
0x00013008UL, 0x0000AC3FUL,
37+
0x0001302CUL, 0x01F50AAAUL,
38+
0x00013030UL, 0x00104924UL,
39+
0x00013034UL, 0x00000001UL,
40+
0x0001303CUL, 0x00010AABUL,
41+
0x00013040UL, 0x00000000UL,
42+
0x000140A0UL, 0x0F00277AUL,
43+
0x000140F4UL, 0x00001020UL,
44+
0x00014134UL, 0x00000880UL,
45+
0x00014138UL, 0x000087E6UL,
46+
0x00014140UL, 0x0088006DUL,
47+
0x00014144UL, 0x1153E6C0UL,
48+
0x00016014UL, 0x00000010UL,
49+
0x00016018UL, 0x0413F920UL,
50+
0x0001601CUL, 0x0052C007UL,
51+
0x00016020UL, 0x000000C8UL,
52+
0x00016024UL, 0x00000000UL,
53+
0x00016028UL, 0x03000000UL,
54+
0x0001602CUL, 0x00000000UL,
55+
0x00016030UL, 0x00FF0264UL,
56+
0x00016034UL, 0x000008A2UL,
57+
0x00016038UL, 0x00000001UL,
58+
0x0001603CUL, 0x000807B0UL,
59+
0x00016040UL, 0x000000A7UL,
60+
0x00016044UL, 0x00000000UL,
61+
0x00016048UL, 0x0AC00141UL,
62+
0x0001604CUL, 0x744AC39BUL,
63+
0x00016050UL, 0x000003F0UL,
64+
0x00016054UL, 0x00000000UL,
65+
0x00016058UL, 0x00000000UL,
66+
0x0001605CUL, 0x30100101UL,
67+
0x00016060UL, 0x7F7F7050UL,
68+
0x00016064UL, 0x00000000UL,
69+
0x00017014UL, 0x000270FAUL,
70+
0x00017018UL, 0x00001800UL,
71+
0x0001701CUL, 0x82840000UL,
72+
0x00017028UL, 0x01800000UL,
73+
0x00017048UL, 0x00003D3CUL,
74+
0x0001704CUL, 0x000019BCUL,
75+
0x00017070UL, 0x00010103UL,
76+
0x00017074UL, 0x00000442UL,
77+
0x00017078UL, 0x00552300UL,
78+
0xFFFFFFFFUL,
79+
};
80+
81+
const uint32_t ieee802154_config_base_min[] = {
82+
0x01010FFCUL, 0x0003C00EUL,
83+
0x0001303CUL, 0x00010AABUL,
84+
0x00016034UL, 0x000008A2UL,
85+
0x00016038UL, 0x00000001UL,
86+
0x00017078UL, 0x00552300UL,
87+
0xFFFFFFFFUL,
88+
};
89+
90+
const uint32_t ieee802154_config_2415MHz_min[] = {
91+
0x01010FFCUL, 0x0003C00AUL,
92+
0x0001303CUL, 0x00003555UL,
93+
0xFFFFFFFFUL,
94+
};
95+
96+
const uint32_t ieee802154_config_2420MHz_min[] = {
97+
0x0001303CUL, 0x00003555UL,
98+
0x00016034UL, 0x000004A1UL,
99+
0x00016038UL, 0x00000009UL,
100+
0x00017078UL, 0x0049E006UL,
101+
0xFFFFFFFFUL,
102+
};
103+

0 commit comments

Comments
 (0)