vl6180x_platform.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*******************************************************************************
  2. ################################################################################
  3. #
  4. # This program is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU General Public License version 2 and only version 2 as
  6. # published by the Free Software Foundation.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  11. # details.
  12. #
  13. # You should have received a copy of the GNU General Public License along with
  14. # this program; if not, write to the Free Software Foundation, Inc.,
  15. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. #------------------------------------------------------------------------------
  18. # Imaging Division
  19. ################################################################################
  20. ********************************************************************************/
  21. /* vl6180x_platform.h STM32 Nucleo F401 single device sample code project */
  22. #ifndef VL6180x_PLATFORM
  23. #define VL6180x_PLATFORM
  24. #include "vl6180x_def.h"
  25. #define VL6180x_SINGLE_DEVICE_DRIVER 0
  26. #define VL6180x_RANGE_STATUS_ERRSTRING 1
  27. #define VL6180X_SAFE_POLLING_ENTER 0
  28. #define VL6180X_LOG_ENABLE 0
  29. #define VL6180x_DEV_DATA_ATTR
  30. #define ROMABLE_DATA
  31. #if VL6180X_LOG_ENABLE
  32. /* dot not include non ansi here trace was a case :( */
  33. #ifdef TRACE
  34. #include "diag/trace.h"
  35. #define LOG_GET_TIME() HAL_GetTick()
  36. #else
  37. /* these is nto stm32 vl6180x GNuArm eclpse build*/
  38. #define trace_printf(...) (void)0
  39. #define LOG_GET_TIME() (int)0 /* add your code here expect to be an integer native (%d) type value */
  40. #endif
  41. #define LOG_FUNCTION_START(fmt, ... ) \
  42. trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__)
  43. #define LOG_FUNCTION_END(status)\
  44. trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status)
  45. #define LOG_FUNCTION_END_FMT(status, fmt, ... )\
  46. trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
  47. #define VL6180x_ErrLog(msg, ... )\
  48. do{\
  49. trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\
  50. }while(0)
  51. #else /* VL6180X_LOG_ENABLE no logging */
  52. #define LOG_FUNCTION_START(...) (void)0
  53. #define LOG_FUNCTION_END(...) (void)0
  54. #define LOG_FUNCTION_END_FMT(...) (void)0
  55. #define VL6180x_ErrLog(... ) (void)0
  56. #endif
  57. #if VL6180x_SINGLE_DEVICE_DRIVER
  58. #error "VL6180x_SINGLE_DEVICE_DRIVER must be set"
  59. #endif
  60. struct MyVL6180Dev_t {
  61. struct VL6180xDevData_t Data;
  62. uint8_t I2cAddr;
  63. uint8_t DevID;
  64. // misc flags for application
  65. unsigned Present:1;
  66. unsigned Ready:1;
  67. };
  68. typedef struct MyVL6180Dev_t *VL6180xDev_t;
  69. #define VL6180xDevDataGet(dev, field) (dev->Data.field)
  70. #define VL6180xDevDataSet(dev, field, data) (dev->Data.field)=(data)
  71. void VL6180x_PollDelay(VL6180xDev_t dev);
  72. void DISP_ExecLoopBody(void);
  73. #define VL6180x_PollDelay(dev) DISP_ExecLoopBody();
  74. #endif /* VL6180x_PLATFORM */