Librairie adaptée au laboratoire 2

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

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 
00057 #define LOG_FUNCTION_START(fmt, ... ) \
00058     trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__)
00059 
00060 #define LOG_FUNCTION_END(status)\
00061     trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status)
00062 
00063 #define LOG_FUNCTION_END_FMT(status, fmt, ... )\
00064     trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
00065 
00066 #define VL6180X_ErrLog(msg, ... )\
00067     do {\
00068         trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\
00069     } while(0)
00070 
00071 #else /* VL6180X_LOG_ENABLE no logging */
00072   //void OnErrLog(void);
00073   #define LOG_FUNCTION_START(...) (void)0
00074   #define LOG_FUNCTION_END(...) (void)0
00075   #define LOG_FUNCTION_END_FMT(...) (void)0
00076   #define VL6180X_ErrLog(... ) //OnErrLog() //(void)0
00077 #endif
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 #if  VL6180X_SINGLE_DEVICE_DRIVER
00085     #error "VL6180X_SINGLE_DEVICE_DRIVER must be set"
00086 #endif
00087         
00088 struct MyVL6180Dev_t {
00089     struct VL6180XDevData_t Data;
00090     uint8_t I2cAddr;
00091     //uint8_t DevID;
00092     
00093     //misc flags for application    
00094     unsigned Present:1;
00095     unsigned Ready:1;
00096 };
00097 typedef struct MyVL6180Dev_t *VL6180XDev_t;
00098 
00099 #define VL6180XDevDataGet(dev, field) (dev->Data.field)
00100 #define VL6180XDevDataSet(dev, field, data) (dev->Data.field)=(data)
00101 
00102 #endif  /* VL6180X_PLATFORM */