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
max1168.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3  * Copyright (C) 2012 Gautier Hattenberger
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
23 #ifndef MAX1168_H
24 #define MAX1168_H
25 
26 #include "std.h"
27 
28 #define MAX1168_NB_CHAN 8
29 
30 #ifndef MAX1168_SLAVE_IDX
31 #define MAX1168_SLAVE_IDX SPI_SLAVE0
32 #endif
33 
34 #ifndef MAX1168_SPI_DEV
35 #define MAX1168_SPI_DEV spi1
36 #endif
37 
40 #ifndef MAX1168_CONF_CHANNEL
41 #define MAX1168_CONF_CHANNEL 0x7 // select all channels
42 #endif
43 #ifndef MAX1168_CONF_SCAN
44 #define MAX1168_CONF_SCAN 0x1 // scan number of channels selected
45 #endif
46 #ifndef MAX1168_CONF_REF
47 #define MAX1168_CONF_REF 0x0 // internal ref and no power down
48 #endif
49 #ifndef MAX1168_CONF_CLOCK
50 #define MAX1168_CONF_CLOCK 0x1 // internal clock
51 #endif
52 
53 #define MAX1168_CONF_CR ((MAX1168_CONF_CHANNEL<<5)|(MAX1168_CONF_SCAN<<3)|(MAX1168_CONF_REF<<1)|(MAX1168_CONF_CLOCK))
54 
55 extern void max1168_init( void );
56 extern void max1168_read( void );
57 extern void max1168_event( void );
58 
59 #define MAX1168_IDLE 0
60 #define MAX1168_SENDING_REQ 1
61 #define MAX1168_GOT_EOC 2
62 #define MAX1168_READING_RES 3
63 #define MAX1168_DATA_AVAILABLE 4
64 extern volatile uint8_t max1168_status;
65 
67 
68 #define Max1168Periodic() { \
69  if (max1168_status == MAX1168_IDLE) { \
70  max1168_read(); \
71  } \
72 }
73 
74 /* underlying architecture */
75 #include "peripherals/max1168_arch.h"
76 /* must be implemented by underlying architecture */
77 extern void max1168_arch_init( void );
78 
79 
80 #endif /* MAX1168_H */
unsigned short uint16_t
Definition: types.h:16
void max1168_event(void)
Definition: max1168.c:98
void max1168_read(void)
Definition: max1168_arch.c:26
#define MAX1168_NB_CHAN
Definition: max1168.h:28
volatile uint8_t max1168_status
Definition: max1168.c:27
unsigned char uint8_t
Definition: types.h:14
void max1168_arch_init(void)
Definition: max1168_arch.c:31
uint16_t max1168_values[MAX1168_NB_CHAN]
Definition: max1168.c:28
void max1168_init(void)
Definition: max1168.c:40