Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mag_micromag_fw.c
Go to the documentation of this file.
3 #include "led.h"
4 
5 #include "mcu_periph/uart.h"
6 #include "pprzlink/messages.h"
8 
11 
12 
14 {
15 
16  static uint8_t cnt = 0;
17 
18  if (micromag_status == MM_IDLE) {
19  // uint8_t * tab = &cnt;
20  // DOWNLINK_SEND_DEBUG(1,tab);
21  cnt = 0;
22  MmSendReq();
23  } else if (micromag_status == MM_GOT_EOC) {
24  MmReadRes();
25  } else if (micromag_status == MM_WAITING_EOC) {
26  cnt++;
27  if (cnt > 50) {cnt = 0; micromag_status = MM_IDLE;}
28  }
29 }
30 
31 void micromag_event(void)
32 {
33 
34  int32_t mx = micromag_values[0];
35  int32_t my = micromag_values[1];
36  int32_t mz = micromag_values[2];
37 
39  DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice,
40  &mx,
41  &my,
42  &mz);
44  }
45 }
46 
47 void micromag_init(void)
48 {
49 
51 
52  uint8_t i;
53  for (i = 0; i < MM_NB_AXIS; i++) {
54  micromag_values[i] = 0;
55  }
57 }
58 
60 {
62 }
63 
65 {
66  if (micromag_status == MM_IDLE) {
67  MmSendReq();
68  } else if (micromag_status == MM_GOT_EOC) {
69  MmReadRes();
70  } else if (micromag_status == MM_DATA_AVAILABLE) {
72  }
73 }
74 
void micromag_reset()
#define MmReadRes()
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define MM_NB_AXIS
volatile int16_t micromag_values[MM_NB_AXIS]
#define MM_DATA_AVAILABLE
void micromag_init(void)
void micromag_periodic(void)
void micromag_read()
#define MM_WAITING_EOC
#define MM_IDLE
#define MmSendReq()
signed short int16_t
Definition: types.h:17
signed long int32_t
Definition: types.h:19
#define MM_GOT_EOC
unsigned char uint8_t
Definition: types.h:14
arch independent LED (Light Emitting Diodes) API
void micromag_event(void)
void micromag_hw_init(void)
volatile uint8_t micromag_status