Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mag_micromag_fw.c
Go to the documentation of this file.
3 #include "led.h"
4 
5 #ifndef DOWNLINK_DEVICE
6 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
7 #endif
8 #include "mcu_periph/uart.h"
9 #include "messages.h"
11 
14 
15 
16 void micromag_periodic( void ) {
17 
18  static uint8_t cnt = 0;
19 
20  if (micromag_status == MM_IDLE) {
21  // uint8_t * tab = &cnt;
22  // DOWNLINK_SEND_DEBUG(1,tab);
23  cnt = 0;
24  MmSendReq();
25  }
26  else if (micromag_status == MM_GOT_EOC) {
27  MmReadRes();
28  }
29  else if (micromag_status == MM_WAITING_EOC) {
30  cnt++;
31  if (cnt > 50) {cnt = 0; micromag_status = MM_IDLE;}
32  }
33 }
34 
35 void micromag_event( void ) {
36 
40 
42  DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice,
43  &mx,
44  &my,
45  &mz );
47  }
48 }
49 
50 void micromag_init( void ) {
51 
53 
54  uint8_t i;
55  for (i=0; i<MM_NB_AXIS; i++)
56  micromag_values[i] = 0;
58 }
59 
62 }
63 
64 void micromag_read() {
65  if (micromag_status == MM_IDLE) {
66  MmSendReq();
67  }
68  else if (micromag_status == MM_GOT_EOC) {
69  MmReadRes();
70  }
71  else if (micromag_status == MM_DATA_AVAILABLE) {
73  }
74 }
75 
void micromag_reset()
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define MM_WAITING_EOC
Definition: micromag.h:16
volatile int16_t micromag_values[MM_NB_AXIS]
#define MM_GOT_EOC
Definition: micromag.h:17
#define MM_IDLE
Definition: micromag.h:13
void micromag_init(void)
void micromag_periodic(void)
void micromag_read()
signed short int16_t
Definition: types.h:17
#define MmSendReq()
Definition: micromag_hw.h:68
signed long int32_t
Definition: types.h:19
#define MM_NB_AXIS
Definition: micromag.h:6
#define MmReadRes()
Definition: micromag_hw.h:80
#define MM_DATA_AVAILABLE
Definition: micromag.h:19
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