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
hmc5843.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
24 #ifndef HMC5843_H
25 #define HMC5843_H
26 
27 #include "std.h"
28 #include "mcu_periph/i2c.h"
29 
30 struct Hmc5843 {
37  union {
40  } data;
41 };
42 
43 extern struct Hmc5843 hmc5843;
44 
45 #ifndef HMC5843_NO_IRQ
46 #include "peripherals/hmc5843_arch.h"
47 
48 extern void hmc5843_arch_init( void );
49 extern void hmc5843_arch_reset( void );
50 #endif
51 
52 extern void hmc5843_init(void);
53 extern void hmc5843_periodic(void);
54 extern void hmc5843_idle_task(void);
55 
56 /* default I2C address */
57 #define HMC5843_ADDR 0x3C
58 
59 /* Registers */
60 #define HMC5843_REG_CFGA 0x00
61 #define HMC5843_REG_CFGB 0x01
62 #define HMC5843_REG_MODE 0x02
63 #define HMC5843_REG_DATXM 0x03
64 #define HMC5843_REG_DATXL 0x04
65 #define HMC5843_REG_DATYM 0x05
66 #define HMC5843_REG_DATYL 0x06
67 #define HMC5843_REG_DATZM 0x07
68 #define HMC5843_REG_DATZL 0x08
69 #define HMC5843_REG_STATUS 0x09
70 #define HMC5843_REG_IDA 0x0A
71 #define HMC5843_REG_IDB 0x0B
72 #define HMC5843_REG_IDC 0x0C
73 
74 #include <string.h>
75 
76 #define MagEvent(_m_handler) { \
77  hmc5843_idle_task(); \
78  if (hmc5843.data_available) { \
79  _m_handler(); \
80  } \
81  }
82 
83 #endif /* HMC5843_H */
uint32_t timeout
Definition: hmc5843.h:32
void hmc5843_init(void)
Definition: hmc5843.c:16
union Hmc5843::@16 data
uint8_t initialized
Definition: hmc5843.h:35
uint8_t sent_tx
Definition: hmc5843.h:33
void hmc5843_periodic(void)
Definition: hmc5843.c:103
void hmc5843_idle_task(void)
Definition: hmc5843.c:60
struct Hmc5843 hmc5843
Definition: hmc5843.c:9
struct i2c_transaction i2c_trans
Definition: hmc5843.h:31
uint8_t sent_rx
Definition: hmc5843.h:34
unsigned long uint32_t
Definition: types.h:18
signed short int16_t
Definition: types.h:17
uint8_t data_available
Definition: hmc5843.h:36
void hmc5843_arch_init(void)
Definition: hmc5843_arch.c:24
void hmc5843_arch_reset(void)
Definition: hmc5843_arch.c:61
int16_t value[3]
Definition: hmc5843.h:39
unsigned char uint8_t
Definition: types.h:14
uint8_t buf[7]
Definition: hmc5843.h:38