vl6180x_platform.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*******************************************************************************
  2. Copyright ?2014, STMicroelectronics International N.V.
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of STMicroelectronics nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
  17. NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
  18. IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
  19. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. ********************************************************************************/
  26. #ifndef VL6180x_PLATFORM_H
  27. #define VL6180x_PLATFORM_H
  28. #include "vl6180x_appcfg.h"
  29. #include "vl6180x_def.h"
  30. #define VL6180x_DEV_DATA_ATTR
  31. #define ROMABLE_DATA
  32. /* #define ROMABLE_DATA __attribute__ ((section ("user_rom"))) */
  33. #if VL6180X_LOG_ENABLE
  34. #include <linux/module.h>
  35. #define LOG_GET_TIME() (int)0 /* add your code here expect to be an integer native (%d) type value */
  36. #define LOG_FUNCTION_START(fmt, ... ) \
  37. printk("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__)
  38. #define LOG_FUNCTION_END(status)\
  39. printk("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status)
  40. #define LOG_FUNCTION_END_FMT(status, fmt, ... )\
  41. printk("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
  42. #define VL6180x_ErrLog(msg, ... )\
  43. do{\
  44. printk("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\
  45. }while(0)
  46. #else /* VL6180X_LOG_ENABLE no logging */
  47. #define LOG_FUNCTION_START(...) (void)0
  48. #define LOG_FUNCTION_END(...) (void)0
  49. #define LOG_FUNCTION_END_FMT(...) (void)0
  50. #define VL6180x_ErrLog(... ) (void)0
  51. #endif
  52. #if VL6180x_SINGLE_DEVICE_DRIVER
  53. typedef uint8_t VL6180xDev_t;
  54. typedef VL6180xDev_t stmvl6180x_dev;
  55. #else /* VL6180x_SINGLE_DEVICE_DRIVER */
  56. struct MyVL6180Dev_t {
  57. struct VL6180xDevData_t Data;
  58. #if I2C_BUFFER_CONFIG == 2
  59. uint8_t i2c_buffer[VL6180x_MAX_I2C_XFER_SIZE];
  60. #define VL6180x_GetI2cBuffer(dev, n) ((dev)->i2c_buffer)
  61. #endif
  62. uint32_t I2cAddress;
  63. };
  64. typedef struct MyVL6180Dev_t *VL6180xDev_t;
  65. typedef struct MyVL6180Dev_t stmvl6180x_dev;
  66. #define VL6180xDevDataGet(dev, field) (dev->Data.field)
  67. #define VL6180xDevDataSet(dev, field, data) (dev->Data.field)=(data)
  68. #endif /* #else VL6180x_SINGLE_DEVICE_DRIVER */
  69. void VL6180x_PollDelay(VL6180xDev_t dev);
  70. void DISP_ExecLoopBody(void);
  71. #define VL6180x_PollDelay(dev) (void)0
  72. #endif /* VL6180x_PLATFORM_H */