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 Freescale

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

Committer:
andreikovacs
Date:
Tue Aug 18 13:04:46 2015 +0000
Revision:
28:2555c5ae3ccd
Parent:
27:1eb29717bfd9
Added fsl_phy_mcr20a and fsl_smac libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andreikovacs 27:1eb29717bfd9 1 #include "circular_buffer.h"
andreikovacs 27:1eb29717bfd9 2
andreikovacs 27:1eb29717bfd9 3 CircularBuffer::CircularBuffer()
andreikovacs 27:1eb29717bfd9 4 {
andreikovacs 27:1eb29717bfd9 5 size = gCircularBufferSize_c;
andreikovacs 27:1eb29717bfd9 6 readIndex = 0;
andreikovacs 27:1eb29717bfd9 7 writeIndex = 0;
andreikovacs 27:1eb29717bfd9 8 count = 0;
andreikovacs 27:1eb29717bfd9 9 MEM_Init();
andreikovacs 27:1eb29717bfd9 10 buffer = (uint8_t *) MEM_BufferAlloc(size * sizeof(uint8_t));
andreikovacs 27:1eb29717bfd9 11 if ( NULL == buffer )
andreikovacs 27:1eb29717bfd9 12 {
andreikovacs 27:1eb29717bfd9 13 /*if buffer alloc fails stop the program execution*/
andreikovacs 27:1eb29717bfd9 14 while(1);
andreikovacs 27:1eb29717bfd9 15 }
andreikovacs 27:1eb29717bfd9 16 }
andreikovacs 27:1eb29717bfd9 17
andreikovacs 27:1eb29717bfd9 18 CircularBuffer::CircularBuffer(uint32_t sz)
andreikovacs 27:1eb29717bfd9 19 {
andreikovacs 27:1eb29717bfd9 20 size = sz;
andreikovacs 27:1eb29717bfd9 21 readIndex = 0;
andreikovacs 27:1eb29717bfd9 22 writeIndex = 0;
andreikovacs 27:1eb29717bfd9 23 count = 0;
andreikovacs 27:1eb29717bfd9 24 MEM_Init();
andreikovacs 27:1eb29717bfd9 25 buffer = (uint8_t *) MEM_BufferAlloc(size * sizeof(uint8_t));
andreikovacs 27:1eb29717bfd9 26 if ( NULL == buffer )
andreikovacs 27:1eb29717bfd9 27 {
andreikovacs 27:1eb29717bfd9 28 /*if buffer alloc fails stop the program execution*/
andreikovacs 27:1eb29717bfd9 29 while(1);
andreikovacs 27:1eb29717bfd9 30 }
andreikovacs 27:1eb29717bfd9 31 }
andreikovacs 27:1eb29717bfd9 32
andreikovacs 27:1eb29717bfd9 33 CircularBuffer::~CircularBuffer()
andreikovacs 27:1eb29717bfd9 34 {
andreikovacs 27:1eb29717bfd9 35 size = 0;
andreikovacs 27:1eb29717bfd9 36 readIndex = 0;
andreikovacs 27:1eb29717bfd9 37 writeIndex = 0;
andreikovacs 27:1eb29717bfd9 38 count = 0;
andreikovacs 27:1eb29717bfd9 39 MEM_BufferFree(buffer);
andreikovacs 27:1eb29717bfd9 40 }
andreikovacs 27:1eb29717bfd9 41
andreikovacs 27:1eb29717bfd9 42 bufferStatus_t CircularBuffer :: addToBuffer (uint8_t c)
andreikovacs 27:1eb29717bfd9 43 {
andreikovacs 27:1eb29717bfd9 44 buffer[writeIndex] = c;
andreikovacs 27:1eb29717bfd9 45 writeIndex++;
andreikovacs 27:1eb29717bfd9 46 if (writeIndex >= size)
andreikovacs 27:1eb29717bfd9 47 {
andreikovacs 27:1eb29717bfd9 48 writeIndex = 0;
andreikovacs 27:1eb29717bfd9 49 }
andreikovacs 27:1eb29717bfd9 50 count++;
andreikovacs 27:1eb29717bfd9 51 if (count >= size)
andreikovacs 27:1eb29717bfd9 52 {
andreikovacs 27:1eb29717bfd9 53 return buffer_Full_c;
andreikovacs 27:1eb29717bfd9 54 }
andreikovacs 27:1eb29717bfd9 55 return buffer_Ok_c;
andreikovacs 27:1eb29717bfd9 56 }
andreikovacs 27:1eb29717bfd9 57
andreikovacs 27:1eb29717bfd9 58 bufferStatus_t CircularBuffer :: getFromBuffer (uint8_t *c)
andreikovacs 27:1eb29717bfd9 59 {
andreikovacs 27:1eb29717bfd9 60 if ( 0 == count )
andreikovacs 27:1eb29717bfd9 61 {
andreikovacs 27:1eb29717bfd9 62 return buffer_Empty_c;
andreikovacs 27:1eb29717bfd9 63 }
andreikovacs 27:1eb29717bfd9 64 (*c) = buffer[readIndex];
andreikovacs 27:1eb29717bfd9 65 readIndex++;
andreikovacs 27:1eb29717bfd9 66 if (readIndex >= size)
andreikovacs 27:1eb29717bfd9 67 {
andreikovacs 27:1eb29717bfd9 68 readIndex = 0;
andreikovacs 27:1eb29717bfd9 69 }
andreikovacs 27:1eb29717bfd9 70 count--;
andreikovacs 27:1eb29717bfd9 71 return buffer_Ok_c;
andreikovacs 27:1eb29717bfd9 72 }
andreikovacs 27:1eb29717bfd9 73
andreikovacs 27:1eb29717bfd9 74 uint32_t CircularBuffer :: getCount()
andreikovacs 27:1eb29717bfd9 75 {
andreikovacs 27:1eb29717bfd9 76 return count;
andreikovacs 27:1eb29717bfd9 77 }