Update platform drivers

Committer:
mahphalke
Date:
Wed Feb 26 06:09:13 2020 +0000
Revision:
8:70fc373a5f46
Child:
9:9e247b9c9abf
Structured platform drivers similar to github version by splitting functionality from single file into multiple modules.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mahphalke 8:70fc373a5f46 1 /***************************************************************************//**
mahphalke 8:70fc373a5f46 2 * @file platform_support.cpp
mahphalke 8:70fc373a5f46 3 * @brief: support functions and declarations for particular platform
mahphalke 8:70fc373a5f46 4 * @details: This is a platform specific file that supports functionality
mahphalke 8:70fc373a5f46 5 * required from application generic file. This file should be
mahphalke 8:70fc373a5f46 6 * modified according to platform that you are working with.
mahphalke 8:70fc373a5f46 7 ********************************************************************************
mahphalke 8:70fc373a5f46 8 * Copyright (c) 2019, 2020 Analog Devices, Inc.
mahphalke 8:70fc373a5f46 9 *
mahphalke 8:70fc373a5f46 10 * All rights reserved.
mahphalke 8:70fc373a5f46 11 *
mahphalke 8:70fc373a5f46 12 * This software is proprietary to Analog Devices, Inc. and its licensors.
mahphalke 8:70fc373a5f46 13 * By using this software you agree to the terms of the associated
mahphalke 8:70fc373a5f46 14 * Analog Devices Software License Agreement.
mahphalke 8:70fc373a5f46 15 *******************************************************************************/
mahphalke 8:70fc373a5f46 16
mahphalke 8:70fc373a5f46 17 /******************************************************************************/
mahphalke 8:70fc373a5f46 18 /************************ Includes Files **************************************/
mahphalke 8:70fc373a5f46 19 /******************************************************************************/
mahphalke 8:70fc373a5f46 20 #include <mbed.h>
mahphalke 8:70fc373a5f46 21 #include "platform_support.h"
mahphalke 8:70fc373a5f46 22
mahphalke 8:70fc373a5f46 23 /******************************************************************************/
mahphalke 8:70fc373a5f46 24 /********************** Variables and User defined data types *****************/
mahphalke 8:70fc373a5f46 25 /******************************************************************************/
mahphalke 8:70fc373a5f46 26
mahphalke 8:70fc373a5f46 27 #define BAUD_RATE 115200 // UART Communication Baud Rate
mahphalke 8:70fc373a5f46 28
mahphalke 8:70fc373a5f46 29 /******************************************************************************/
mahphalke 8:70fc373a5f46 30 /************************ Variable Declarations *******************************/
mahphalke 8:70fc373a5f46 31 /******************************************************************************/
mahphalke 8:70fc373a5f46 32
mahphalke 8:70fc373a5f46 33 // Configure and instantiate UART protocol and baud rate
mahphalke 8:70fc373a5f46 34 // *Note: Multiple instances of 'Serial' port can be created with different pins
mahphalke 8:70fc373a5f46 35 // and baud rate settings. In that case, user must use desired 'Serial'
mahphalke 8:70fc373a5f46 36 // instance/object to access the serial data, since order of declaration
mahphalke 8:70fc373a5f46 37 // depends upon the user and compiler.
mahphalke 8:70fc373a5f46 38 static Serial port(USBTX, USBRX, BAUD_RATE);
mahphalke 8:70fc373a5f46 39
mahphalke 8:70fc373a5f46 40 /******************************************************************************/
mahphalke 8:70fc373a5f46 41 /************************ Functions Definitions *******************************/
mahphalke 8:70fc373a5f46 42 /******************************************************************************/
mahphalke 8:70fc373a5f46 43
mahphalke 8:70fc373a5f46 44 /**
mahphalke 8:70fc373a5f46 45 * @brief getchar, but does not block if nothing waiting to be read
mahphalke 8:70fc373a5f46 46 * @param None
mahphalke 8:70fc373a5f46 47 * @retval character if available, NULL otherwise
mahphalke 8:70fc373a5f46 48 */
mahphalke 8:70fc373a5f46 49 char getchar_noblock(void)
mahphalke 8:70fc373a5f46 50 {
mahphalke 8:70fc373a5f46 51 char rx_char = '\0';
mahphalke 8:70fc373a5f46 52
mahphalke 8:70fc373a5f46 53 // Return the character read from the serial port
mahphalke 8:70fc373a5f46 54 if (port.readable() > 0) {
mahphalke 8:70fc373a5f46 55 rx_char = port.getc();
mahphalke 8:70fc373a5f46 56 }
mahphalke 8:70fc373a5f46 57
mahphalke 8:70fc373a5f46 58 return rx_char;
mahphalke 8:70fc373a5f46 59 }