Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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 "messages.h"
8 
11 
12 
13 void micromag_periodic( void ) {
14 
15  static uint8_t cnt = 0;
16 
17  if (micromag_status == MM_IDLE) {
18  // uint8_t * tab = &cnt;
19  // DOWNLINK_SEND_DEBUG(1,tab);
20  cnt = 0;
21  MmSendReq();
22  }
23  else if (micromag_status == MM_GOT_EOC) {
24  MmReadRes();
25  }
26  else if (micromag_status == MM_WAITING_EOC) {
27  cnt++;
28  if (cnt > 50) {cnt = 0; micromag_status = MM_IDLE;}
29  }
30 }
31 
32 void micromag_event( void ) {
33 
37 
39  DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice,
40  &mx,
41  &my,
42  &mz );
44  }
45 }
46 
47 void micromag_init( void ) {
48 
50 
51  uint8_t i;
52  for (i=0; i<MM_NB_AXIS; i++)
53  micromag_values[i] = 0;
55 }
56 
59 }
60 
61 void micromag_read() {
62  if (micromag_status == MM_IDLE) {
63  MmSendReq();
64  }
65  else if (micromag_status == MM_GOT_EOC) {
66  MmReadRes();
67  }
68  else if (micromag_status == MM_DATA_AVAILABLE) {
70  }
71 }
72 
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