FreeCalypso > hg > tcs211-l1-reconst
comparison chipsetsw/layer1/cfile/l1_pwmgr.c @ 133:e6611ca0d054
l1_pwmgr.c: l1s_recover_HWTimers() reconstructed
| author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
|---|---|
| date | Sat, 14 May 2016 17:07:26 +0000 |
| parents | c721b9d301b9 |
| children | cedb53c5926d |
comparison
equal
deleted
inserted
replaced
| 132:c721b9d301b9 | 133:e6611ca0d054 |
|---|---|
| 1666 //------------------------------------------------- | 1666 //------------------------------------------------- |
| 1667 | 1667 |
| 1668 cntlreg = Dtimer1_Get_cntlreg(); | 1668 cntlreg = Dtimer1_Get_cntlreg(); |
| 1669 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN) | 1669 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN) |
| 1670 { | 1670 { |
| 1671 cntlreg = cntlreg&0x1F; | 1671 #if 0 /* match TCS211 object */ |
| 1672 cntlreg = cntlreg&0x1F; | |
| 1673 #endif | |
| 1672 cntlreg >>= 2; // take PTV | 1674 cntlreg >>= 2; // take PTV |
| 1673 cntlreg = 1 << (cntlreg+1); // compute 2^(PTV+1) | 1675 cntlreg = 1 << (cntlreg+1); // compute 2^(PTV+1) |
| 1674 // convert sleep duration in HWTimers ticks.... | 1676 // convert sleep duration in HWTimers ticks.... |
| 1675 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.0012308); | 1677 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.0012308); |
| 1676 if (duration < 0.0){ | 1678 #if 0 /* match TCS211 object */ |
| 1677 duration = 0.0; // This needs to be done for all the timers | 1679 if (duration < 0.0){ |
| 1678 } | 1680 duration = 0.0; // This needs to be done for all the timers |
| 1681 } | |
| 1682 #endif | |
| 1679 timer1 = Dtimer1_ReadValue() - (UWORD16) duration; | 1683 timer1 = Dtimer1_ReadValue() - (UWORD16) duration; |
| 1680 | 1684 |
| 1681 Dtimer1_Start(0); | 1685 Dtimer1_Start(0); |
| 1682 Dtimer1_WriteValue(timer1); | 1686 Dtimer1_WriteValue(timer1); |
| 1683 Dtimer1_Start(1); | 1687 Dtimer1_Start(1); |
| 1684 } | 1688 } |
| 1685 | 1689 |
| 1686 cntlreg = Dtimer2_Get_cntlreg(); | 1690 cntlreg = Dtimer2_Get_cntlreg(); |
| 1687 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN) | 1691 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN) |
| 1688 { | 1692 { |
| 1689 cntlreg = cntlreg&0x1F; | 1693 #if 0 /* match TCS211 object */ |
| 1694 cntlreg = cntlreg&0x1F; | |
| 1695 #endif | |
| 1690 cntlreg >>= 2; // take PTV | 1696 cntlreg >>= 2; // take PTV |
| 1691 cntlreg = 1 << (cntlreg+1); | 1697 cntlreg = 1 << (cntlreg+1); |
| 1692 // convert sleep duration in HWTimers ticks.... | 1698 // convert sleep duration in HWTimers ticks.... |
| 1693 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.0012308); | 1699 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.0012308); |
| 1694 if (duration < 0.0){ | 1700 #if 0 /* match TCS211 object */ |
| 1695 duration = 0.0; // This needs to be done for all the timers | 1701 if (duration < 0.0){ |
| 1696 } | 1702 duration = 0.0; // This needs to be done for all the timers |
| 1703 } | |
| 1704 #endif | |
| 1697 timer2 = Dtimer2_ReadValue() - (UWORD16) duration; | 1705 timer2 = Dtimer2_ReadValue() - (UWORD16) duration; |
| 1698 Dtimer2_Start(0); | 1706 Dtimer2_Start(0); |
| 1699 Dtimer2_WriteValue(timer2); | 1707 Dtimer2_WriteValue(timer2); |
| 1700 Dtimer2_Start(1); | 1708 Dtimer2_Start(1); |
| 1701 } | 1709 } |
