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