jj
Dependencies: VL6180x X_NUCLEO_COMMON X_NUCLEO_IHM01A1 mbed
Fork of 1-DoorCloser by
VL6180X/vl6180x_platform.h@0:1cb50d31c3b5, 2016-03-25 (annotated)
- Committer:
- julientiron
- Date:
- Fri Mar 25 21:27:03 2016 +0000
- Revision:
- 0:1cb50d31c3b5
Code petit robot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
julientiron | 0:1cb50d31c3b5 | 1 | /******************************************************************************* |
julientiron | 0:1cb50d31c3b5 | 2 | ################################################################################ |
julientiron | 0:1cb50d31c3b5 | 3 | # |
julientiron | 0:1cb50d31c3b5 | 4 | # This program is free software; you can redistribute it and/or modify it under |
julientiron | 0:1cb50d31c3b5 | 5 | # the terms of the GNU General Public License version 2 and only version 2 as |
julientiron | 0:1cb50d31c3b5 | 6 | # published by the Free Software Foundation. |
julientiron | 0:1cb50d31c3b5 | 7 | # |
julientiron | 0:1cb50d31c3b5 | 8 | # This program is distributed in the hope that it will be useful, but WITHOUT |
julientiron | 0:1cb50d31c3b5 | 9 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
julientiron | 0:1cb50d31c3b5 | 10 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
julientiron | 0:1cb50d31c3b5 | 11 | # details. |
julientiron | 0:1cb50d31c3b5 | 12 | # |
julientiron | 0:1cb50d31c3b5 | 13 | # You should have received a copy of the GNU General Public License along with |
julientiron | 0:1cb50d31c3b5 | 14 | # this program; if not, write to the Free Software Foundation, Inc., |
julientiron | 0:1cb50d31c3b5 | 15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
julientiron | 0:1cb50d31c3b5 | 16 | # |
julientiron | 0:1cb50d31c3b5 | 17 | #------------------------------------------------------------------------------ |
julientiron | 0:1cb50d31c3b5 | 18 | # Imaging Division |
julientiron | 0:1cb50d31c3b5 | 19 | ################################################################################ |
julientiron | 0:1cb50d31c3b5 | 20 | ********************************************************************************/ |
julientiron | 0:1cb50d31c3b5 | 21 | |
julientiron | 0:1cb50d31c3b5 | 22 | |
julientiron | 0:1cb50d31c3b5 | 23 | /* vl6180x_platform.h STM32 Nucleo F401 single device sample code project */ |
julientiron | 0:1cb50d31c3b5 | 24 | |
julientiron | 0:1cb50d31c3b5 | 25 | #ifndef VL6180x_PLATFORM |
julientiron | 0:1cb50d31c3b5 | 26 | #define VL6180x_PLATFORM |
julientiron | 0:1cb50d31c3b5 | 27 | |
julientiron | 0:1cb50d31c3b5 | 28 | |
julientiron | 0:1cb50d31c3b5 | 29 | #include "vl6180x_def.h" |
julientiron | 0:1cb50d31c3b5 | 30 | |
julientiron | 0:1cb50d31c3b5 | 31 | |
julientiron | 0:1cb50d31c3b5 | 32 | #define VL6180x_SINGLE_DEVICE_DRIVER 0 |
julientiron | 0:1cb50d31c3b5 | 33 | #define VL6180x_RANGE_STATUS_ERRSTRING 1 |
julientiron | 0:1cb50d31c3b5 | 34 | #define VL6180X_SAFE_POLLING_ENTER 0 |
julientiron | 0:1cb50d31c3b5 | 35 | #define VL6180X_LOG_ENABLE 0 |
julientiron | 0:1cb50d31c3b5 | 36 | #define MY_LOG 1 |
julientiron | 0:1cb50d31c3b5 | 37 | |
julientiron | 0:1cb50d31c3b5 | 38 | #define VL6180x_DEV_DATA_ATTR |
julientiron | 0:1cb50d31c3b5 | 39 | #define ROMABLE_DATA |
julientiron | 0:1cb50d31c3b5 | 40 | |
julientiron | 0:1cb50d31c3b5 | 41 | |
julientiron | 0:1cb50d31c3b5 | 42 | #if VL6180X_LOG_ENABLE |
julientiron | 0:1cb50d31c3b5 | 43 | /* dot not include non ansi here trace was a case :( */ |
julientiron | 0:1cb50d31c3b5 | 44 | #ifdef TRACE |
julientiron | 0:1cb50d31c3b5 | 45 | #include "diag/trace.h" |
julientiron | 0:1cb50d31c3b5 | 46 | extern volatile uint32_t g_TickCnt; |
julientiron | 0:1cb50d31c3b5 | 47 | #define LOG_GET_TIME() g_TickCnt |
julientiron | 0:1cb50d31c3b5 | 48 | //#define LOG_GET_TIME() HAL_GetTick() |
julientiron | 0:1cb50d31c3b5 | 49 | #else |
julientiron | 0:1cb50d31c3b5 | 50 | /* these is nto stm32 vl6180x GNuArm eclpse build*/ |
julientiron | 0:1cb50d31c3b5 | 51 | #define trace_printf(...) (void)0 |
julientiron | 0:1cb50d31c3b5 | 52 | #define LOG_GET_TIME() (int)0 /* add your code here expect to be an integer native (%d) type value */ |
julientiron | 0:1cb50d31c3b5 | 53 | #endif |
julientiron | 0:1cb50d31c3b5 | 54 | |
julientiron | 0:1cb50d31c3b5 | 55 | |
julientiron | 0:1cb50d31c3b5 | 56 | |
julientiron | 0:1cb50d31c3b5 | 57 | #define LOG_FUNCTION_START(fmt, ... ) \ |
julientiron | 0:1cb50d31c3b5 | 58 | trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__) |
julientiron | 0:1cb50d31c3b5 | 59 | |
julientiron | 0:1cb50d31c3b5 | 60 | #define LOG_FUNCTION_END(status)\ |
julientiron | 0:1cb50d31c3b5 | 61 | trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status) |
julientiron | 0:1cb50d31c3b5 | 62 | |
julientiron | 0:1cb50d31c3b5 | 63 | #define LOG_FUNCTION_END_FMT(status, fmt, ... )\ |
julientiron | 0:1cb50d31c3b5 | 64 | trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__) |
julientiron | 0:1cb50d31c3b5 | 65 | |
julientiron | 0:1cb50d31c3b5 | 66 | #define VL6180x_ErrLog(msg, ... )\ |
julientiron | 0:1cb50d31c3b5 | 67 | do{\ |
julientiron | 0:1cb50d31c3b5 | 68 | trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\ |
julientiron | 0:1cb50d31c3b5 | 69 | }while(0) |
julientiron | 0:1cb50d31c3b5 | 70 | |
julientiron | 0:1cb50d31c3b5 | 71 | #else /* VL6180X_LOG_ENABLE no logging */ |
julientiron | 0:1cb50d31c3b5 | 72 | //void OnErrLog(void); |
julientiron | 0:1cb50d31c3b5 | 73 | #define LOG_FUNCTION_START(...) (void)0 |
julientiron | 0:1cb50d31c3b5 | 74 | #define LOG_FUNCTION_END(...) (void)0 |
julientiron | 0:1cb50d31c3b5 | 75 | #define LOG_FUNCTION_END_FMT(...) (void)0 |
julientiron | 0:1cb50d31c3b5 | 76 | #define VL6180x_ErrLog(... ) //OnErrLog() //(void)0 |
julientiron | 0:1cb50d31c3b5 | 77 | #endif |
julientiron | 0:1cb50d31c3b5 | 78 | |
julientiron | 0:1cb50d31c3b5 | 79 | |
julientiron | 0:1cb50d31c3b5 | 80 | #ifdef MY_LOG /* define printf as pc.printf in order to change the baudrate */ |
julientiron | 0:1cb50d31c3b5 | 81 | extern Serial pc; |
julientiron | 0:1cb50d31c3b5 | 82 | #define printf(...) pc.printf(__VA_ARGS__) |
julientiron | 0:1cb50d31c3b5 | 83 | #endif |
julientiron | 0:1cb50d31c3b5 | 84 | |
julientiron | 0:1cb50d31c3b5 | 85 | |
julientiron | 0:1cb50d31c3b5 | 86 | #if VL6180x_SINGLE_DEVICE_DRIVER |
julientiron | 0:1cb50d31c3b5 | 87 | #error "VL6180x_SINGLE_DEVICE_DRIVER must be set" |
julientiron | 0:1cb50d31c3b5 | 88 | #endif |
julientiron | 0:1cb50d31c3b5 | 89 | |
julientiron | 0:1cb50d31c3b5 | 90 | struct MyVL6180Dev_t { |
julientiron | 0:1cb50d31c3b5 | 91 | struct VL6180xDevData_t Data; |
julientiron | 0:1cb50d31c3b5 | 92 | uint8_t I2cAddr; |
julientiron | 0:1cb50d31c3b5 | 93 | //uint8_t DevID; |
julientiron | 0:1cb50d31c3b5 | 94 | |
julientiron | 0:1cb50d31c3b5 | 95 | //misc flags for application |
julientiron | 0:1cb50d31c3b5 | 96 | unsigned Present:1; |
julientiron | 0:1cb50d31c3b5 | 97 | unsigned Ready:1; |
julientiron | 0:1cb50d31c3b5 | 98 | }; |
julientiron | 0:1cb50d31c3b5 | 99 | typedef struct MyVL6180Dev_t *VL6180xDev_t; |
julientiron | 0:1cb50d31c3b5 | 100 | |
julientiron | 0:1cb50d31c3b5 | 101 | #define VL6180xDevDataGet(dev, field) (dev->Data.field) |
julientiron | 0:1cb50d31c3b5 | 102 | #define VL6180xDevDataSet(dev, field, data) (dev->Data.field)=(data) |
julientiron | 0:1cb50d31c3b5 | 103 | |
julientiron | 0:1cb50d31c3b5 | 104 | |
julientiron | 0:1cb50d31c3b5 | 105 | #endif /* VL6180x_PLATFORM */ |
julientiron | 0:1cb50d31c3b5 | 106 | |
julientiron | 0:1cb50d31c3b5 | 107 | |
julientiron | 0:1cb50d31c3b5 | 108 |