From 03b9fa23fa8d7c7a49f817cd2108ab47b3afe7ec Mon Sep 17 00:00:00 2001 From: asterix Date: Mon, 27 Sep 2010 17:20:33 +0000 Subject: [PATCH] Add stand alone module for read internal sensor temperature for ek-lm3s1968 board. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4317 38d2e660-2303-0410-9eaa-f027e97ec537 --- boards/ek-lm3s1968/hw/hw_adc.h | 77 ++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 boards/ek-lm3s1968/hw/hw_adc.h diff --git a/boards/ek-lm3s1968/hw/hw_adc.h b/boards/ek-lm3s1968/hw/hw_adc.h new file mode 100644 index 00000000..9730ed98 --- /dev/null +++ b/boards/ek-lm3s1968/hw/hw_adc.h @@ -0,0 +1,77 @@ +/** + * \file + * + * + * \brief Some ADC utilis. + * + * \author Daniele Basile + */ + +#ifndef HW_ADC_H +#define HW_ADC_H + +#include +#include + +#include + +/* + * Return the cpu core temperature in raw format + */ +INLINE uint16_t hw_readRawTemp(void) +{ + /* Trig the temperature sampling */ + HWREG(ADC0_BASE + ADC_O_PSSI) = BV(3); + + return (uint16_t)HWREG(ADC0_BASE + ADC_O_SSFIFO3); +} + +INLINE void hw_initIntTemp(void) +{ + + SYSCTL_RCGC0_R |= SYSCTL_RCGC0_ADC0; + + /* Why this??? */ + timer_udelay(1); + + /* Disable all sequence */ + HWREG(ADC0_BASE + ADC_O_ACTSS) = 0; + /* Set trigger event to programmed (for all sequence) */ + HWREG(ADC0_BASE + ADC_O_EMUX) = 0; + + HWREG(ADC0_BASE + ADC_O_SSMUX3) = 1; + /* Enalbe read of temperature sensor */ + HWREG(ADC0_BASE + ADC_O_SSCTL3) = BV(3); + /* Enable sequence S03 (single sample on select channel) */ + HWREG(ADC0_BASE + ADC_O_ACTSS) = BV(3); +} + +#endif /* HW_ADC_H */ -- 2.25.1