From 56d6f07e5c87bf8745bb9548ae2227b39d083883 Mon Sep 17 00:00:00 2001 From: asterix Date: Wed, 7 Oct 2009 15:32:39 +0000 Subject: [PATCH] Add tmp123 sensor temperature driver. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3039 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/drv/tmp123.c | 72 +++++++++++++++++++++++++++++++++++++++++++ bertos/drv/tmp123.h | 56 +++++++++++++++++++++++++++++++++ bertos/hw/hw_tmp123.h | 52 +++++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 bertos/drv/tmp123.c create mode 100644 bertos/drv/tmp123.h create mode 100644 bertos/hw/hw_tmp123.h diff --git a/bertos/drv/tmp123.c b/bertos/drv/tmp123.c new file mode 100644 index 00000000..9fcc9165 --- /dev/null +++ b/bertos/drv/tmp123.c @@ -0,0 +1,72 @@ +/** + * \file + * + * + * \brief TMP123 Texas Intrument sensor temperature. + * + * \author Daniele Basile + * + */ + +#include "tmp123.h" + +#include "hw/hw_tmp123.h" + +#include + +#include + +#include + +/** + * Read temperature from TMP123 chip. + */ +deci_celsius_t tmp123_read(KFile *fd) +{ + int16_t tmp; + + CS_ENABLE(); + kfile_read(fd, &tmp, sizeof(tmp)); + tmp = be16_to_cpu(tmp); + CS_DISABLE(); + + tmp >>= 3; + return DIV_ROUND((tmp * 10), 16); +} +/** + * Init module + */ +void tmp123_init(void) +{ + TMP123_HW_INIT(); +} + + diff --git a/bertos/drv/tmp123.h b/bertos/drv/tmp123.h new file mode 100644 index 00000000..cb7b377c --- /dev/null +++ b/bertos/drv/tmp123.h @@ -0,0 +1,56 @@ +/** + * \file + * + * + * \brief TMP123 Texas Intrument sensor temperature. + * + * \author Daniele Basile + * + * $WIZ$ module_name = "tmp123" + * $WIZ$ module_depends = "timer", "kfile" + * $WIZ$ module_configuration = "" + * $WIZ$ module_hw = "bertos/hw/hw_tmp123.h" + */ + +#ifndef DRV_TMP123_H +#define DRV_TMP123_H + +#include + +#include + +typedef int16_t deci_celsius_t; + +deci_celsius_t tmp123_read(KFile *fd); + +void tmp123_init(void); + +#endif /* DRV_TMP123_H */ diff --git a/bertos/hw/hw_tmp123.h b/bertos/hw/hw_tmp123.h new file mode 100644 index 00000000..7da97e1f --- /dev/null +++ b/bertos/hw/hw_tmp123.h @@ -0,0 +1,52 @@ +/** + * \file + * + * + * \brief Hardware macro definition. + * + * \author Daniele Basile + */ + +#ifndef HW_TMP123_H +#define HW_TMP123_H + +#warning TODO:This is an example implentation, you must implement it! + +#define CS_ENABLE() /* Implement me! */ +#define CS_DISABLE() /* Implement me! */ + +#define TMP123_HW_INIT() \ + do { \ + /* Pin init */\ + } while (0) + +#endif /* HW_TMP123_H */ + -- 2.25.1