Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
temp_temod.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Martin Mueller
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
30 #include "mcu_periph/i2c.h"
31 #include "led.h"
32 #include "mcu_periph/uart.h"
33 #include "messages.h"
35 
38 
39 #ifndef DOWNLINK_DEVICE
40 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
41 #endif
42 
43 #ifndef TEMOD_I2C_DEV
44 #define TEMOD_I2C_DEV i2c0
45 #endif
46 
47 #ifndef TEMOD_TYPE
48 #define TEMOD_TYPE TEMOD_I2C_R1
49 #endif
50 
51 #define TEMOD_SLAVE_ADDR 0xF0
52 
53 void temod_init(void) {
55 }
56 
57 void temod_periodic( void ) {
59 }
60 
61 void temod_event( void ) {
62 
64 
65  uint16_t tmd_temperature;
66 
67  /* read two byte temperature */
68  tmd_temperature = tmd_trans.buf[0] << 8;
69  tmd_temperature |= tmd_trans.buf[1];
70 
71  ftmd_temperature = (tmd_temperature / TEMOD_TYPE) - 32.;
72 
73  DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &tmd_temperature, &ftmd_temperature);
75  }
76 }
77 
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void temod_periodic(void)
Definition: temp_temod.c:57
#define TEMOD_SLAVE_ADDR
Definition: temp_temod.c:51
#define TEMOD_I2C_DEV
Definition: temp_temod.c:44
void temod_init(void)
Definition: temp_temod.c:53
enum I2CTransactionStatus status
Definition: i2c.h:83
float ftmd_temperature
Definition: temp_temod.c:36
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:82
arch independent LED (Light Emitting Diodes) API
struct i2c_transaction tmd_trans
Definition: temp_temod.c:37
#define TEMOD_TYPE
Definition: temp_temod.c:48
void temod_event(void)
Definition: temp_temod.c:61
bool_t i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Definition: i2c.c:95
Architecture independent I2C (Inter-Integrated Circuit Bus) API.