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_lm75.c
Go to the documentation of this file.
1 /*
2  * $Id: temp_lm75.c $
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 
33 
34 #include "mcu_periph/i2c.h"
35 #include "led.h"
36 #include "mcu_periph/uart.h"
37 #include "messages.h"
39 
40 #ifndef DOWNLINK_DEVICE
41 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
42 #endif
43 
46 
47 #ifndef LM75_I2C_DEV
48 #define LM75_I2C_DEV i2c0
49 #endif
50 
51 /* address can be set through A0..A2, starting at 0x90 */
52 
53 #ifndef LM75_SLAVE_ADDR
54 #define LM75_SLAVE_ADDR 0x90
55 #endif
56 
57 void lm75_init(void) {
59 }
60 
61 void lm75_periodic( void ) {
64 }
65 
66 void lm75_event( void ) {
68  uint16_t lm75_temperature;
69  float flm75_temperature;
70 
71  /* read two byte temperature */
72  lm75_temperature = lm75_trans.buf[0] << 8;
73  lm75_temperature |= lm75_trans.buf[1];
74  lm75_temperature >>= 7;
75  if (lm75_temperature & 0x0100)
76  lm75_temperature |= 0xFE00;
77 
78  flm75_temperature = ((int16_t) lm75_temperature) / 2.;
79 
80  DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &lm75_temperature, &flm75_temperature);
82  }
83 }
uint8_t lm75_meas_started
Definition: temp_lm75.c:44
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
struct i2c_transaction lm75_trans
Definition: temp_lm75.c:45
void lm75_init(void)
Definition: temp_lm75.c:57
void lm75_event(void)
Definition: temp_lm75.c:66
#define LM75_I2C_DEV
Definition: temp_lm75.c:48
signed short int16_t
Definition: types.h:17
enum I2CTransactionStatus status
Definition: i2c.h:47
#define LM75_TEMP_REG
Definition: temp_lm75.h:6
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:46
unsigned char uint8_t
Definition: types.h:14
#define I2CTransceive(_p, _t, _s_addr, _len_w, _len_r)
Definition: i2c.h:156
#define LM75_SLAVE_ADDR
Definition: temp_lm75.c:54
arch independent LED (Light Emitting Diodes) API
void lm75_periodic(void)
Definition: temp_lm75.c:61