paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [6301] Another temperature sensor


From: Martin Mueller
Subject: [paparazzi-commits] [6301] Another temperature sensor
Date: Thu, 28 Oct 2010 18:04:06 +0000

Revision: 6301
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6301
Author:   mmm
Date:     2010-10-28 18:04:05 +0000 (Thu, 28 Oct 2010)
Log Message:
-----------
Another temperature sensor

Added Paths:
-----------
    paparazzi3/trunk/conf/modules/temp_temod.xml
    paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.c
    paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.h

Added: paparazzi3/trunk/conf/modules/temp_temod.xml
===================================================================
--- paparazzi3/trunk/conf/modules/temp_temod.xml                                
(rev 0)
+++ paparazzi3/trunk/conf/modules/temp_temod.xml        2010-10-28 18:04:05 UTC 
(rev 6301)
@@ -0,0 +1,20 @@
+<!DOCTYPE module SYSTEM "module.dtd">
+
+<!--
+     Hygrosens TEMOD-I2C-Rx temperature sensor
+     @param SCP_I2C_DEV i2c device (default i2c0)
+     @param TEMOD_TYPE device type (default TEMOD_I2C_R1)
+     -->
+
+<module name="temp_temod" dir="meteo">
+  <header>
+    <file name="temp_temod.h"/>
+  </header>
+  <init fun="temod_init()"/>
+  <periodic fun="temod_periodic()" freq="8"/>
+  <event fun="temod_event()"/>
+  <makefile target="ap">
+    <file name="temp_temod.c"/>
+  </makefile>
+</module>
+

Added: paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.c                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.c     2010-10-28 
18:04:05 UTC (rev 6301)
@@ -0,0 +1,76 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 Martin Mueller
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+/** \file temp_temod.c
+ *  \brief Hygrosens TEMOD-I2C-Rx temperature sensor interface for PT1000
+ *         e.g. Heraeus PT 1000 M 222 KL. B 
+ */
+
+
+#include "temp_temod.h"
+#include "i2c.h"
+#include "led.h"
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+float ftmd_temperature;
+struct i2c_transaction tmd_trans;
+
+#ifndef TEMOD_I2C_DEV
+#define TEMOD_I2C_DEV i2c0
+#endif
+
+#ifndef TEMOD_TYPE
+#define TEMOD_TYPE TEMOD_I2C_R1
+#endif
+
+#define TEMOD_SLAVE_ADDR 0xF0
+
+
+void temod_init(void) {
+      tmd_trans.status = I2CTransDone;
+}
+
+void temod_periodic( void ) {
+    I2CReceive(TEMOD_I2C_DEV, tmd_trans, TEMOD_SLAVE_ADDR, 2);
+}
+
+void temod_event( void ) {
+
+  if (tmd_trans.status == I2CTransSuccess) {
+
+      uint16_t tmd_temperature;
+
+      /* read two byte temperature */
+      tmd_temperature  = tmd_trans.buf[0] << 8;
+      tmd_temperature |= tmd_trans.buf[1];
+
+      ftmd_temperature = (tmd_temperature / TEMOD_TYPE) - 32.;
+
+      DOWNLINK_SEND_TMP_STATUS(DefaultChannel, &tmd_temperature, 
&ftmd_temperature);
+      tmd_trans.status = I2CTransDone;
+  }
+}
+

Added: paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.h                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/temp_temod.h     2010-10-28 
18:04:05 UTC (rev 6301)
@@ -0,0 +1,16 @@
+#ifndef TEMP_TEMOD_H
+#define TEMP_TEMOD_H
+
+#include "std.h"
+
+#define TEMOD_I2C_R1    256.
+#define TEMOD_I2C_R2    128.
+#define TEMOD_I2C_R3    64.
+
+extern float ftmd_temperature;
+
+void temod_init(void);
+void temod_periodic(void);
+void temod_event(void);
+
+#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]