Analog Devices / Mbed OS EVAL-ADMX2001

Dependencies:   ADMX2001

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers platform_support.cpp Source File

platform_support.cpp

Go to the documentation of this file.
00001 /***************************************************************************//**
00002  *   @file     platform_support.cpp
00003  *   @brief:   support functions and declarations for particular platform
00004  *   @details: This is a platform specific file that supports functionality
00005  *             required from application generic file. This file should be
00006  *             modified according to platform that you are working with.
00007 ********************************************************************************
00008  * Copyright (c) 2019, 2020 Analog Devices, Inc.
00009  *
00010  * All rights reserved.
00011  *
00012  * This software is proprietary to Analog Devices, Inc. and its licensors.
00013  * By using this software you agree to the terms of the associated
00014  * Analog Devices Software License Agreement.
00015 *******************************************************************************/
00016 
00017 /******************************************************************************/
00018 /************************ Includes Files **************************************/
00019 /******************************************************************************/
00020 #include <mbed.h>
00021 #include "platform_support.h"
00022 
00023 /******************************************************************************/
00024 /********************** Variables and User defined data types *****************/
00025 /******************************************************************************/
00026 
00027 #define BAUD_RATE        115200  // UART Communication Baud Rate
00028 
00029 /******************************************************************************/
00030 /************************ Variable Declarations *******************************/
00031 /******************************************************************************/
00032 
00033 // Configure and instantiate UART protocol and baud rate
00034 // *Note: Multiple instances of 'Serial' port can be created with different pins
00035 //        and baud rate settings. In that case, user must use desired 'Serial'
00036 //        instance/object to access the serial data, since order of declaration
00037 //        depends upon the user and compiler.
00038 static Serial port(USBTX, USBRX, BAUD_RATE);
00039 
00040 /******************************************************************************/
00041 /************************ Functions Definitions *******************************/
00042 /******************************************************************************/
00043 
00044 /**
00045   * @brief  getchar, but does not block if nothing waiting to be read
00046   * @param  None
00047   * @retval character if available, NULL otherwise
00048   */
00049 char getchar_noblock(void)
00050 {
00051     char rx_char = '\0';
00052 
00053     // Return the character read from the serial port
00054     if (port.readable() > 0) {
00055         rx_char = port.getc();
00056     }
00057 
00058     return rx_char;
00059 }