Enda Kilgarriff / platform_drivers
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 
00028 
00029 /******************************************************************************/
00030 /************************ Variable Declarations *******************************/
00031 /******************************************************************************/
00032 
00033 // Configure and instantiate Serial object to access the stdin.
00034 // The default mbed baud rate is 9600, unless is it overriden in the
00035 // mbed_app.json file, or by creating another Serial object using the same pins.
00036 static Serial port(USBTX, USBRX);
00037 
00038 /******************************************************************************/
00039 /************************ Functions Definitions *******************************/
00040 /******************************************************************************/
00041 
00042 /**
00043   * @brief  getchar, but does not block if nothing waiting to be read
00044   * @param  None
00045   * @return character if available, NULL otherwise
00046   */
00047 char getchar_noblock(void)
00048 {
00049     char rx_char = '\0';
00050 
00051     // Return the character read from the serial port
00052     if (port.readable() > 0) {
00053         rx_char = port.getc();
00054     }
00055 
00056     return rx_char;
00057 }