BeRTOS
hw_ntc.h
Go to the documentation of this file.
00001 
00090 #ifndef HW_NTC_H
00091 #define HW_NTC_H
00092 
00093 #include "ntc_map.h"
00094 
00095 #include <cfg/debug.h>
00096 
00097 #include <drv/ntc.h>
00098 #include <drv/adc.h>
00099 
00100 #warning TODO:This is an example implementation, you must implement it!
00101 
00102 extern const res_t      NTC_RSER[NTC_CNT];
00103 extern const res_t      NTC_RPAR[NTC_CNT];
00104 extern const amp_t      NTC_AMP[NTC_CNT];
00105 extern const NtcHwInfo* NTC_INFO[NTC_CNT];
00106 
00107 
00112 INLINE res_t ntc_hw_read(NtcDev dev)
00113 {
00114     ASSERT(dev < NTC_CNT);
00115     // See above for formula explanation.
00116     adcread_t adcval = adc_read((uint16_t)dev);
00117     float rp = (adcval * NTC_RSER[dev] ) / ((1 << adc_bits()) * NTC_AMP[dev] - adcval);
00118 
00119     //kprintf("Rp[%f], Rntc[%f]\n", rp/100, ((NTC_RPAR[dev] * rp) / (NTC_RPAR[dev] - rp)) / 100.0);
00120 
00121     return ( (NTC_RPAR[dev] * rp) / (NTC_RPAR[dev] - rp) );
00122 }
00123 
00124 
00128 INLINE const NtcHwInfo* ntc_hw_getInfo(NtcDev dev)
00129 {
00130     return NTC_INFO[dev];
00131 }
00132 
00133 #define NTC_HW_INIT do  { /* Implement me! */ } while(0)
00134 
00135 #endif /* HW_NTC_H */