Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
temp_temod.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2010 Martin Mueller
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 
32 #include "mcu_periph/i2c.h"
33 #include "led.h"
34 #include "mcu_periph/uart.h"
35 #include "messages.h"
37 
40 
41 #ifndef DOWNLINK_DEVICE
42 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
43 #endif
44 
45 #ifndef TEMOD_I2C_DEV
46 #define TEMOD_I2C_DEV i2c0
47 #endif
48 
49 #ifndef TEMOD_TYPE
50 #define TEMOD_TYPE TEMOD_I2C_R1
51 #endif
52 
53 #define TEMOD_SLAVE_ADDR 0xF0
54 
55 void temod_init(void) {
57 }
58 
59 void temod_periodic( void ) {
61 }
62 
63 void temod_event( void ) {
64 
66 
67  uint16_t tmd_temperature;
68 
69  /* read two byte temperature */
70  tmd_temperature = tmd_trans.buf[0] << 8;
71  tmd_temperature |= tmd_trans.buf[1];
72 
73  ftmd_temperature = (tmd_temperature / TEMOD_TYPE) - 32.;
74 
75  DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &tmd_temperature, &ftmd_temperature);
77  }
78 }
79 
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define I2CReceive(_p, _t, _s_addr, _len)
Definition: i2c.h:140
void temod_periodic(void)
Definition: temp_temod.c:59
#define TEMOD_SLAVE_ADDR
Definition: temp_temod.c:53
#define TEMOD_I2C_DEV
Definition: temp_temod.c:46
void temod_init(void)
Definition: temp_temod.c:55
enum I2CTransactionStatus status
Definition: i2c.h:47
float ftmd_temperature
Definition: temp_temod.c:38
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:46
arch independent LED (Light Emitting Diodes) API
struct i2c_transaction tmd_trans
Definition: temp_temod.c:39
#define TEMOD_TYPE
Definition: temp_temod.c:50
void temod_event(void)
Definition: temp_temod.c:63