Now you can use NC as InterruptIn
Fork of X_NUCLEO_6180XA1 by
Components/VL6180X/vl6180x_platform.h@8:f943a1fca15f, 2015-09-29 (annotated)
- Committer:
- licio.mapelli@st.com
- Date:
- Tue Sep 29 14:50:15 2015 +0200
- Revision:
- 8:f943a1fca15f
- Parent:
- 1:1de1ea2994d9
- Child:
- 10:4954b09b72d8
fixed i2c functions and code cleanup
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gallonm | 1:1de1ea2994d9 | 1 | /******************************************************************************* |
gallonm | 1:1de1ea2994d9 | 2 | Copyright © 2014, STMicroelectronics International N.V. |
gallonm | 1:1de1ea2994d9 | 3 | All rights reserved. |
gallonm | 1:1de1ea2994d9 | 4 | |
gallonm | 1:1de1ea2994d9 | 5 | Redistribution and use in source and binary forms, with or without |
gallonm | 1:1de1ea2994d9 | 6 | modification, are permitted provided that the following conditions are met: |
gallonm | 1:1de1ea2994d9 | 7 | * Redistributions of source code must retain the above copyright |
gallonm | 1:1de1ea2994d9 | 8 | notice, this list of conditions and the following disclaimer. |
gallonm | 1:1de1ea2994d9 | 9 | * Redistributions in binary form must reproduce the above copyright |
gallonm | 1:1de1ea2994d9 | 10 | notice, this list of conditions and the following disclaimer in the |
gallonm | 1:1de1ea2994d9 | 11 | documentation and/or other materials provided with the distribution. |
gallonm | 1:1de1ea2994d9 | 12 | * Neither the name of STMicroelectronics nor the |
gallonm | 1:1de1ea2994d9 | 13 | names of its contributors may be used to endorse or promote products |
gallonm | 1:1de1ea2994d9 | 14 | derived from this software without specific prior written permission. |
gallonm | 1:1de1ea2994d9 | 15 | |
gallonm | 1:1de1ea2994d9 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
gallonm | 1:1de1ea2994d9 | 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
gallonm | 1:1de1ea2994d9 | 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND |
gallonm | 1:1de1ea2994d9 | 19 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. |
gallonm | 1:1de1ea2994d9 | 20 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY |
gallonm | 1:1de1ea2994d9 | 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
gallonm | 1:1de1ea2994d9 | 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
gallonm | 1:1de1ea2994d9 | 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
gallonm | 1:1de1ea2994d9 | 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
gallonm | 1:1de1ea2994d9 | 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
gallonm | 1:1de1ea2994d9 | 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
gallonm | 1:1de1ea2994d9 | 27 | ********************************************************************************/ |
gallonm | 1:1de1ea2994d9 | 28 | |
gallonm | 1:1de1ea2994d9 | 29 | |
gallonm | 1:1de1ea2994d9 | 30 | |
gallonm | 1:1de1ea2994d9 | 31 | /* vl6180x_platform.h STM32 Nucelo F401 single device using generic cci-i2c |
gallonm | 1:1de1ea2994d9 | 32 | * trace via swo port some GnuArm eclipse toolset */ |
gallonm | 1:1de1ea2994d9 | 33 | |
gallonm | 1:1de1ea2994d9 | 34 | #ifndef VL6180x_PLATFORM |
gallonm | 1:1de1ea2994d9 | 35 | #define VL6180x_PLATFORM |
gallonm | 1:1de1ea2994d9 | 36 | |
gallonm | 1:1de1ea2994d9 | 37 | #include "vl6180x_def.h" |
gallonm | 1:1de1ea2994d9 | 38 | |
gallonm | 1:1de1ea2994d9 | 39 | |
gallonm | 1:1de1ea2994d9 | 40 | |
gallonm | 1:1de1ea2994d9 | 41 | #define VL6180x_DEV_DATA_ATTR |
gallonm | 1:1de1ea2994d9 | 42 | |
gallonm | 1:1de1ea2994d9 | 43 | #define ROMABLE_DATA |
gallonm | 1:1de1ea2994d9 | 44 | /* #define ROMABLE_DATA __attribute__ ((section ("user_rom"))) */ |
gallonm | 1:1de1ea2994d9 | 45 | |
gallonm | 1:1de1ea2994d9 | 46 | |
gallonm | 1:1de1ea2994d9 | 47 | |
gallonm | 1:1de1ea2994d9 | 48 | #if VL6180X_LOG_ENABLE |
gallonm | 1:1de1ea2994d9 | 49 | /* dot not include non ansi here trace was a case :( */ |
gallonm | 1:1de1ea2994d9 | 50 | #ifdef TRACE |
gallonm | 1:1de1ea2994d9 | 51 | #include "diag/trace.h" |
gallonm | 1:1de1ea2994d9 | 52 | extern volatile uint32_t g_TickCnt; |
gallonm | 1:1de1ea2994d9 | 53 | #define LOG_GET_TIME() g_TickCnt |
gallonm | 1:1de1ea2994d9 | 54 | #else |
gallonm | 1:1de1ea2994d9 | 55 | /* these is nto stm32 vl6180x GNuArm eclpse build*/ |
gallonm | 1:1de1ea2994d9 | 56 | #define trace_printf(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 57 | #define LOG_GET_TIME() (int)0 /* add your code here expect to be an integer native (%d) type value */ |
gallonm | 1:1de1ea2994d9 | 58 | #endif |
gallonm | 1:1de1ea2994d9 | 59 | |
gallonm | 1:1de1ea2994d9 | 60 | |
gallonm | 1:1de1ea2994d9 | 61 | |
gallonm | 1:1de1ea2994d9 | 62 | #define LOG_FUNCTION_START(fmt, ... ) \ |
gallonm | 1:1de1ea2994d9 | 63 | trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__) |
gallonm | 1:1de1ea2994d9 | 64 | |
gallonm | 1:1de1ea2994d9 | 65 | #define LOG_FUNCTION_END(status)\ |
gallonm | 1:1de1ea2994d9 | 66 | trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status) |
gallonm | 1:1de1ea2994d9 | 67 | |
gallonm | 1:1de1ea2994d9 | 68 | #define LOG_FUNCTION_END_FMT(status, fmt, ... )\ |
gallonm | 1:1de1ea2994d9 | 69 | trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__) |
gallonm | 1:1de1ea2994d9 | 70 | |
gallonm | 1:1de1ea2994d9 | 71 | #define VL6180x_ErrLog(msg, ... )\ |
gallonm | 1:1de1ea2994d9 | 72 | do{\ |
gallonm | 1:1de1ea2994d9 | 73 | trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\ |
gallonm | 1:1de1ea2994d9 | 74 | }while(0) |
gallonm | 1:1de1ea2994d9 | 75 | |
gallonm | 1:1de1ea2994d9 | 76 | #else /* VL6180X_LOG_ENABLE no logging */ |
gallonm | 1:1de1ea2994d9 | 77 | void OnErrLog(void); |
gallonm | 1:1de1ea2994d9 | 78 | #define LOG_FUNCTION_START(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 79 | #define LOG_FUNCTION_END(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 80 | #define LOG_FUNCTION_END_FMT(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 81 | #define VL6180x_ErrLog(... ) OnErrLog() |
gallonm | 1:1de1ea2994d9 | 82 | #endif |
gallonm | 1:1de1ea2994d9 | 83 | |
gallonm | 1:1de1ea2994d9 | 84 | |
licio.mapelli@st.com | 8:f943a1fca15f | 85 | typedef struct MyVL6180Dev_t { |
licio.mapelli@st.com | 8:f943a1fca15f | 86 | struct VL6180xDevData_t Data; |
licio.mapelli@st.com | 8:f943a1fca15f | 87 | uint8_t I2cAddr; |
licio.mapelli@st.com | 8:f943a1fca15f | 88 | uint8_t DevID; |
licio.mapelli@st.com | 8:f943a1fca15f | 89 | |
licio.mapelli@st.com | 8:f943a1fca15f | 90 | // misc flags for application |
licio.mapelli@st.com | 8:f943a1fca15f | 91 | unsigned Present:1; |
licio.mapelli@st.com | 8:f943a1fca15f | 92 | unsigned Ready:1; |
licio.mapelli@st.com | 8:f943a1fca15f | 93 | }VL6180xDev_t; |
gallonm | 1:1de1ea2994d9 | 94 | |
gallonm | 1:1de1ea2994d9 | 95 | |
licio.mapelli@st.com | 8:f943a1fca15f | 96 | #define VL6180xDevDataGet(dev, field) (dev.Data.field) |
licio.mapelli@st.com | 8:f943a1fca15f | 97 | #define VL6180xDevDataSet(dev, field, data) (dev.Data.field)=(data) |
gallonm | 1:1de1ea2994d9 | 98 | |
licio.mapelli@st.com | 8:f943a1fca15f | 99 | //#endif /* #else VL6180x_SINGLE_DEVICE_DRIVER */ |
gallonm | 1:1de1ea2994d9 | 100 | |
gallonm | 1:1de1ea2994d9 | 101 | void VL6180x_PollDelay(VL6180xDev_t dev); |
gallonm | 1:1de1ea2994d9 | 102 | |
gallonm | 1:1de1ea2994d9 | 103 | void DISP_ExecLoopBody(void); |
gallonm | 1:1de1ea2994d9 | 104 | #define VL6180x_PollDelay(dev) DISP_ExecLoopBody(); |
gallonm | 1:1de1ea2994d9 | 105 | |
gallonm | 1:1de1ea2994d9 | 106 | |
gallonm | 1:1de1ea2994d9 | 107 | #endif /* VL6180x_PLATFORM */ |
gallonm | 1:1de1ea2994d9 | 108 | |
gallonm | 1:1de1ea2994d9 | 109 | |
gallonm | 1:1de1ea2994d9 | 110 |