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

RF_Drivers_Atmel/driverDebug.c

Committer:
sam_grove
Date:
2015-03-05
Revision:
4:d47832caea44
Parent:
RF_Drivers/driverDebug.c@ 2:3e7685cfb2a7

File content as of revision 4:d47832caea44:

//#include "system_event.h"
//#include <string.h>
//#include "pl_types.h"
//#include "pcer_low_level.h"
//#include "pio_low_level.h"
#include "driverDebug.h"
//#include "uart_low_level.h"
//#include "usart_low_level.h"
//#include "SAMxxBoardDefinitions.h"
//#include "arm_hal_interrupt.h"
#include <stdio.h>

#define debug printf


/**
  * Send string to debug port.
  *
  * \param str String pointer. Have to end by zero ('\0')
  *
  */
#if 0
void debug_send1(uint8_t *str)
{
    while(*str)
    {
        if (debug_put(*str) == 0)
        {
            str++;
        }
        else return;
    }
}
#endif

/**
  * Send constant string to debug port.
  *
  * \param str Constant string pointer.
  *
  */
#if 0
void debug_send_const(prog_uint8_t *str)
{
    while(*str)
    {
        //if (debug_put(*str) == 0)
        if (printf(str) == 0)
        {
            str++;
        }
        else return;
    }
}
#endif

/*
 * \brief Help round function.
 *
 * \param value Divident
 * \param divider Divisor
 *
 * \return Quotient
 */
uint32_t debug_round(uint32_t value, uint32_t divider)
{
    uint32_t tmp = value;
    value *= 10;
    value /= divider;
    tmp = value;
    while(tmp > 10)
        tmp -= 10;
    if(((tmp & 0x0000000f) > 4) && ((tmp & 0x0000000f) < 10))
        value += 10;
    if(tmp != 10)
        value -= tmp;
    value /= 10;
    return value;
}

/**
 * Print a number to the debug port.
 *
 * \param width string maximum length
 * \param base base number (16 for hex, 10 for decimal etc.)
 * \param n number value
 *
 * \return pointer to the formatted string
 */
void debug_integer(uint8_t width, uint8_t base, int16_t n)
{
  uint8_t bfr[8];
  uint8_t *ptr = bfr;
  uint8_t ctr = 0;

  if (width > 7) width = 7;

  ptr += width;
  *ptr-- = 0;

  if (base == 16)
  {
      do
      {
          *ptr = n & 0x0F;
          if (*ptr < 10) *ptr += '0';
          else *ptr += ('A'-10);
          ptr--;
          n >>= 4;
          ctr++;
      }while((ctr & 1) || (ctr < width));
  }
  else
  {
      uint8_t negative = 0;
      if (n < 0)
      { negative = 1;
        n = -n;
      }
      ctr++;
      do
      {
        *ptr-- = (n % 10) + '0';
        n /= 10;
        ctr++;
      }while ((ctr < width) && n);
      if (negative)
      {
        *ptr-- = '-';
      }
      else
      {
        *ptr-- = ' ';
      }
  }
  ptr++;
  //debug_send(ptr);
    debug(ptr);
}

/**
  * Print data array in HEX format. Bytes are separated with colon.
  *
  * \param ptr Pointer to 8-bit data array.
  * \param len Amount of printed bytes
  *
  */
void printf_array(uint8_t *ptr , uint16_t len)
{
    uint16_t i;
    for(i=0; i<len; i++)
    {
        if(i)
        {
            if(i%16== 0)
            {
                debug("\r\n");
                if(len > 64)
                {
                    uint8_t x =254;
                    while(x--);
                }
            }
            else
            {
                debug(":");
            }
        }
        debug_hex(*ptr++);
    }
    debug("\r\n");
}

/**
 * Print a IPv6 address.
 *
 * \param addr_ptr pointer to ipv6 address
 *
 */
void printf_ipv6_address(uint8_t *addr_ptr)
{
    if(addr_ptr)
    {
        uint8_t i, d_colon = 0;
        uint16_t current_value = 0, last_value = 0;

        for(i=0; i< 16;i += 2)
        {
            current_value =  (*addr_ptr++ << 8);
            current_value += *addr_ptr++;

            if(i == 0)
            {
                last_value = current_value;
                debug_hex(current_value >> 8);
                debug_hex(current_value );
                debug(":");
            }
            else
            {
                if(current_value == 0)
                {
                    if(i== 14)
                    {
                        debug(":");
                        //debug_put('0');
                        debug("0");
                    }
                    else
                    {
                        if(last_value == 0)
                        {
                            if(d_colon == 0)
                            {
                                d_colon=1;
                            }
                        }
                        else
                        {
                            if(d_colon == 2)
                            {
                                //debug_put('0');
                                debug("0");
                                debug(":");
                            }
                        }
                    }
                }
                else
                {
                    if(last_value == 0)
                    {
                        if(d_colon == 1)
                        {
                            debug(":");
                            d_colon = 2;
                        }
                        else
                        {
                            //debug_put('0');
                            debug("0");
                            debug(":");
                        }
                    }
                    if(current_value > 0x00ff)
                    {
                        debug_hex(current_value >> 8);
                    }
                    debug_hex(current_value );
                    if(i< 14)
                    {
                        debug(":");
                    }
                }
                last_value = current_value;
            }
        }
    }
    else
    {
        debug("Address Print: pointer NULL");
    }
    debug("\r\n");
}