
The MCR20A Wireless UART application functions as an wireless UART bridge between two (one-to-one) or several (one to many) boards. The application can be used with both a TERM, or with software that is capable of opening a serial port and writing to or reading from it. The characters sent or received are not necessarily ASCII printable characters.
Dependencies: fsl_phy_mcr20a fsl_smac mbed-rtos mbed
Fork of mcr20_wireless_uart by
By default, the application uses broadcast addresses for OTA communication. This way, the application can be directly downloaded and run without any user intervention. The following use case assumes no changes have been done to the project.
- Two (or more) MCR20A platforms (plugged into the FRDM-K64F Freescale Freedom Development platform) have to be connected to the PC using the mini/micro-USB cables.
- The code must be downloaded on the platforms via CMSIS-DAP (or other means).
- After that, two or more TERM applications must be opened, and the serial ports must be configured with the same baud rate as the one in the project (default baud rate is 115200). Other necessary serial configurations are 8 bit, no parity, and 1 stop bit.
- To start the setup, each platform must be reset, and one of the (user) push buttons found on the MCR20A platform must be pressed. The user can press any of the non-reset buttons on the FRDM-K64F Freescale Freedom Development platform as well. *This initiates the state machine of the application so user can start.
Documentation
SMAC Demo Applications User Guide
IEEE802_14_5_PHY/MpmInterface.h@18:b02fc0e53df8, 2015-04-03 (annotated)
- Committer:
- cotigac
- Date:
- Fri Apr 03 05:23:33 2015 +0000
- Revision:
- 18:b02fc0e53df8
Started creating wireless uart demo based on mbed-rtos
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cotigac | 18:b02fc0e53df8 | 1 | /*! |
cotigac | 18:b02fc0e53df8 | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
cotigac | 18:b02fc0e53df8 | 3 | * All rights reserved. |
cotigac | 18:b02fc0e53df8 | 4 | * |
cotigac | 18:b02fc0e53df8 | 5 | * \file MpmInterface.h |
cotigac | 18:b02fc0e53df8 | 6 | * This is a header file for the Multiple PAN Manager. |
cotigac | 18:b02fc0e53df8 | 7 | * |
cotigac | 18:b02fc0e53df8 | 8 | * Redistribution and use in source and binary forms, with or without modification, |
cotigac | 18:b02fc0e53df8 | 9 | * are permitted provided that the following conditions are met: |
cotigac | 18:b02fc0e53df8 | 10 | * |
cotigac | 18:b02fc0e53df8 | 11 | * o Redistributions of source code must retain the above copyright notice, this list |
cotigac | 18:b02fc0e53df8 | 12 | * of conditions and the following disclaimer. |
cotigac | 18:b02fc0e53df8 | 13 | * |
cotigac | 18:b02fc0e53df8 | 14 | * o Redistributions in binary form must reproduce the above copyright notice, this |
cotigac | 18:b02fc0e53df8 | 15 | * list of conditions and the following disclaimer in the documentation and/or |
cotigac | 18:b02fc0e53df8 | 16 | * other materials provided with the distribution. |
cotigac | 18:b02fc0e53df8 | 17 | * |
cotigac | 18:b02fc0e53df8 | 18 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
cotigac | 18:b02fc0e53df8 | 19 | * contributors may be used to endorse or promote products derived from this |
cotigac | 18:b02fc0e53df8 | 20 | * software without specific prior written permission. |
cotigac | 18:b02fc0e53df8 | 21 | * |
cotigac | 18:b02fc0e53df8 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
cotigac | 18:b02fc0e53df8 | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
cotigac | 18:b02fc0e53df8 | 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
cotigac | 18:b02fc0e53df8 | 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
cotigac | 18:b02fc0e53df8 | 26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
cotigac | 18:b02fc0e53df8 | 27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
cotigac | 18:b02fc0e53df8 | 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
cotigac | 18:b02fc0e53df8 | 29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
cotigac | 18:b02fc0e53df8 | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
cotigac | 18:b02fc0e53df8 | 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
cotigac | 18:b02fc0e53df8 | 32 | */ |
cotigac | 18:b02fc0e53df8 | 33 | |
cotigac | 18:b02fc0e53df8 | 34 | #ifndef __MPM_H__ |
cotigac | 18:b02fc0e53df8 | 35 | #define __MPM_H__ |
cotigac | 18:b02fc0e53df8 | 36 | |
cotigac | 18:b02fc0e53df8 | 37 | /************************************************************************************ |
cotigac | 18:b02fc0e53df8 | 38 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 39 | * Include |
cotigac | 18:b02fc0e53df8 | 40 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 41 | ************************************************************************************/ |
cotigac | 18:b02fc0e53df8 | 42 | |
cotigac | 18:b02fc0e53df8 | 43 | #include "EmbeddedTypes.h" |
cotigac | 18:b02fc0e53df8 | 44 | //#include "fsl_os_abstraction.h" |
cotigac | 18:b02fc0e53df8 | 45 | #include "PhyInterface.h" |
cotigac | 18:b02fc0e53df8 | 46 | |
cotigac | 18:b02fc0e53df8 | 47 | /************************************************************************************ |
cotigac | 18:b02fc0e53df8 | 48 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 49 | * Public macros |
cotigac | 18:b02fc0e53df8 | 50 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 51 | ************************************************************************************/ |
cotigac | 18:b02fc0e53df8 | 52 | |
cotigac | 18:b02fc0e53df8 | 53 | /* The maximun number of MAC instances that can be registered. |
cotigac | 18:b02fc0e53df8 | 54 | * If set to 0, the MPM is disabled! |
cotigac | 18:b02fc0e53df8 | 55 | */ |
cotigac | 18:b02fc0e53df8 | 56 | #if !defined(gMpmMaxPANs_c) |
cotigac | 18:b02fc0e53df8 | 57 | #define gMpmMaxPANs_c 1 |
cotigac | 18:b02fc0e53df8 | 58 | #endif |
cotigac | 18:b02fc0e53df8 | 59 | |
cotigac | 18:b02fc0e53df8 | 60 | #define gMpmIncluded_d (gMpmMaxPANs_c > 1) |
cotigac | 18:b02fc0e53df8 | 61 | |
cotigac | 18:b02fc0e53df8 | 62 | #define gMpmPhyPanRegSets_c (2) |
cotigac | 18:b02fc0e53df8 | 63 | #define gMpmUseDifferentTxPwrLevel_c (0) |
cotigac | 18:b02fc0e53df8 | 64 | #define gMpmAcquireIsBlocking_d (0) |
cotigac | 18:b02fc0e53df8 | 65 | #define gMpmInvalidRegSet_c (gMpmPhyPanRegSets_c) |
cotigac | 18:b02fc0e53df8 | 66 | |
cotigac | 18:b02fc0e53df8 | 67 | /* Dual Pan Dwell settings |
cotigac | 18:b02fc0e53df8 | 68 | +-----------------+---------------------+ |
cotigac | 18:b02fc0e53df8 | 69 | | PRESCALER | RANGE | |
cotigac | 18:b02fc0e53df8 | 70 | | bits [1:0] | bits [7:2] | |
cotigac | 18:b02fc0e53df8 | 71 | +------+----------+---------------------+ |
cotigac | 18:b02fc0e53df8 | 72 | |value | timebase | min - max | |
cotigac | 18:b02fc0e53df8 | 73 | +------+----------+---------------------+ |
cotigac | 18:b02fc0e53df8 | 74 | | 00 | 0.5 ms | 0.5 - 32 ms | |
cotigac | 18:b02fc0e53df8 | 75 | | 01 | 2.5 ms | 2.5 - 160 ms | |
cotigac | 18:b02fc0e53df8 | 76 | | 10 | 10 ms | 10 - 640 ms | |
cotigac | 18:b02fc0e53df8 | 77 | | 11 | 50 ms | 50 - 3.2 seconds | |
cotigac | 18:b02fc0e53df8 | 78 | +------+----------+---------------------+ |
cotigac | 18:b02fc0e53df8 | 79 | */ |
cotigac | 18:b02fc0e53df8 | 80 | |
cotigac | 18:b02fc0e53df8 | 81 | /* Dwell Time prescaller (0 to 3) */ |
cotigac | 18:b02fc0e53df8 | 82 | #define mDefaultDualPanDwellPrescaller_c (0x00) // 0,5 ms |
cotigac | 18:b02fc0e53df8 | 83 | #define mDualPanDwellPrescallerMask_c (0x03) |
cotigac | 18:b02fc0e53df8 | 84 | #define mDualPanDwellPrescallerShift_c (0) |
cotigac | 18:b02fc0e53df8 | 85 | |
cotigac | 18:b02fc0e53df8 | 86 | /* Dwell Time value (0 to 63) */ |
cotigac | 18:b02fc0e53df8 | 87 | #define mDefaultDualPanDwellTime_c (0x06) |
cotigac | 18:b02fc0e53df8 | 88 | #define mDualPanDwellTimeMask_c (0xFC) |
cotigac | 18:b02fc0e53df8 | 89 | #define mDualPanDwellTimeShift_c (2) |
cotigac | 18:b02fc0e53df8 | 90 | |
cotigac | 18:b02fc0e53df8 | 91 | |
cotigac | 18:b02fc0e53df8 | 92 | #if (gMpmMaxPANs_c > gMpmPhyPanRegSets_c) |
cotigac | 18:b02fc0e53df8 | 93 | #error The number of PANs exceeds the number of HW registry sets! This feature is not supported yet. |
cotigac | 18:b02fc0e53df8 | 94 | #endif |
cotigac | 18:b02fc0e53df8 | 95 | |
cotigac | 18:b02fc0e53df8 | 96 | /* MPM flags */ |
cotigac | 18:b02fc0e53df8 | 97 | #define gMpmFlagPanCoord_c (1 << 0) |
cotigac | 18:b02fc0e53df8 | 98 | #define gMpmFlagPromiscuous_c (1 << 1) |
cotigac | 18:b02fc0e53df8 | 99 | #define gMpmFlagRxOnWhenIdle_c (1 << 2) |
cotigac | 18:b02fc0e53df8 | 100 | |
cotigac | 18:b02fc0e53df8 | 101 | /************************************************************************************ |
cotigac | 18:b02fc0e53df8 | 102 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 103 | * Public type definitions |
cotigac | 18:b02fc0e53df8 | 104 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 105 | ************************************************************************************/ |
cotigac | 18:b02fc0e53df8 | 106 | |
cotigac | 18:b02fc0e53df8 | 107 | typedef PACKED_STRUCT mpmConfig_tag{ |
cotigac | 18:b02fc0e53df8 | 108 | bool_t autoMode; |
cotigac | 18:b02fc0e53df8 | 109 | uint8_t dwellTime; |
cotigac | 18:b02fc0e53df8 | 110 | uint8_t activeMAC; |
cotigac | 18:b02fc0e53df8 | 111 | }mpmConfig_t; |
cotigac | 18:b02fc0e53df8 | 112 | |
cotigac | 18:b02fc0e53df8 | 113 | typedef union panFlags_tag{ |
cotigac | 18:b02fc0e53df8 | 114 | uint16_t all; |
cotigac | 18:b02fc0e53df8 | 115 | struct{ |
cotigac | 18:b02fc0e53df8 | 116 | uint16_t panCoordinator: 1; |
cotigac | 18:b02fc0e53df8 | 117 | uint16_t promiscuous: 1; |
cotigac | 18:b02fc0e53df8 | 118 | uint16_t rxOnWhenIdle: 1; |
cotigac | 18:b02fc0e53df8 | 119 | uint16_t reserved: 13; |
cotigac | 18:b02fc0e53df8 | 120 | }; |
cotigac | 18:b02fc0e53df8 | 121 | }panFlags_t; |
cotigac | 18:b02fc0e53df8 | 122 | |
cotigac | 18:b02fc0e53df8 | 123 | typedef struct panInfo_tag{ |
cotigac | 18:b02fc0e53df8 | 124 | uint8_t flags; |
cotigac | 18:b02fc0e53df8 | 125 | uint8_t macInstance; |
cotigac | 18:b02fc0e53df8 | 126 | uint8_t phyRegSet; |
cotigac | 18:b02fc0e53df8 | 127 | int8_t locked; |
cotigac | 18:b02fc0e53df8 | 128 | #if (gMpmMaxPANs_c > gMpmPhyPanRegSets_c) |
cotigac | 18:b02fc0e53df8 | 129 | uint64_t longAddr; |
cotigac | 18:b02fc0e53df8 | 130 | uint16_t shortAddr; |
cotigac | 18:b02fc0e53df8 | 131 | uint16_t panId; |
cotigac | 18:b02fc0e53df8 | 132 | uint8_t channel; |
cotigac | 18:b02fc0e53df8 | 133 | #endif |
cotigac | 18:b02fc0e53df8 | 134 | #if gMpmUseDifferentTxPwrLevel_c |
cotigac | 18:b02fc0e53df8 | 135 | uint8_t pwrLevel; |
cotigac | 18:b02fc0e53df8 | 136 | #endif |
cotigac | 18:b02fc0e53df8 | 137 | }panInfo_t; |
cotigac | 18:b02fc0e53df8 | 138 | |
cotigac | 18:b02fc0e53df8 | 139 | #ifdef __cplusplus |
cotigac | 18:b02fc0e53df8 | 140 | extern "C" { |
cotigac | 18:b02fc0e53df8 | 141 | #endif |
cotigac | 18:b02fc0e53df8 | 142 | |
cotigac | 18:b02fc0e53df8 | 143 | /************************************************************************************ |
cotigac | 18:b02fc0e53df8 | 144 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 145 | * Public memory declarations |
cotigac | 18:b02fc0e53df8 | 146 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 147 | ************************************************************************************/ |
cotigac | 18:b02fc0e53df8 | 148 | |
cotigac | 18:b02fc0e53df8 | 149 | /************************************************************************************ |
cotigac | 18:b02fc0e53df8 | 150 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 151 | * Public functions |
cotigac | 18:b02fc0e53df8 | 152 | ************************************************************************************* |
cotigac | 18:b02fc0e53df8 | 153 | ************************************************************************************/ |
cotigac | 18:b02fc0e53df8 | 154 | #if gMpmIncluded_d |
cotigac | 18:b02fc0e53df8 | 155 | |
cotigac | 18:b02fc0e53df8 | 156 | void MPM_Init( void ); |
cotigac | 18:b02fc0e53df8 | 157 | void MPM_SetConfig( mpmConfig_t *pCfg ); |
cotigac | 18:b02fc0e53df8 | 158 | void MPM_GetConfig( mpmConfig_t *pCfg ); |
cotigac | 18:b02fc0e53df8 | 159 | |
cotigac | 18:b02fc0e53df8 | 160 | int32_t MPM_GetPanIndex( instanceId_t macInstance ); |
cotigac | 18:b02fc0e53df8 | 161 | uint32_t MPM_GetRegSet(uint8_t panIdx); |
cotigac | 18:b02fc0e53df8 | 162 | uint32_t MPM_GetMacInstanceFromRegSet(uint32_t regSet); |
cotigac | 18:b02fc0e53df8 | 163 | #define MPM_isPanActive( panIdx ) (MPM_GetRegSet(panIdx) != gMpmInvalidRegSet_c) |
cotigac | 18:b02fc0e53df8 | 164 | |
cotigac | 18:b02fc0e53df8 | 165 | phyStatus_t MPM_PrepareForTx( instanceId_t macInstance ); |
cotigac | 18:b02fc0e53df8 | 166 | phyStatus_t MPM_PrepareForRx( instanceId_t macInstance ); |
cotigac | 18:b02fc0e53df8 | 167 | phyStatus_t MPM_GetPIB(phyPibId_t pibId, void *pValue, uint8_t panIdx); |
cotigac | 18:b02fc0e53df8 | 168 | phyStatus_t MPM_SetPIB(phyPibId_t pibId, void *pValue, uint8_t panIdx); |
cotigac | 18:b02fc0e53df8 | 169 | |
cotigac | 18:b02fc0e53df8 | 170 | #else /* #if gMpmIncluded_d */ |
cotigac | 18:b02fc0e53df8 | 171 | |
cotigac | 18:b02fc0e53df8 | 172 | #define MPM_Init() |
cotigac | 18:b02fc0e53df8 | 173 | #define MPM_SetConfig( prescaller, dwellTime ) |
cotigac | 18:b02fc0e53df8 | 174 | |
cotigac | 18:b02fc0e53df8 | 175 | #define MPM_GetPanIndex( macInstance ) 0 |
cotigac | 18:b02fc0e53df8 | 176 | #define MPM_GetRegSet( panIdx ) 0 |
cotigac | 18:b02fc0e53df8 | 177 | #define MPM_GetMacInstanceFromRegSet( regSet ) 0 |
cotigac | 18:b02fc0e53df8 | 178 | #define MPM_isPanActive( panIdx ) 1 |
cotigac | 18:b02fc0e53df8 | 179 | |
cotigac | 18:b02fc0e53df8 | 180 | #define MPM_PrepareForTx( macInstance ) gPhySuccess_c |
cotigac | 18:b02fc0e53df8 | 181 | #define MPM_PrepareForRx( macInstance ) gPhySuccess_c |
cotigac | 18:b02fc0e53df8 | 182 | #define MPM_GetPIB( pibId, pibValue, panIdx ) gPhySuccess_c |
cotigac | 18:b02fc0e53df8 | 183 | #define MPM_SetPIB( pibId, pibValue, panIdx ) gPhySuccess_c |
cotigac | 18:b02fc0e53df8 | 184 | |
cotigac | 18:b02fc0e53df8 | 185 | #endif /* #if gMpmIncluded_d */ |
cotigac | 18:b02fc0e53df8 | 186 | |
cotigac | 18:b02fc0e53df8 | 187 | phyStatus_t MPM_AcquirePAN( instanceId_t macInstance ); |
cotigac | 18:b02fc0e53df8 | 188 | phyStatus_t MPM_ReleasePAN( instanceId_t macInstance ); |
cotigac | 18:b02fc0e53df8 | 189 | |
cotigac | 18:b02fc0e53df8 | 190 | #ifdef __cplusplus |
cotigac | 18:b02fc0e53df8 | 191 | } |
cotigac | 18:b02fc0e53df8 | 192 | #endif |
cotigac | 18:b02fc0e53df8 | 193 | |
cotigac | 18:b02fc0e53df8 | 194 | #endif /*__MPM_H__ */ |
cotigac | 18:b02fc0e53df8 | 195 |