Ted Grosch / Mbed 2 deprecated Nucleo_TOF_I2C

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hostController.h Source File

hostController.h

Go to the documentation of this file.
00001 /*! 
00002 * \file hostController.h
00003 * \author  Karthik Rajagopal <krthik@ti.com>
00004 * \version 0.9.1
00005 *
00006 * \section COPYRIGHT
00007 * TEXAS INSTRUMENTS TEXT FILE LICENSE
00008 * Copyright (c) 2018 Texas Instruments Incorporated
00009 * All rights reserved not granted herein.
00010 * Limited License.
00011 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive license under copyrights and patents it now or hereafter owns or controls to make, have made, use, import, offer to sell and sell ("Utilize") this software subject to the terms herein.  With respect to the foregoing patent license, such license is granted  solely to the extent that any such patent is necessary to Utilize the software alone.  The patent license shall not apply to any combinations which include this software, other than combinations with devices manufactured by or for TI ("TI Devices").  No hardware patent is licensed hereunder.
00012 * Redistributions must preserve existing copyright notices and reproduce this license (including the above copyright notice and the disclaimer and (if applicable) source code license limitations below) in the documentation and/or other materials provided with the distribution
00013 * Redistribution and use in binary form, without modification, are permitted provided that the following conditions are met:
00014 * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any software provided in binary form.
00015 * * any redistribution and use are licensed by TI for use only with TI Devices.
00016 * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
00017 * If software source code is provided to you, modification and redistribution of the source code are permitted provided that the following conditions are met:
00018 * * any redistribution and use of the source code, including any resulting derivative works, are licensed by TI for use only with TI Devices.
00019 * * any redistribution and use of any object code compiled from the source code and any resulting derivative works, are licensed by TI for use only with TI Devices.
00020 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or promote products derived from this software without specific prior written permission.
00021 * DISCLAIMER.
00022 * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00023 *
00024 * \section DESCRIPTION
00025 * This file contains the hostController class. This file contains a general template for a host controller
00026 */
00027 #ifndef HOSTCONTROLLER_H_
00028 #define HOSTCONTROLLER_H_
00029 
00030 #include "i2cHandler.h"
00031 //#include "definitions.h"
00032 
00033 //#ifdef TIMSP430F5529_LAUNCHPAD_CALIBRATION_TOOL
00034 //#include "MSP430/i2cHandler.h"
00035 //#include "MSP430/flashHandler.h"
00036 //#include "MSP430/MSPConnections.h"
00037 //extern "C"
00038 //{
00039 //#include "MSP430/hal.h"
00040 //#include "MSP430/USB_config/descriptors.h"
00041 //#include "MSP430/USB_API/USB_Common/device.h"
00042 //#include "MSP430/USB_API/USB_Common/usb.h"                 // USB-specific functions
00043 //#include "MSP430/USB_API/USB_CDC_API/UsbCdc.h"
00044 //#include "MSP430/USB_app/usbConstructs.h"
00045 //}
00046 //#include <stdlib.h> //Added to support abs function
00047 //#endif
00048 
00049 //#include <stdint.h>
00050 
00051 //#ifdef OPT3101_USE_SERIALLIB 
00052 //#include "serialLib/serial.h"
00053 //#ifdef _WIN32
00054 //#include <windows.h>
00055 //#else
00056 //#include <unistd.h>
00057 //#endif /*_WIN32 */
00058 //#endif /* for OPT3101_USE_SERIALLIB */
00059 
00060 //#ifdef OPT3101_USE_STDIOLIB 
00061 //#include <stdio.h>
00062 /*! \def filename length
00063 This sets memory allocation length for file naming strings
00064 */
00065 //#define FILENAME_LENGTH 50
00066 //const char filePath[] = { "C:/temp/" };
00067 //#endif
00068 
00069 //#ifdef OPT3101_USE_SERIALLIB
00070 /** \brief Serial Command Port  declaration
00071 This global variable declaration with name OPT3101commandPort of class serial::Serial is used by class like OPT3101::deviceRegister for I2C read and writes.
00072 */
00073 //serial::Serial OPT3101commandPort("COM4", 9600, serial::Timeout::simpleTimeout(1000));
00074 //#if defined(linux) || defined(_WIN32)
00075 //extern serial::Serial OPT3101I2CCommandPort;
00076 //#endif
00077 
00078 //#endif // SERIAL LIB
00079 
00080 class hostController;
00081 
00082 
00083 //#ifdef OPT3101_USE_STDIOLIB 
00084 /** \brief filePath
00085 This global variable to declare a path to all calibration files storage 
00086 */
00087 //extern const char filePath[];
00088 //#endif
00089 
00090 /** \brief hostController declaration
00091 This global variable declaration with name host of class hostController is used by various different classes like OPT3101::deviceRegister , OPT3101::registers and OPT3101::device to specify specific instructions to the host like wait, sleep, I2C reads and writes
00092 */
00093 extern hostController host;
00094 typedef unsigned char uint8_t;
00095 typedef unsigned int uint32_t;
00096 typedef unsigned short uint16_t;
00097 /*! \class hostController
00098 \brief Generic implementation for host 
00099 
00100 As part of OPT3101SDK there are several host specific functions that need to be performed. Examples of such functions are writing or reading from I2C ports, sending reset pulse to OPT3101 device<br>
00101 These implementations are very specific to the host on which the SDK is ported and run. <br>
00102 This abstract class provides a template with self explanatory method names which the users can override and implement their own functions. <br>
00103 Example code is provided for OPT3101EVM with implementations for a windows 10 PC. 
00104 */
00105 class hostController {
00106     public:
00107         /*!
00108         * \brief constructor mostly used to initialize the host
00109         *
00110         * Method to mostly initialize host. Especially for MSP like hosts.
00111         * \return Nothing
00112         */
00113         hostController(void);
00114         /*!
00115         * \brief method to read data from I2C port
00116         *
00117         * \param[in] address; address is the I2C register address 
00118         * \return value; value read from I2C port for the address
00119         */
00120         uint32_t readI2C(uint8_t address);
00121         /*!
00122         * \brief method to write data from I2C port
00123         *
00124         * \param[in] address; address is the I2C register address
00125         * \param[in] data; data to write to I2C register 
00126         * \return Nothing
00127         */
00128         void writeI2C(uint8_t address, uint32_t data);
00129         /*!
00130         * \brief send reset pulse to OPT3101 device
00131         * Method used to send reset pulse to OPT3101 device
00132         * \return Nothing
00133         */
00134         void resetDevice();
00135         /*!
00136         * \brief sleep host 
00137         * Method used to sleep or make host wait for a particular amount of time specified in milliSeconds
00138         * \param[in] timeInMilliSeconds; Time for which the host needs to sleep specified in milliSeconds
00139         * \return Nothing
00140         */
00141         void sleep(uint32_t timeInMilliSeconds);
00142         /*!
00143         * \brief sleep host
00144         * Method used to sleep or make host wait for a particular amount of time specified in number of data ready pulses from OPT3101
00145         * \param[in] dataReadyCounts; Time for which the host needs to sleep specified data ready pulses from OPT3101
00146         * \return Nothing
00147         */
00148         void sleepDataReadyCounts(uint16_t dataReadyCounts);
00149         /*!
00150         * \brief pause host 
00151         * Method used to make host wait for user input or interrupt. Useful for debug
00152         * \return Nothing
00153         */
00154         void pause();
00155         /*!
00156         * \brief initialize host
00157         * Method to initialize host. Especially for MSP like hosts.
00158         * \return Nothing
00159         */
00160         void initialize();
00161         /*!
00162         * \brief print message
00163         * Method to print message on host to user
00164         * \return Nothing
00165         */
00166         void printf(const char *fmt, ...);
00167         /*!
00168         * \brief print Sets color for terminal
00169         * Method sets colors for terminals
00170         * \return Nothing
00171         */
00172         void printfSetColor(uint8_t color=0xFF);
00173 
00174 
00175 //#ifdef TIMSP430F5529_LAUNCHPAD_CALIBRATION_TOOL
00176         I2C::i2cHandler i2c;
00177 //      STORAGE::flashHandler flash;
00178 //      LAUNCHPAD::MSPConnections gpio;
00179 //#endif
00180 
00181 };
00182 
00183 
00184 #endif /* HOSTCONTROLLER_H_ */
00185