Line Health / VL6180
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  
00031  
00032 #define VL6180x_SINGLE_DEVICE_DRIVER    0
00033 #define VL6180x_RANGE_STATUS_ERRSTRING  1
00034 #define VL6180X_SAFE_POLLING_ENTER  0
00035 #define VL6180X_LOG_ENABLE              0
00036 //#define MY_LOG                          1
00037  
00038 #define VL6180x_DEV_DATA_ATTR
00039 #define ROMABLE_DATA
00040  
00041  
00042 #if VL6180X_LOG_ENABLE
00043 /*  dot not include non ansi here trace was a case :( */
00044 #ifdef TRACE
00045 #include "diag/trace.h"
00046 extern volatile uint32_t g_TickCnt;
00047 #define LOG_GET_TIME()  g_TickCnt
00048 //#define LOG_GET_TIME()  HAL_GetTick()
00049 #else
00050 /* these is nto stm32 vl6180x GNuArm eclpse build*/
00051 #define trace_printf(...) (void)0
00052 #define LOG_GET_TIME() (int)0 /* add your code here expect to be an integer native (%d) type  value  */
00053 #endif
00054 
00055  
00056 #define LOG_FUNCTION_START(fmt, ... ) \
00057     trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__)
00058  
00059 #define LOG_FUNCTION_END(status)\
00060         trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status)
00061  
00062 #define LOG_FUNCTION_END_FMT(status, fmt, ... )\
00063         trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
00064  
00065 #define VL6180x_ErrLog(msg, ... )\
00066     do{\
00067         trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\
00068     }while(0)
00069  
00070 #else /* VL6180X_LOG_ENABLE no logging */
00071   //void OnErrLog(void);
00072   #define LOG_FUNCTION_START(...) (void)0
00073   #define LOG_FUNCTION_END(...) (void)0
00074   #define LOG_FUNCTION_END_FMT(...) (void)0
00075   #define VL6180x_ErrLog(... ) //OnErrLog() //(void)0
00076 #endif
00077  
00078   
00079 #ifdef MY_LOG  /* define printf as pc.printf in order to change the baudrate */
00080   extern Serial pc;
00081   #define printf(...) pc.printf(__VA_ARGS__)
00082 #endif
00083  
00084  
00085 #if  VL6180x_SINGLE_DEVICE_DRIVER
00086     #error "VL6180x_SINGLE_DEVICE_DRIVER must be set"
00087 #endif
00088         
00089 struct MyVL6180Dev_t {
00090     struct VL6180xDevData_t Data;
00091     uint8_t I2cAddr;
00092     uint8_t muxCh;
00093     //uint8_t DevID;
00094     
00095     //misc flags for application    
00096     unsigned Present:1;
00097     unsigned Ready:1;
00098 };
00099 typedef struct MyVL6180Dev_t *VL6180xDev_t;
00100  
00101 #define VL6180xDevDataGet(dev, field) (dev->Data.field)
00102 #define VL6180xDevDataSet(dev, field, data) (dev->Data.field)=(data)
00103  
00104  
00105 #endif  /* VL6180x_PLATFORM */
00106  
00107