Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 
mag_micromag_fw.h
micromag_init
void micromag_init(void)
Definition: mag_micromag_fw.c:47
MmReadRes
#define MmReadRes()
Definition: mag_micromag_fw_hw.h:80
MM_WAITING_EOC
#define MM_WAITING_EOC
Definition: mag_micromag_fw.h:18
micromag_read
void micromag_read()
Definition: mag_micromag_fw.c:64
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
int16_t
signed short int16_t
Definition: types.h:17
uint8_t
unsigned char uint8_t
Definition: types.h:14
micromag_event
void micromag_event(void)
Definition: mag_micromag_fw.c:31
mag_micromag_fw_hw.h
MmSendReq
#define MmSendReq()
Definition: mag_micromag_fw_hw.h:68
led.h
arch independent LED (Light Emitting Diodes) API
micromag_values
volatile int16_t micromag_values[MM_NB_AXIS]
Definition: mag_micromag_fw.c:10
micromag_reset
void micromag_reset()
Definition: mag_micromag_fw.c:59
int32_t
signed long int32_t
Definition: types.h:19
MM_NB_AXIS
#define MM_NB_AXIS
Definition: mag_micromag_fw.h:6
MM_IDLE
#define MM_IDLE
Definition: mag_micromag_fw.h:15
micromag_status
volatile uint8_t micromag_status
Definition: mag_micromag_fw.c:9
micromag_hw_init
void micromag_hw_init(void)
Definition: mag_micromag_fw_hw.c:48
MM_DATA_AVAILABLE
#define MM_DATA_AVAILABLE
Definition: mag_micromag_fw.h:21
micromag_periodic
void micromag_periodic(void)
Definition: mag_micromag_fw.c:13
MM_GOT_EOC
#define MM_GOT_EOC
Definition: mag_micromag_fw.h:19