Creating a project about VL6180XA1 for TT_Mxx

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers vl6180x_platform.h Source File

vl6180x_platform.h

00001 /*******************************************************************************
00002 ################################################################################
00003 #
00004 # This program is free software; you can redistribute it and/or modify it under
00005 # the terms of the GNU General Public License version 2 and only version 2 as
00006 # published by the Free Software Foundation.
00007 #
00008 # This program is distributed in the hope that it will be useful, but WITHOUT
00009 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00011 # details.
00012 #
00013 # You should have received a copy of the GNU General Public License along with
00014 # this program; if not, write to the Free Software Foundation, Inc.,
00015 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00016 #
00017 #------------------------------------------------------------------------------
00018 #                             Imaging Division
00019 ################################################################################
00020 ********************************************************************************/
00021 
00022 
00023 /* vl6180x_platform.h STM32 Nucleo F401 single device  sample code project */
00024 
00025 #ifndef VL6180x_PLATFORM
00026 #define VL6180x_PLATFORM
00027 
00028 
00029 #include "vl6180x_def.h"
00030 #include "mbed.h"
00031 #include <stdio.h>
00032 
00033 #define VL6180x_SINGLE_DEVICE_DRIVER    0
00034 #define VL6180x_RANGE_STATUS_ERRSTRING  1
00035 #define VL6180X_SAFE_POLLING_ENTER  0
00036 #define VL6180X_LOG_ENABLE              0
00037 #define MY_LOG                          1
00038 
00039 #define VL6180x_DEV_DATA_ATTR
00040 #define ROMABLE_DATA
00041 
00042 
00043 #if VL6180X_LOG_ENABLE
00044 /*  dot not include non ansi here trace was a case :( */
00045 #ifdef TRACE
00046 #include "diag/trace.h"
00047 extern volatile uint32_t g_TickCnt;
00048 #define LOG_GET_TIME()  g_TickCnt
00049 //#define LOG_GET_TIME()  HAL_GetTick()
00050 #else
00051 /* these is nto stm32 vl6180x GNuArm eclpse build*/
00052 #define trace_printf(...) (void)0
00053 #define LOG_GET_TIME() (int)0 /* add your code here expect to be an integer native (%d) type  value  */
00054 #endif
00055 
00056 
00057 
00058 #define LOG_FUNCTION_START(fmt, ... ) \
00059     trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__)
00060 
00061 #define LOG_FUNCTION_END(status)\
00062         trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status)
00063 
00064 #define LOG_FUNCTION_END_FMT(status, fmt, ... )\
00065         trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
00066 
00067 #define VL6180x_ErrLog(msg, ... )\
00068     do{\
00069         trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\
00070     }while(0)
00071 
00072 #else /* VL6180X_LOG_ENABLE no logging */
00073   //void OnErrLog(void);
00074   #define LOG_FUNCTION_START(...) (void)0
00075   #define LOG_FUNCTION_END(...) (void)0
00076   #define LOG_FUNCTION_END_FMT(...) (void)0
00077   #define VL6180x_ErrLog(... ) printf(__VA_ARGS__) //(void)0//OnErrLog() (void)0 
00078 #endif
00079 
00080   
00081 //#ifdef MY_LOG  /* define printf as pc.printf in order to change the baudrate */
00082 //  extern Serial pc;
00083 //  #define printf(...) pc.printf(__VA_ARGS__)
00084 //#endif
00085 
00086 
00087 #if  VL6180x_SINGLE_DEVICE_DRIVER
00088     #error "VL6180x_SINGLE_DEVICE_DRIVER must be set"
00089 #endif
00090         
00091 struct MyVL6180Dev_t {
00092     struct VL6180xDevData_t Data;
00093     uint8_t I2cAddr;
00094     //uint8_t DevID;
00095     
00096     //misc flags for application    
00097     unsigned Present:1;
00098     unsigned Ready:1;
00099 };
00100 typedef struct MyVL6180Dev_t *VL6180xDev_t;
00101 
00102 #define VL6180xDevDataGet(dev, field) (dev->Data.field)
00103 #define VL6180xDevDataSet(dev, field, data) (dev->Data.field)=(data)
00104 
00105 
00106 #endif  /* VL6180x_PLATFORM */
00107 
00108 
00109 
00110