123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- #include "comdef.h"
- #include "OnBoard.h"
- #include "OSAL.h"
- #include "OSAL_Tasks.h"
- #include "OSAL_Timers.h"
- #include "OSAL_PwrMgr.h"
- pwrmgr_attribute_t pwrmgr_attribute;
- void osal_pwrmgr_init( void )
- {
- pwrmgr_attribute.pwrmgr_device = PWRMGR_ALWAYS_ON;
- pwrmgr_attribute.pwrmgr_task_state = 0;
- }
- void osal_pwrmgr_device( uint8 pwrmgr_device )
- {
- pwrmgr_attribute.pwrmgr_device = pwrmgr_device;
- }
- uint8 osal_pwrmgr_task_state( uint8 task_id, uint8 state )
- {
- if ( task_id >= tasksCnt )
- return ( INVALID_TASK );
- if ( state == PWRMGR_CONSERVE )
- {
-
- pwrmgr_attribute.pwrmgr_task_state &= ~(1 << task_id );
- }
- else
- {
-
- pwrmgr_attribute.pwrmgr_task_state |= (1 << task_id);
- }
- return ( SUCCESS );
- }
- #if defined( POWER_SAVING )
- void osal_pwrmgr_powerconserve( void )
- {
- uint16 next;
- halIntState_t intState;
-
- if ( pwrmgr_attribute.pwrmgr_device != PWRMGR_ALWAYS_ON )
- {
-
- if ( pwrmgr_attribute.pwrmgr_task_state == 0 )
- {
-
- HAL_ENTER_CRITICAL_SECTION( intState );
-
- next = osal_next_timeout();
-
- HAL_EXIT_CRITICAL_SECTION( intState );
-
- OSAL_SET_CPU_INTO_SLEEP( next );
- }
- }
- }
- #endif
|