bexus_mag.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef bexus_mag_h
  2. #define bexus_mag_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //#include "cmsis_os.h"
  7. #include "main.h"
  8. #include <stdbool.h>
  9. #include "bexus_variables.h"
  10. #include "i2c.h"
  11. #include <math.h>
  12. #include <stdlib.h>
  13. // register addresses
  14. enum regAddr
  15. {
  16. WHO_AM_I = 0x0F,
  17. CTRL_REG1 = 0x20,
  18. CTRL_REG2 = 0x21,
  19. CTRL_REG3 = 0x22,
  20. CTRL_REG4 = 0x23,
  21. CTRL_REG5 = 0x24,
  22. STATUS_REG = 0x27,
  23. OUT_X_L = 0x28,
  24. OUT_X_H = 0x29,
  25. OUT_Y_L = 0x2A,
  26. OUT_Y_H = 0x2B,
  27. OUT_Z_L = 0x2C,
  28. OUT_Z_H = 0x2D,
  29. TEMP_OUT_L = 0x2E,
  30. TEMP_OUT_H = 0x2F,
  31. INT_CFG = 0x30,
  32. INT_SRC = 0x31,
  33. INT_THS_L = 0x32,
  34. INT_THS_H = 0x33,
  35. };
  36. void Mag_cal(void);
  37. void Mag_Init(void);
  38. void writeReg(uint8_t reg, uint8_t value);
  39. uint8_t readReg(uint8_t reg);
  40. int Mag_Read(void);
  41. uint8_t testReg(uint8_t address, uint8_t reg);
  42. /*
  43. void vector_cross (struct vector_Uint *a,struct vector_Uint *b,struct vector_Uint *out )
  44. {
  45. out->x = (a->y * b->z) - (a->z * b->y);
  46. out->y = (a->z * b->x) - (a->x * b->z);
  47. out->z = (a->x * b->y) - (a->y * b->x);
  48. }*/
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif