LSM303C_MAG_driver.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
  2. * File Name : LSM303C_MAG_driver.h
  3. * Author : MEMS Application Team
  4. * Version : v1.1
  5. * Date : 22 Nov 2016
  6. * Description : LSM303C header driver file
  7. *
  8. ********************************************************************************
  9. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  10. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  11. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  12. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  13. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  14. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  15. *
  16. * THIS SOFTWARE IS SPECIFICALLY DESIGNED FOR EXCLUSIVE USE WITH ST PARTS.
  17. *******************************************************************************/
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __LSM303C_MAG_DRIVER__H
  20. #define __LSM303C_MAG_DRIVER__H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. /* Exported types ------------------------------------------------------------*/
  26. //these could change accordingly with the architecture
  27. #ifndef __ARCHDEP__TYPES
  28. #define __ARCHDEP__TYPES
  29. typedef unsigned char u8_t;
  30. typedef unsigned short int u16_t;
  31. typedef unsigned int u32_t;
  32. typedef int i32_t;
  33. typedef short int i16_t;
  34. typedef signed char i8_t;
  35. #endif /*__ARCHDEP__TYPES*/
  36. /* Exported common structure --------------------------------------------------------*/
  37. #ifndef __SHARED__TYPES
  38. #define __SHARED__TYPES
  39. typedef union{
  40. i16_t i16bit[3];
  41. u8_t u8bit[6];
  42. } Type3Axis16bit_U;
  43. typedef union{
  44. i16_t i16bit;
  45. u8_t u8bit[2];
  46. } Type1Axis16bit_U;
  47. typedef union{
  48. i32_t i32bit;
  49. u8_t u8bit[4];
  50. } Type1Axis32bit_U;
  51. typedef enum {
  52. MEMS_SUCCESS = 0x01,
  53. MEMS_ERROR = 0x00
  54. } status_t;
  55. #endif /*__SHARED__TYPES*/
  56. /* Exported macro ------------------------------------------------------------*/
  57. /* Exported constants --------------------------------------------------------*/
  58. /************** I2C Address *****************/
  59. #define LSM303C_MAG_I2C_ADDRESS 0x3C
  60. /************** Who am I *******************/
  61. #define LSM303C_MAG_WHO_AM_I 0x3D
  62. /************** Device Register *******************/
  63. #define LSM303C_MAG_WHO_AM_I_REG 0X0F
  64. #define LSM303C_MAG_CTRL_REG1 0X20
  65. #define LSM303C_MAG_CTRL_REG2 0X21
  66. #define LSM303C_MAG_CTRL_REG3 0X22
  67. #define LSM303C_MAG_CTRL_REG4 0X23
  68. #define LSM303C_MAG_CTRL_REG5 0X24
  69. #define LSM303C_MAG_STATUS_REG 0X27
  70. #define LSM303C_MAG_OUTX_L 0X28
  71. #define LSM303C_MAG_OUTX_H 0X29
  72. #define LSM303C_MAG_OUTY_L 0X2A
  73. #define LSM303C_MAG_OUTY_H 0X2B
  74. #define LSM303C_MAG_OUTZ_L 0X2C
  75. #define LSM303C_MAG_OUTZ_H 0X2D
  76. #define LSM303C_MAG_TEMP_OUT_L 0X2E
  77. #define LSM303C_MAG_TEMP_OUT_H 0X2F
  78. #define LSM303C_MAG_INT_CFG 0X30
  79. #define LSM303C_MAG_INT_SRC 0X31
  80. #define LSM303C_MAG_INT_THS_L 0X32
  81. #define LSM303C_MAG_INT_THS_H 0X33
  82. /************** Generic Function *******************/
  83. /*******************************************************************************
  84. * Register : Generic - All
  85. * Address : Generic - All
  86. * Bit Group Name: None
  87. * Permission : W
  88. *******************************************************************************/
  89. status_t LSM303C_ACC_GYRO_WriteReg( void *handle, u8_t Reg, u8_t *Bufp, u16_t len );
  90. /*******************************************************************************
  91. * Register : Generic - All
  92. * Address : Generic - All
  93. * Bit Group Name: None
  94. * Permission : R
  95. *******************************************************************************/
  96. status_t LSM303C_ACC_GYRO_ReadReg( void *handle, u8_t Reg, u8_t *Bufp, u16_t len );
  97. /**************** Base Function *******************/
  98. /*******************************************************************************
  99. * Register : WHO_AM_I_REG
  100. * Address : 0X0F
  101. * Bit Group Name: WHO_AM_I_BIT
  102. * Permission : RO
  103. *******************************************************************************/
  104. #define LSM303C_MAG_WHO_AM_I_BIT_MASK 0xFF
  105. #define LSM303C_MAG_WHO_AM_I_BIT_POSITION 0
  106. status_t LSM303C_MAG_R_WHO_AM_I_(void *handle, u8_t *value);
  107. /*******************************************************************************
  108. * Register : CTRL_REG3
  109. * Address : 0X22
  110. * Bit Group Name: MD
  111. * Permission : RW
  112. *******************************************************************************/
  113. typedef enum {
  114. LSM303C_MAG_MD_CONTINUOUS =0x00,
  115. LSM303C_MAG_MD_SINGLE =0x01,
  116. LSM303C_MAG_MD_POWER_DOWN =0x02,
  117. LSM303C_MAG_MD_POWER_DOWN_AUTO =0x03,
  118. } LSM303C_MAG_MD_t;
  119. #define LSM303C_MAG_MD_MASK 0x03
  120. status_t LSM303C_MAG_W_SystemOperatingMode(void *handle, LSM303C_MAG_MD_t newValue);
  121. status_t LSM303C_MAG_R_SystemOperatingMode(void *handle, LSM303C_MAG_MD_t *value);
  122. /*******************************************************************************
  123. * Register : CTRL_REG5
  124. * Address : 0X24
  125. * Bit Group Name: BDU
  126. * Permission : RW
  127. *******************************************************************************/
  128. typedef enum {
  129. LSM303C_MAG_BDU_DISABLE =0x00,
  130. LSM303C_MAG_BDU_ENABLE =0x40,
  131. } LSM303C_MAG_BDU_t;
  132. #define LSM303C_MAG_BDU_MASK 0x40
  133. status_t LSM303C_MAG_W_BlockDataUpdate(void *handle, LSM303C_MAG_BDU_t newValue);
  134. status_t LSM303C_MAG_R_BlockDataUpdate(void *handle, LSM303C_MAG_BDU_t *value);
  135. /*******************************************************************************
  136. * Register : CTRL_REG2
  137. * Address : 0X21
  138. * Bit Group Name: FS
  139. * Permission : RW
  140. *******************************************************************************/
  141. typedef enum {
  142. LSM303C_MAG_FS_4Ga =0x00,
  143. LSM303C_MAG_FS_8Ga =0x20,
  144. LSM303C_MAG_FS_12Ga =0x40,
  145. LSM303C_MAG_FS_16Ga =0x60,
  146. } LSM303C_MAG_FS_t;
  147. #define LSM303C_MAG_FS_MASK 0x60
  148. status_t LSM303C_MAG_W_FullScale(void *handle, LSM303C_MAG_FS_t newValue);
  149. status_t LSM303C_MAG_R_FullScale(void *handle, LSM303C_MAG_FS_t *value);
  150. /*******************************************************************************
  151. * Register : CTRL_REG1
  152. * Address : 0X20
  153. * Bit Group Name: DO
  154. * Permission : RW
  155. *******************************************************************************/
  156. typedef enum {
  157. LSM303C_MAG_DO_0_625Hz =0x00,
  158. LSM303C_MAG_DO_1_25Hz =0x04,
  159. LSM303C_MAG_DO_2_5Hz =0x08,
  160. LSM303C_MAG_DO_5Hz =0x0C,
  161. LSM303C_MAG_DO_10Hz =0x10,
  162. LSM303C_MAG_DO_20Hz =0x14,
  163. LSM303C_MAG_DO_40Hz =0x18,
  164. LSM303C_MAG_DO_80Hz =0x1C,
  165. } LSM303C_MAG_DO_t;
  166. #define LSM303C_MAG_DO_MASK 0x1C
  167. status_t LSM303C_MAG_W_OutputDataRate(void *handle, LSM303C_MAG_DO_t newValue);
  168. status_t LSM303C_MAG_R_OutputDataRate(void *handle, LSM303C_MAG_DO_t *value);
  169. /*******************************************************************************
  170. * Register : <REGISTER_L> - <REGISTER_H>
  171. * Output Type : Magnetic
  172. * Permission : RO
  173. *******************************************************************************/
  174. status_t LSM303C_MAG_Get_Magnetic(void *handle,u8_t *buff);
  175. /**************** Advanced Function *******************/
  176. /*******************************************************************************
  177. * Register : CTRL_REG1
  178. * Address : 0X20
  179. * Bit Group Name: ST
  180. * Permission : RW
  181. *******************************************************************************/
  182. typedef enum {
  183. LSM303C_MAG_ST_DISABLE =0x00,
  184. LSM303C_MAG_ST_ENABLE =0x01,
  185. } LSM303C_MAG_ST_t;
  186. #define LSM303C_MAG_ST_MASK 0x01
  187. status_t LSM303C_MAG_W_SelfTest(void *handle, LSM303C_MAG_ST_t newValue);
  188. status_t LSM303C_MAG_R_SelfTest(void *handle, LSM303C_MAG_ST_t *value);
  189. /*******************************************************************************
  190. * Register : CTRL_REG1
  191. * Address : 0X20
  192. * Bit Group Name: OM
  193. * Permission : RW
  194. *******************************************************************************/
  195. typedef enum {
  196. LSM303C_MAG_OM_LOW_POWER =0x00,
  197. LSM303C_MAG_OM_MEDIUM =0x20,
  198. LSM303C_MAG_OM_HIGH =0x40,
  199. LSM303C_MAG_OM_ULTRA_HIGH =0x60,
  200. } LSM303C_MAG_OM_t;
  201. #define LSM303C_MAG_OM_MASK 0x60
  202. status_t LSM303C_MAG_W_OperatingModeXY(void *handle, LSM303C_MAG_OM_t newValue);
  203. status_t LSM303C_MAG_R_OperatingModeXY(void *handle, LSM303C_MAG_OM_t *value);
  204. /*******************************************************************************
  205. * Register : CTRL_REG1
  206. * Address : 0X20
  207. * Bit Group Name: TEMP_EN
  208. * Permission : RW
  209. *******************************************************************************/
  210. typedef enum {
  211. LSM303C_MAG_TEMP_EN_DISABLE =0x00,
  212. LSM303C_MAG_TEMP_EN_ENABLE =0x80,
  213. } LSM303C_MAG_TEMP_EN_t;
  214. #define LSM303C_MAG_TEMP_EN_MASK 0x80
  215. status_t LSM303C_MAG_W_TemperatureSensor(void *handle, LSM303C_MAG_TEMP_EN_t newValue);
  216. status_t LSM303C_MAG_R_TemperatureSensor(void *handle, LSM303C_MAG_TEMP_EN_t *value);
  217. /*******************************************************************************
  218. * Register : CTRL_REG2
  219. * Address : 0X21
  220. * Bit Group Name: SOFT_RST
  221. * Permission : RW
  222. *******************************************************************************/
  223. typedef enum {
  224. LSM303C_MAG_SOFT_RST_NO =0x00,
  225. LSM303C_MAG_SOFT_RST_YES =0x04,
  226. } LSM303C_MAG_SOFT_RST_t;
  227. #define LSM303C_MAG_SOFT_RST_MASK 0x04
  228. status_t LSM303C_MAG_W_SoftRST(void *handle, LSM303C_MAG_SOFT_RST_t newValue);
  229. status_t LSM303C_MAG_R_SoftRST(void *handle, LSM303C_MAG_SOFT_RST_t *value);
  230. /*******************************************************************************
  231. * Register : CTRL_REG2
  232. * Address : 0X21
  233. * Bit Group Name: REBOOT
  234. * Permission : RW
  235. *******************************************************************************/
  236. typedef enum {
  237. LSM303C_MAG_REBOOT_NO =0x00,
  238. LSM303C_MAG_REBOOT_YES =0x08,
  239. } LSM303C_MAG_REBOOT_t;
  240. #define LSM303C_MAG_REBOOT_MASK 0x08
  241. status_t LSM303C_MAG_W_Reboot(void *handle, LSM303C_MAG_REBOOT_t newValue);
  242. status_t LSM303C_MAG_R_Reboot(void *handle, LSM303C_MAG_REBOOT_t *value);
  243. /*******************************************************************************
  244. * Register : CTRL_REG3
  245. * Address : 0X22
  246. * Bit Group Name: SIM
  247. * Permission : RW
  248. *******************************************************************************/
  249. typedef enum {
  250. LSM303C_MAG_SIM_4_WIRE =0x00,
  251. LSM303C_MAG_SIM_3_WIRE =0x04,
  252. } LSM303C_MAG_SIM_t;
  253. #define LSM303C_MAG_SIM_MASK 0x04
  254. status_t LSM303C_MAG_W_SerialInterfaceMode(void *handle, LSM303C_MAG_SIM_t newValue);
  255. status_t LSM303C_MAG_R_SerialInterfaceMode(void *handle, LSM303C_MAG_SIM_t *value);
  256. /*******************************************************************************
  257. * Register : CTRL_REG3
  258. * Address : 0X22
  259. * Bit Group Name: LP
  260. * Permission : RW
  261. *******************************************************************************/
  262. typedef enum {
  263. LSM303C_MAG_LP_DISABLE =0x00,
  264. LSM303C_MAG_LP_ENABLE =0x20,
  265. } LSM303C_MAG_LP_t;
  266. #define LSM303C_MAG_LP_MASK 0x20
  267. status_t LSM303C_MAG_W_FastLowPowerXYZ(void *handle, LSM303C_MAG_LP_t newValue);
  268. status_t LSM303C_MAG_R_FastLowPowerXYZ(void *handle, LSM303C_MAG_LP_t *value);
  269. /*******************************************************************************
  270. * Register : CTRL_REG4
  271. * Address : 0X23
  272. * Bit Group Name: BLE
  273. * Permission : RW
  274. *******************************************************************************/
  275. typedef enum {
  276. LSM303C_MAG_BLE_INVERT =0x00,
  277. LSM303C_MAG_BLE_DEFAULT =0x02,
  278. } LSM303C_MAG_BLE_t;
  279. #define LSM303C_MAG_BLE_MASK 0x02
  280. status_t LSM303C_MAG_W_LittleBigEndianInversion(void *handle, LSM303C_MAG_BLE_t newValue);
  281. status_t LSM303C_MAG_R_LittleBigEndianInversion(void *handle, LSM303C_MAG_BLE_t *value);
  282. /*******************************************************************************
  283. * Register : CTRL_REG4
  284. * Address : 0X23
  285. * Bit Group Name: OMZ
  286. * Permission : RW
  287. *******************************************************************************/
  288. typedef enum {
  289. LSM303C_MAG_OMZ_LOW_POWER =0x00,
  290. LSM303C_MAG_OMZ_MEDIUM =0x04,
  291. LSM303C_MAG_OMZ_HIGH =0x08,
  292. LSM303C_MAG_OMZ_ULTRA_HIGH =0x0C,
  293. } LSM303C_MAG_OMZ_t;
  294. #define LSM303C_MAG_OMZ_MASK 0x0C
  295. status_t LSM303C_MAG_W_OperatingModeZ(void *handle, LSM303C_MAG_OMZ_t newValue);
  296. status_t LSM303C_MAG_R_OperatingModeZ(void *handle, LSM303C_MAG_OMZ_t *value);
  297. /*******************************************************************************
  298. * Register : STATUS_REG
  299. * Address : 0X27
  300. * Bit Group Name: XDA
  301. * Permission : RO
  302. *******************************************************************************/
  303. typedef enum {
  304. LSM303C_MAG_XDA_NOT_AVAILABLE =0x00,
  305. LSM303C_MAG_XDA_AVAILABLE =0x01,
  306. } LSM303C_MAG_XDA_t;
  307. #define LSM303C_MAG_XDA_MASK 0x01
  308. status_t LSM303C_MAG_R_NewXData(void *handle, LSM303C_MAG_XDA_t *value);
  309. /*******************************************************************************
  310. * Register : STATUS_REG
  311. * Address : 0X27
  312. * Bit Group Name: YDA
  313. * Permission : RO
  314. *******************************************************************************/
  315. typedef enum {
  316. LSM303C_MAG_YDA_NOT_AVAILABLE =0x00,
  317. LSM303C_MAG_YDA_AVAILABLE =0x02,
  318. } LSM303C_MAG_YDA_t;
  319. #define LSM303C_MAG_YDA_MASK 0x02
  320. status_t LSM303C_MAG_R_NewYData(void *handle, LSM303C_MAG_YDA_t *value);
  321. /*******************************************************************************
  322. * Register : STATUS_REG
  323. * Address : 0X27
  324. * Bit Group Name: ZDA
  325. * Permission : RO
  326. *******************************************************************************/
  327. typedef enum {
  328. LSM303C_MAG_ZDA_NOT_AVAILABLE =0x00,
  329. LSM303C_MAG_ZDA_AVAILABLE =0x04,
  330. } LSM303C_MAG_ZDA_t;
  331. #define LSM303C_MAG_ZDA_MASK 0x04
  332. status_t LSM303C_MAG_R_NewZData(void *handle, LSM303C_MAG_ZDA_t *value);
  333. /*******************************************************************************
  334. * Register : STATUS_REG
  335. * Address : 0X27
  336. * Bit Group Name: ZYXDA
  337. * Permission : RO
  338. *******************************************************************************/
  339. typedef enum {
  340. LSM303C_MAG_ZYXDA_NOT_AVAILABLE =0x00,
  341. LSM303C_MAG_ZYXDA_AVAILABLE =0x08,
  342. } LSM303C_MAG_ZYXDA_t;
  343. #define LSM303C_MAG_ZYXDA_MASK 0x08
  344. status_t LSM303C_MAG_R_NewXYZData(void *handle, LSM303C_MAG_ZYXDA_t *value);
  345. /*******************************************************************************
  346. * Register : STATUS_REG
  347. * Address : 0X27
  348. * Bit Group Name: XOR
  349. * Permission : RO
  350. *******************************************************************************/
  351. typedef enum {
  352. LSM303C_MAG_XOR_NOT_OVERRUN =0x00,
  353. LSM303C_MAG_XOR_OVERRUN =0x10,
  354. } LSM303C_MAG_XOR_t;
  355. #define LSM303C_MAG_XOR_MASK 0x10
  356. status_t LSM303C_MAG_R_DataXOverrun(void *handle, LSM303C_MAG_XOR_t *value);
  357. /*******************************************************************************
  358. * Register : STATUS_REG
  359. * Address : 0X27
  360. * Bit Group Name: YOR
  361. * Permission : RO
  362. *******************************************************************************/
  363. typedef enum {
  364. LSM303C_MAG_YOR_NOT_OVERRUN =0x00,
  365. LSM303C_MAG_YOR_OVERRUN =0x20,
  366. } LSM303C_MAG_YOR_t;
  367. #define LSM303C_MAG_YOR_MASK 0x20
  368. status_t LSM303C_MAG_R_DataYOverrun(void *handle, LSM303C_MAG_YOR_t *value);
  369. /*******************************************************************************
  370. * Register : STATUS_REG
  371. * Address : 0X27
  372. * Bit Group Name: ZOR
  373. * Permission : RO
  374. *******************************************************************************/
  375. typedef enum {
  376. LSM303C_MAG_ZOR_NOT_OVERRUN =0x00,
  377. LSM303C_MAG_ZOR_OVERRUN =0x40,
  378. } LSM303C_MAG_ZOR_t;
  379. #define LSM303C_MAG_ZOR_MASK 0x40
  380. status_t LSM303C_MAG_R_DataZOverrun(void *handle, LSM303C_MAG_ZOR_t *value);
  381. /*******************************************************************************
  382. * Register : STATUS_REG
  383. * Address : 0X27
  384. * Bit Group Name: ZYXOR
  385. * Permission : RO
  386. *******************************************************************************/
  387. typedef enum {
  388. LSM303C_MAG_ZYXOR_NOT_OVERRUN =0x00,
  389. LSM303C_MAG_ZYXOR_OVERRUN =0x80,
  390. } LSM303C_MAG_ZYXOR_t;
  391. #define LSM303C_MAG_ZYXOR_MASK 0x80
  392. status_t LSM303C_MAG_R_DataXYZOverrun(void *handle, LSM303C_MAG_ZYXOR_t *value);
  393. /*******************************************************************************
  394. * Register : INT_CFG
  395. * Address : 0X30
  396. * Bit Group Name: IEN
  397. * Permission : RW
  398. *******************************************************************************/
  399. typedef enum {
  400. LSM303C_MAG_IEN_DISABLE =0x00,
  401. LSM303C_MAG_IEN_ENABLE =0x01,
  402. } LSM303C_MAG_IEN_t;
  403. #define LSM303C_MAG_IEN_MASK 0x01
  404. status_t LSM303C_MAG_W_InterruptEnable(void *handle, LSM303C_MAG_IEN_t newValue);
  405. status_t LSM303C_MAG_R_InterruptEnable(void *handle, LSM303C_MAG_IEN_t *value);
  406. /*******************************************************************************
  407. * Register : INT_CFG
  408. * Address : 0X30
  409. * Bit Group Name: LIR
  410. * Permission : RW
  411. *******************************************************************************/
  412. typedef enum {
  413. LSM303C_MAG_LIR_LATCHED =0x00,
  414. LSM303C_MAG_LIR_NOT_LATCHED =0x02,
  415. } LSM303C_MAG_LIR_t;
  416. #define LSM303C_MAG_LIR_MASK 0x02
  417. status_t LSM303C_MAG_W_LatchInterruptRq(void *handle, LSM303C_MAG_LIR_t newValue);
  418. status_t LSM303C_MAG_R_LatchInterruptRq(void *handle, LSM303C_MAG_LIR_t *value);
  419. /*******************************************************************************
  420. * Register : INT_CFG
  421. * Address : 0X30
  422. * Bit Group Name: IEA
  423. * Permission : RW
  424. *******************************************************************************/
  425. typedef enum {
  426. LSM303C_MAG_IEA_LOW =0x00,
  427. LSM303C_MAG_IEA_HIGH =0x04,
  428. } LSM303C_MAG_IEA_t;
  429. #define LSM303C_MAG_IEA_MASK 0x04
  430. status_t LSM303C_MAG_W_InterruptActive(void *handle, LSM303C_MAG_IEA_t newValue);
  431. status_t LSM303C_MAG_R_InterruptActive(void *handle, LSM303C_MAG_IEA_t *value);
  432. /*******************************************************************************
  433. * Register : INT_CFG
  434. * Address : 0X30
  435. * Bit Group Name: ZIEN
  436. * Permission : RW
  437. *******************************************************************************/
  438. typedef enum {
  439. LSM303C_MAG_ZIEN_DISABLE =0x00,
  440. LSM303C_MAG_ZIEN_ENABLE =0x20,
  441. } LSM303C_MAG_ZIEN_t;
  442. #define LSM303C_MAG_ZIEN_MASK 0x20
  443. status_t LSM303C_MAG_W_InterruptOnZ(void *handle, LSM303C_MAG_ZIEN_t newValue);
  444. status_t LSM303C_MAG_R_InterruptOnZ(void *handle, LSM303C_MAG_ZIEN_t *value);
  445. /*******************************************************************************
  446. * Register : INT_CFG
  447. * Address : 0X30
  448. * Bit Group Name: YIEN
  449. * Permission : RW
  450. *******************************************************************************/
  451. typedef enum {
  452. LSM303C_MAG_YIEN_DISABLE =0x00,
  453. LSM303C_MAG_YIEN_ENABLE =0x40,
  454. } LSM303C_MAG_YIEN_t;
  455. #define LSM303C_MAG_YIEN_MASK 0x40
  456. status_t LSM303C_MAG_W_InterruptOnY(void *handle, LSM303C_MAG_YIEN_t newValue);
  457. status_t LSM303C_MAG_R_InterruptOnY(void *handle, LSM303C_MAG_YIEN_t *value);
  458. /*******************************************************************************
  459. * Register : INT_CFG
  460. * Address : 0X30
  461. * Bit Group Name: XIEN
  462. * Permission : RW
  463. *******************************************************************************/
  464. typedef enum {
  465. LSM303C_MAG_XIEN_DISABLE =0x00,
  466. LSM303C_MAG_XIEN_ENABLE =0x80,
  467. } LSM303C_MAG_XIEN_t;
  468. #define LSM303C_MAG_XIEN_MASK 0x80
  469. status_t LSM303C_MAG_W_InterruptOnX(void *handle, LSM303C_MAG_XIEN_t newValue);
  470. status_t LSM303C_MAG_R_InterruptOnX(void *handle, LSM303C_MAG_XIEN_t *value);
  471. /*******************************************************************************
  472. * Register : INT_SRC
  473. * Address : 0X31
  474. * Bit Group Name: INT
  475. * Permission : RW
  476. *******************************************************************************/
  477. typedef enum {
  478. LSM303C_MAG_INT_DOWN =0x00,
  479. LSM303C_MAG_INT_UP =0x01,
  480. } LSM303C_MAG_INT_t;
  481. #define LSM303C_MAG_INT_MASK 0x01
  482. status_t LSM303C_MAG_W_InterruptFlag(void *handle, LSM303C_MAG_INT_t newValue);
  483. status_t LSM303C_MAG_R_InterruptFlag(void *handle, LSM303C_MAG_INT_t *value);
  484. /*******************************************************************************
  485. * Register : INT_SRC
  486. * Address : 0X31
  487. * Bit Group Name: MROI
  488. * Permission : RW
  489. *******************************************************************************/
  490. typedef enum {
  491. LSM303C_MAG_MROI_IN_RANGE =0x00,
  492. LSM303C_MAG_MROI_OVERFLOW =0x02,
  493. } LSM303C_MAG_MROI_t;
  494. #define LSM303C_MAG_MROI_MASK 0x02
  495. status_t LSM303C_MAG_W_MagneticFieldOverflow(void *handle, LSM303C_MAG_MROI_t newValue);
  496. status_t LSM303C_MAG_R_MagneticFieldOverflow(void *handle, LSM303C_MAG_MROI_t *value);
  497. /*******************************************************************************
  498. * Register : INT_SRC
  499. * Address : 0X31
  500. * Bit Group Name: NTH_Z
  501. * Permission : RW
  502. *******************************************************************************/
  503. typedef enum {
  504. LSM303C_MAG_NTH_Z_DOWN =0x00,
  505. LSM303C_MAG_NTH_Z_UP =0x04,
  506. } LSM303C_MAG_NTH_Z_t;
  507. #define LSM303C_MAG_NTH_Z_MASK 0x04
  508. status_t LSM303C_MAG_W_NegativeThresholdFlagZ(void *handle, LSM303C_MAG_NTH_Z_t newValue);
  509. status_t LSM303C_MAG_R_NegativeThresholdFlagZ(void *handle, LSM303C_MAG_NTH_Z_t *value);
  510. /*******************************************************************************
  511. * Register : INT_SRC
  512. * Address : 0X31
  513. * Bit Group Name: NTH_Y
  514. * Permission : RW
  515. *******************************************************************************/
  516. typedef enum {
  517. LSM303C_MAG_NTH_Y_DOWN =0x00,
  518. LSM303C_MAG_NTH_Y_UP =0x08,
  519. } LSM303C_MAG_NTH_Y_t;
  520. #define LSM303C_MAG_NTH_Y_MASK 0x08
  521. status_t LSM303C_MAG_W_NegativeThresholdFlagY(void *handle, LSM303C_MAG_NTH_Y_t newValue);
  522. status_t LSM303C_MAG_R_NegativeThresholdFlagY(void *handle, LSM303C_MAG_NTH_Y_t *value);
  523. /*******************************************************************************
  524. * Register : INT_SRC
  525. * Address : 0X31
  526. * Bit Group Name: NTH_X
  527. * Permission : RW
  528. *******************************************************************************/
  529. typedef enum {
  530. LSM303C_MAG_NTH_X_DOWN =0x00,
  531. LSM303C_MAG_NTH_X_UP =0x10,
  532. } LSM303C_MAG_NTH_X_t;
  533. #define LSM303C_MAG_NTH_X_MASK 0x10
  534. status_t LSM303C_MAG_W_NegativeThresholdFlagX(void *handle, LSM303C_MAG_NTH_X_t newValue);
  535. status_t LSM303C_MAG_R_NegativeThresholdFlagX(void *handle, LSM303C_MAG_NTH_X_t *value);
  536. /*******************************************************************************
  537. * Register : INT_SRC
  538. * Address : 0X31
  539. * Bit Group Name: PTH_Z
  540. * Permission : RW
  541. *******************************************************************************/
  542. typedef enum {
  543. LSM303C_MAG_PTH_Z_DOWN =0x00,
  544. LSM303C_MAG_PTH_Z_UP =0x20,
  545. } LSM303C_MAG_PTH_Z_t;
  546. #define LSM303C_MAG_PTH_Z_MASK 0x20
  547. status_t LSM303C_MAG_W_PositiveThresholdFlagZ(void *handle, LSM303C_MAG_PTH_Z_t newValue);
  548. status_t LSM303C_MAG_R_PositiveThresholdFlagZ(void *handle, LSM303C_MAG_PTH_Z_t *value);
  549. /*******************************************************************************
  550. * Register : INT_SRC
  551. * Address : 0X31
  552. * Bit Group Name: PTH_Y
  553. * Permission : RW
  554. *******************************************************************************/
  555. typedef enum {
  556. LSM303C_MAG_PTH_Y_DOWN =0x00,
  557. LSM303C_MAG_PTH_Y_UP =0x40,
  558. } LSM303C_MAG_PTH_Y_t;
  559. #define LSM303C_MAG_PTH_Y_MASK 0x40
  560. status_t LSM303C_MAG_W_PositiveThresholdFlagY(void *handle, LSM303C_MAG_PTH_Y_t newValue);
  561. status_t LSM303C_MAG_R_PositiveThresholdFlagY(void *handle, LSM303C_MAG_PTH_Y_t *value);
  562. /*******************************************************************************
  563. * Register : INT_SRC
  564. * Address : 0X31
  565. * Bit Group Name: PTH_X
  566. * Permission : RW
  567. *******************************************************************************/
  568. typedef enum {
  569. LSM303C_MAG_PTH_X_DOWN =0x00,
  570. LSM303C_MAG_PTH_X_UP =0x80,
  571. } LSM303C_MAG_PTH_X_t;
  572. #define LSM303C_MAG_PTH_X_MASK 0x80
  573. status_t LSM303C_MAG_W_PositiveThresholdFlagX(void *handle, LSM303C_MAG_PTH_X_t newValue);
  574. status_t LSM303C_MAG_R_PositiveThresholdFlagX(void *handle, LSM303C_MAG_PTH_X_t *value);
  575. /*******************************************************************************
  576. * Register : <REGISTER_L> - <REGISTER_H>
  577. * Output Type : Temperature
  578. * Permission : RO
  579. *******************************************************************************/
  580. status_t LSM303C_MAG_Get_Temperature(void *handle,u8_t *buff);
  581. /*******************************************************************************
  582. * Register : <REGISTER_L> - <REGISTER_H>
  583. * Output Type : MagneticThreshold
  584. * Permission : RW
  585. *******************************************************************************/
  586. status_t LSM303C_MAG_Set_MagneticThreshold(void *handle,u8_t *buff);
  587. status_t LSM303C_MAG_Get_MagneticThreshold(void *handle,u8_t *buff);
  588. /*******************************************************************************
  589. * Register : Generic - All
  590. * Address : Generic - All
  591. * Bit Group Name: None
  592. * Permission : W
  593. *******************************************************************************/
  594. void LSM303C_MAG_SwapHighLowByte(u8_t *bufferToSwap, u8_t numberOfByte, u8_t dimension);
  595. u8_t LSM303C_MAG_WriteReg(void *handle, u8_t Reg, u8_t *Bufp, u16_t len);
  596. u8_t LSM303C_MAG_ReadReg(void *handle, u8_t Reg, u8_t *Bufp, u16_t len);
  597. #ifdef __cplusplus
  598. }
  599. #endif
  600. #endif