examples/benchmark/kernel-core_avr/hw/hw_thermo.h

Go to the documentation of this file.
00001 
00040 #ifndef HW_THERMO_H
00041 #define HW_THERMO_H
00042 
00043 #include "thermo_map.h"
00044 #include "ntc_map.h"
00045 
00046 #include <drv/phase.h>
00047 #include <drv/ntc.h>
00048 
00049 #include <cfg/debug.h>
00050 #include <cfg/compiler.h>
00051 
00052 #warning TODO:This is an example implentation, you must implement it!
00053 
00057 INLINE deg_t thermo_hw_tolerance(ThermoDev dev)
00058 {
00059     ASSERT(dev < THERMO_CNT);
00060 
00061     switch (dev)
00062     {
00063     case THERMO_TEST: 
00064         /* Put here convertion function to temperature size */
00065         break;
00066 
00067     /* Put here your thermo device */
00068 
00069     default:
00070         ASSERT(0);
00071     }
00072 
00073     return 0;
00074 }
00075 
00076 
00081 INLINE ticks_t thermo_hw_timeout(ThermoDev dev)
00082 {
00083     ASSERT(dev < THERMO_CNT);
00084 
00085     switch (dev)
00086     {
00087     case THERMO_TEST:
00088         /* return ms_to_ticks(60000); */
00089         break;
00090 
00091     /* Put here a time out for select thermo device */
00092 
00093     default:
00094         ASSERT(0);
00095     }
00096 
00097     return 0;
00098 }
00099 
00100 
00101 
00105 INLINE deg_t thermo_hw_read(ThermoDev dev)
00106 {
00107     return ntc_read(dev);
00108 }
00109 
00110 
00115 INLINE void thermo_hw_off(ThermoDev dev)
00116 {
00117     ASSERT(dev < THERMO_CNT);
00118 
00119     switch (dev)
00120     {
00121     case THERMO_TEST:
00122         phase_setPower(TRIAC_TEST, 0);
00123         break;
00124 
00125     /* Put here a thermo device to turn off */
00126 
00127     default:
00128         ASSERT(0);
00129     }
00130 
00131 }
00132 
00133 
00139 INLINE void thermo_hw_set(ThermoDev dev, deg_t target, deg_t cur_temp)
00140 {
00141     ASSERT(dev < THERMO_CNT);
00142 
00143     deg_t dist = target - cur_temp;
00144     //kprintf("dev[%d], dist[%d]\n", dev, dist);
00145 
00146     switch(dev)
00147     {
00148     case THERMO_TEST:
00149         if (dist > 0)
00150         {
00151             /*  phase_setPower(TRIAC_TEST, dist * PID_TEST_K); */
00152         }
00153         else
00154         {
00155             /* phase_setPower(TRIAC_TEST, 0); */
00156         }
00157         break;
00158 
00159     /* Put here an other thermo device */
00160 
00161     default:
00162         ASSERT(0);
00163     }
00164 }
00165 
00166 
00167 #define THERMO_HW_INIT  _thermo_hw_init()
00168 
00172 INLINE void _thermo_hw_init(void)
00173 {
00174     ASSERT(phase_initialized);
00175     ASSERT(ntc_initialized);
00176 
00177     phase_setPower(TRIAC_TEST, 0);
00178 
00179     /* Add here the other thermo device */
00180 }
00181 
00182 #endif /* HW_THERMO_H */