UserInterface

Committer:
roger5641
Date:
Sun Nov 12 01:22:00 2017 +0000
Revision:
0:61a21e393e36
ver1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
roger5641 0:61a21e393e36 1 //! @todo Review this file.
roger5641 0:61a21e393e36 2 /*
roger5641 0:61a21e393e36 3 UserInterface.h
roger5641 0:61a21e393e36 4
roger5641 0:61a21e393e36 5 UserInterface routines are used to read and write user data through the Arduino's
roger5641 0:61a21e393e36 6 serial interface.
roger5641 0:61a21e393e36 7
roger5641 0:61a21e393e36 8 Copyright (c) 2013, Linear Technology Corp.(LTC)
roger5641 0:61a21e393e36 9 All rights reserved.
roger5641 0:61a21e393e36 10
roger5641 0:61a21e393e36 11 Redistribution and use in source and binary forms, with or without
roger5641 0:61a21e393e36 12 modification, are permitted provided that the following conditions are met:
roger5641 0:61a21e393e36 13
roger5641 0:61a21e393e36 14 1. Redistributions of source code must retain the above copyright notice, this
roger5641 0:61a21e393e36 15 list of conditions and the following disclaimer.
roger5641 0:61a21e393e36 16 2. Redistributions in binary form must reproduce the above copyright notice,
roger5641 0:61a21e393e36 17 this list of conditions and the following disclaimer in the documentation
roger5641 0:61a21e393e36 18 and/or other materials provided with the distribution.
roger5641 0:61a21e393e36 19
roger5641 0:61a21e393e36 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
roger5641 0:61a21e393e36 21 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
roger5641 0:61a21e393e36 22 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
roger5641 0:61a21e393e36 23 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
roger5641 0:61a21e393e36 24 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
roger5641 0:61a21e393e36 25 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
roger5641 0:61a21e393e36 26 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
roger5641 0:61a21e393e36 27 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
roger5641 0:61a21e393e36 28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
roger5641 0:61a21e393e36 29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
roger5641 0:61a21e393e36 30
roger5641 0:61a21e393e36 31 The views and conclusions contained in the software and documentation are those
roger5641 0:61a21e393e36 32 of the authors and should not be interpreted as representing official policies,
roger5641 0:61a21e393e36 33 either expressed or implied, of Linear Technology Corp.
roger5641 0:61a21e393e36 34
roger5641 0:61a21e393e36 35 The Linear Technology Linduino is not affiliated with the official Arduino team.
roger5641 0:61a21e393e36 36 However, the Linduino is only possible because of the Arduino team's commitment
roger5641 0:61a21e393e36 37 to the open-source community. Please, visit http://www.arduino.cc and
roger5641 0:61a21e393e36 38 http://store.arduino.cc , and consider a purchase that will help fund their
roger5641 0:61a21e393e36 39 ongoing work.
roger5641 0:61a21e393e36 40 */
roger5641 0:61a21e393e36 41
roger5641 0:61a21e393e36 42 #ifndef USERINTERFACE_H
roger5641 0:61a21e393e36 43 #define USERINTERFACE_H
roger5641 0:61a21e393e36 44
roger5641 0:61a21e393e36 45 #include "mbed.h"
roger5641 0:61a21e393e36 46
roger5641 0:61a21e393e36 47 #define UI_BUFFER_SIZE 64
roger5641 0:61a21e393e36 48 #define SERIAL_TERMINATOR '\n'
roger5641 0:61a21e393e36 49
roger5641 0:61a21e393e36 50 Serial pc(USBTX,USBRX);
roger5641 0:61a21e393e36 51
roger5641 0:61a21e393e36 52 // io buffer
roger5641 0:61a21e393e36 53 extern char ui_buffer[UI_BUFFER_SIZE];
roger5641 0:61a21e393e36 54
roger5641 0:61a21e393e36 55 // Read data from the serial interface into the ui_buffer buffer
roger5641 0:61a21e393e36 56 uint8_t read_data();
roger5641 0:61a21e393e36 57
roger5641 0:61a21e393e36 58 // Read a float value from the serial interface
roger5641 0:61a21e393e36 59 float read_float();
roger5641 0:61a21e393e36 60
roger5641 0:61a21e393e36 61 // Read an integer from the serial interface.
roger5641 0:61a21e393e36 62 // The routine can recognize Hex, Decimal, Octal, or Binary
roger5641 0:61a21e393e36 63 // Example:
roger5641 0:61a21e393e36 64 // Hex: 0x11 (0x prefix)
roger5641 0:61a21e393e36 65 // Decimal: 17
roger5641 0:61a21e393e36 66 // Octal: O21 (leading letter O prefix)
roger5641 0:61a21e393e36 67 // Binary: B10001 (leading letter B prefix)
roger5641 0:61a21e393e36 68 int32_t read_int();
roger5641 0:61a21e393e36 69
roger5641 0:61a21e393e36 70 // Read a string from the serial interface. Returns a pointer to the ui_buffer.
roger5641 0:61a21e393e36 71 char *read_string();
roger5641 0:61a21e393e36 72
roger5641 0:61a21e393e36 73 // Read a character from the serial interface
roger5641 0:61a21e393e36 74 int8_t read_char();
roger5641 0:61a21e393e36 75
roger5641 0:61a21e393e36 76 #endif // USERINTERFACE_H