Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

97 lines
2.9 KiB

  1. /*!
  2. * \file mma8451.h
  3. *
  4. * \brief MMA8451 Accelerometer driver implementation
  5. *
  6. * \copyright Revised BSD License, see section \ref LICENSE.
  7. *
  8. * \code
  9. * ______ _
  10. * / _____) _ | |
  11. * ( (____ _____ ____ _| |_ _____ ____| |__
  12. * \____ \| ___ | (_ _) ___ |/ ___) _ \
  13. * _____) ) ____| | | || |_| ____( (___| | | |
  14. * (______/|_____)_|_|_| \__)_____)\____)_| |_|
  15. * (C)2013-2017 Semtech
  16. *
  17. * \endcode
  18. *
  19. * \author Miguel Luis ( Semtech )
  20. *
  21. * \author Gregory Cristian ( Semtech )
  22. */
  23. #ifndef __MMA8451_H__
  24. #define __MMA8451_H__
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. #include <stdint.h>
  30. #include "utilities.h"
  31. /*
  32. * MMA8451 I2C address
  33. */
  34. #define MMA8451_I2C_ADDRESS 0x1C
  35. /*
  36. * MMA8451 Registers
  37. */
  38. #define MMA8451_STATUS 0x00 //
  39. #define MMA8451_OUT_X_MSB 0x01 //
  40. #define MMA8451_SYSMOD 0x0B //
  41. #define MMA8451_INT_SOURCE 0x0C //
  42. #define MMA8451_ID 0x0D //
  43. #define MMA8451_PL_STATUS 0x10 //
  44. #define MMA8451_PL_CFG 0x11 //
  45. #define MMA8451_PL_COUNT 0x12 // Orientation debounce
  46. #define MMA8451_PL_BF_ZCOMP 0x13 //
  47. #define MMA8451_PL_THS_REG 0x14 //
  48. #define MMA8451_FF_MT_SRC 0x16 //
  49. #define MMA8451_TRANSIENT_CFG 0x1D // Transient enable
  50. #define MMA8451_TRANSIENT_SRC 0x1E // Transient read/clear interrupt
  51. #define MMA8451_TRANSIENT_THS 0x1F // Transient threshold
  52. #define MMA8451_TRANSIENT_COUNT 0x20 // Transient debounce
  53. #define MMA8451_PULSE_SRC 0x22 //
  54. #define MMA8451_CTRL_REG1 0x2A //
  55. #define MMA8451_CTRL_REG2 0x2B //
  56. #define MMA8451_CTRL_REG3 0x2C // Interrupt control
  57. #define MMA8451_CTRL_REG4 0x2D // Interrupt enable
  58. #define MMA8451_CTRL_REG5 0x2E // Interrupt pin selection
  59. /*!
  60. * \brief Initializes the device
  61. *
  62. * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
  63. */
  64. LmnStatus_t MMA8451Init( void );
  65. /*!
  66. * \brief Resets the device
  67. *
  68. * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
  69. */
  70. LmnStatus_t MMA8451Reset( void );
  71. /*!
  72. * \brief Initializes the orientation detection
  73. */
  74. void MMA8451OrientDetect( void );
  75. /*!
  76. * \brief Gets the orientation state.
  77. *
  78. * \retval orientation Bit 6 [1: Horizontal, 0: Vertical]
  79. * Bit 0 [1: Face down, 0: Face up]
  80. * Other bits don't care.
  81. */
  82. uint8_t MMA8451GetOrientation( void );
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif // __MMA8451_H__