Now you can use NC as InterruptIn
Fork of X_NUCLEO_6180XA1 by
Components/VL6180X/vl6180x_platform.h@1:1de1ea2994d9, 2015-09-09 (annotated)
- Committer:
- gallonm
- Date:
- Wed Sep 09 16:00:39 2015 +0000
- Revision:
- 1:1de1ea2994d9
- Child:
- 8:f943a1fca15f
Added some files
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 | |
gallonm | 1:1de1ea2994d9 | 38 | #include "vl6180x_appcfg.h" |
gallonm | 1:1de1ea2994d9 | 39 | #include "vl6180x_def.h" |
gallonm | 1:1de1ea2994d9 | 40 | |
gallonm | 1:1de1ea2994d9 | 41 | |
gallonm | 1:1de1ea2994d9 | 42 | |
gallonm | 1:1de1ea2994d9 | 43 | #define VL6180x_DEV_DATA_ATTR |
gallonm | 1:1de1ea2994d9 | 44 | |
gallonm | 1:1de1ea2994d9 | 45 | #define ROMABLE_DATA |
gallonm | 1:1de1ea2994d9 | 46 | /* #define ROMABLE_DATA __attribute__ ((section ("user_rom"))) */ |
gallonm | 1:1de1ea2994d9 | 47 | |
gallonm | 1:1de1ea2994d9 | 48 | |
gallonm | 1:1de1ea2994d9 | 49 | |
gallonm | 1:1de1ea2994d9 | 50 | #if VL6180X_LOG_ENABLE |
gallonm | 1:1de1ea2994d9 | 51 | /* dot not include non ansi here trace was a case :( */ |
gallonm | 1:1de1ea2994d9 | 52 | #ifdef TRACE |
gallonm | 1:1de1ea2994d9 | 53 | #include "diag/trace.h" |
gallonm | 1:1de1ea2994d9 | 54 | extern volatile uint32_t g_TickCnt; |
gallonm | 1:1de1ea2994d9 | 55 | #define LOG_GET_TIME() g_TickCnt |
gallonm | 1:1de1ea2994d9 | 56 | #else |
gallonm | 1:1de1ea2994d9 | 57 | /* these is nto stm32 vl6180x GNuArm eclpse build*/ |
gallonm | 1:1de1ea2994d9 | 58 | #define trace_printf(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 59 | #define LOG_GET_TIME() (int)0 /* add your code here expect to be an integer native (%d) type value */ |
gallonm | 1:1de1ea2994d9 | 60 | #endif |
gallonm | 1:1de1ea2994d9 | 61 | |
gallonm | 1:1de1ea2994d9 | 62 | |
gallonm | 1:1de1ea2994d9 | 63 | |
gallonm | 1:1de1ea2994d9 | 64 | #define LOG_FUNCTION_START(fmt, ... ) \ |
gallonm | 1:1de1ea2994d9 | 65 | trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__) |
gallonm | 1:1de1ea2994d9 | 66 | |
gallonm | 1:1de1ea2994d9 | 67 | #define LOG_FUNCTION_END(status)\ |
gallonm | 1:1de1ea2994d9 | 68 | trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status) |
gallonm | 1:1de1ea2994d9 | 69 | |
gallonm | 1:1de1ea2994d9 | 70 | #define LOG_FUNCTION_END_FMT(status, fmt, ... )\ |
gallonm | 1:1de1ea2994d9 | 71 | trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__) |
gallonm | 1:1de1ea2994d9 | 72 | |
gallonm | 1:1de1ea2994d9 | 73 | #define VL6180x_ErrLog(msg, ... )\ |
gallonm | 1:1de1ea2994d9 | 74 | do{\ |
gallonm | 1:1de1ea2994d9 | 75 | trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\ |
gallonm | 1:1de1ea2994d9 | 76 | }while(0) |
gallonm | 1:1de1ea2994d9 | 77 | |
gallonm | 1:1de1ea2994d9 | 78 | #else /* VL6180X_LOG_ENABLE no logging */ |
gallonm | 1:1de1ea2994d9 | 79 | void OnErrLog(void); |
gallonm | 1:1de1ea2994d9 | 80 | #define LOG_FUNCTION_START(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 81 | #define LOG_FUNCTION_END(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 82 | #define LOG_FUNCTION_END_FMT(...) (void)0 |
gallonm | 1:1de1ea2994d9 | 83 | #define VL6180x_ErrLog(... ) OnErrLog() |
gallonm | 1:1de1ea2994d9 | 84 | #endif |
gallonm | 1:1de1ea2994d9 | 85 | |
gallonm | 1:1de1ea2994d9 | 86 | |
gallonm | 1:1de1ea2994d9 | 87 | #if VL6180x_SINGLE_DEVICE_DRIVER |
gallonm | 1:1de1ea2994d9 | 88 | typedef uint8_t VL6180xDev_t; |
gallonm | 1:1de1ea2994d9 | 89 | |
gallonm | 1:1de1ea2994d9 | 90 | #else /* VL6180x_SINGLE_DEVICE_DRIVER */ |
gallonm | 1:1de1ea2994d9 | 91 | |
gallonm | 1:1de1ea2994d9 | 92 | struct MyVL6180Dev_t { |
gallonm | 1:1de1ea2994d9 | 93 | struct VL6180xDevData_t Data; |
gallonm | 1:1de1ea2994d9 | 94 | #if I2C_BUFFER_CONFIG == 2 |
gallonm | 1:1de1ea2994d9 | 95 | uint8_t i2c_buffer[VL6180x_MAX_I2C_XFER_SIZE]; |
gallonm | 1:1de1ea2994d9 | 96 | #define VL6180x_GetI2cBuffer(dev, n) ((dev)->i2c_buffer) |
gallonm | 1:1de1ea2994d9 | 97 | #endif |
gallonm | 1:1de1ea2994d9 | 98 | }; |
gallonm | 1:1de1ea2994d9 | 99 | typedef struct MyVL6180Dev_t *VL6180xDev_t; |
gallonm | 1:1de1ea2994d9 | 100 | |
gallonm | 1:1de1ea2994d9 | 101 | #define VL6180xDevDataGet(dev, field) (dev->Data.field) |
gallonm | 1:1de1ea2994d9 | 102 | #define VL6180xDevDataSet(dev, field, data) (dev->Data.field)=(data) |
gallonm | 1:1de1ea2994d9 | 103 | |
gallonm | 1:1de1ea2994d9 | 104 | #endif /* #else VL6180x_SINGLE_DEVICE_DRIVER */ |
gallonm | 1:1de1ea2994d9 | 105 | |
gallonm | 1:1de1ea2994d9 | 106 | void VL6180x_PollDelay(VL6180xDev_t dev); |
gallonm | 1:1de1ea2994d9 | 107 | |
gallonm | 1:1de1ea2994d9 | 108 | void DISP_ExecLoopBody(void); |
gallonm | 1:1de1ea2994d9 | 109 | #define VL6180x_PollDelay(dev) DISP_ExecLoopBody(); |
gallonm | 1:1de1ea2994d9 | 110 | |
gallonm | 1:1de1ea2994d9 | 111 | |
gallonm | 1:1de1ea2994d9 | 112 | #endif /* VL6180x_PLATFORM */ |
gallonm | 1:1de1ea2994d9 | 113 | |
gallonm | 1:1de1ea2994d9 | 114 | |
gallonm | 1:1de1ea2994d9 | 115 |