From 7f9a062b339c086b7a597e0c31b75068379e17c1 Mon Sep 17 00:00:00 2001 From: asterix Date: Tue, 28 Sep 2010 08:16:43 +0000 Subject: [PATCH] Add conversion formula for internal temperature sensor. Use macros istead BV. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4321 38d2e660-2303-0410-9eaa-f027e97ec537 --- boards/ek-lm3s1968/hw/hw_adc.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/boards/ek-lm3s1968/hw/hw_adc.h b/boards/ek-lm3s1968/hw/hw_adc.h index 902a8b47..53ba119f 100644 --- a/boards/ek-lm3s1968/hw/hw_adc.h +++ b/boards/ek-lm3s1968/hw/hw_adc.h @@ -49,14 +49,25 @@ INLINE uint16_t hw_readRawTemp(void) { /* Trig the temperature sampling */ - HWREG(ADC0_BASE + ADC_O_PSSI) = BV(3); + HWREG(ADC0_BASE + ADC_O_PSSI) |= ADC_PSSI_SS3; return (uint16_t)HWREG(ADC0_BASE + ADC_O_SSFIFO3); } -INLINE void hw_initIntTemp(void) +/* + * Return the cpu core temperature in degrees C*100 + */ +INLINE uint16_t hw_readIntTemp(void) { + /* Trig the temperature sampling */ + HWREG(ADC0_BASE + ADC_O_PSSI) |= ADC_PSSI_SS3; + return (uint16_t)(14750 - ADC_RANGECONV(HWREG(ADC0_BASE + ADC_O_SSFIFO3), 0, 300) * 75); +} + +INLINE void hw_initIntTemp(void) +{ + /* Enable ADC0 clock */ SYSCTL_RCGC0_R |= SYSCTL_RCGC0_ADC0; /* Why this??? */ @@ -67,9 +78,9 @@ INLINE void hw_initIntTemp(void) /* Set trigger event to programmed (for all sequence) */ HWREG(ADC0_BASE + ADC_O_EMUX) = 0; /* Enalbe read of temperature sensor */ - HWREG(ADC0_BASE + ADC_O_SSCTL3) = BV(3); + HWREG(ADC0_BASE + ADC_O_SSCTL3) |= ADC_SSCTL3_TS0; /* Enable sequence S03 (single sample on select channel) */ - HWREG(ADC0_BASE + ADC_O_ACTSS) = BV(3); + HWREG(ADC0_BASE + ADC_O_ACTSS) |= ADC_ACTSS_ASEN3; } #endif /* HW_ADC_H */ -- 2.25.1