Skip to content

Commit

Permalink
Deep Sleep WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Xmister committed Jun 15, 2023
1 parent 6491b8c commit 0a4097b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions beken378/driver/sys_ctrl/sys_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1709,15 +1709,15 @@ void sctrl_enter_rtos_idle_sleep(PS_DEEP_CTRL_PARAM deep_param)
reg = 0xFFFFFFFF;
REG_WRITE(SCTRL_GPIO_WAKEUP_INT_STATUS,reg);

if(deep_param.deep_wkway == PS_DEEP_WAKEUP_RTC
&& deep_param.param != 0xffffffff)
if(deep_param.wake_up_way == PS_DEEP_WAKEUP_RTC
&& deep_param.sleep_time != 0xffffffff)
{
reg = REG_READ(SCTRL_ROSC_TIMER);
reg |= ROSC_TIMER_INT_STATUS_BIT;
REG_WRITE(SCTRL_ROSC_TIMER,reg);
reg = REG_READ(SCTRL_ROSC_TIMER);
reg &= ~(ROSC_TIMER_PERIOD_MASK << ROSC_TIMER_PERIOD_POSI);
reg |= (deep_param.param << ROSC_TIMER_PERIOD_POSI);
reg |= (deep_param.sleep_time << ROSC_TIMER_PERIOD_POSI);
REG_WRITE(SCTRL_ROSC_TIMER,reg);
reg = REG_READ(SCTRL_ROSC_TIMER);
reg |= ROSC_TIMER_ENABLE_BIT;
Expand All @@ -1733,13 +1733,13 @@ void sctrl_enter_rtos_idle_sleep(PS_DEEP_CTRL_PARAM deep_param)
reg |= (0x1 << 8);
REG_WRITE(SCTRL_BLOCK_EN_MUX, reg);
}
else if(deep_param.deep_wkway == PS_DEEP_WAKEUP_GPIO)
else if(deep_param.wake_up_way == PS_DEEP_WAKEUP_GPIO)
{
reg = 0xFFFFFFFF;
REG_WRITE(SCTRL_GPIO_WAKEUP_INT_STATUS,reg);
reg = deep_param.gpio_lv;
reg = deep_param.gpio_edge_map;
REG_WRITE(SCTRL_GPIO_WAKEUP_TYPE,reg);
reg = deep_param.param;
reg = deep_param.gpio_index_map;
REG_WRITE(SCTRL_GPIO_WAKEUP_EN,reg);

}
Expand Down
2 changes: 1 addition & 1 deletion beken378/func/include/manual_ps_pub.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typedef enum {
MANUAL_MODE_IDLE = 1,
} MANUAL_MODE;

#define PS_SUPPORT_MANUAL_SLEEP 0
#define PS_SUPPORT_MANUAL_SLEEP 1
typedef void ( *ps_wakeup_cb ) ( void );
extern void deep_sleep_wakeup_with_gpio ( UINT32 gpio_index_map, UINT32 gpio_edge_map );
extern void bk_enter_deep_sleep_mode ( PS_DEEP_CTRL_PARAM *deep_param );
Expand Down
20 changes: 10 additions & 10 deletions beken378/func/power_save/manual_ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,21 @@ void idle_sleep_wakeup_with_timer ( UINT32 sleep_time )

if ( sleep_time != 0xffffffff ) {
os_printf ( "idle sleep with rtc,%d ms\r\n", sleep_time );
deep_param.param = ( ( sleep_time * 102400 ) / 3125 ) ;
deep_param.sleep_time = ( ( sleep_time * 102400 ) / 3125 ) ;

if ( deep_param.param > 0xffff ) //only 16 bit
deep_param.param = 0xffff;
else if ( deep_param.param < 32 )
deep_param.param = 32;
if ( deep_param.sleep_time > 0xffff ) //only 16 bit
deep_param.sleep_time = 0xffff;
else if ( deep_param.sleep_time < 32 )
deep_param.sleep_time = 32;
}
else {
os_printf ( "idle sleep forever\r\n" );
deep_param.param = 0xffffffff;
deep_param.sleep_time = 0xffffffff;
}

param = LPO_SELECT_ROSC;
sddev_control ( SCTRL_DEV_NAME, CMD_SCTRL_SET_LOW_PWR_CLK, &param );
deep_param.deep_wkway = PS_DEEP_WAKEUP_RTC;
deep_param.wake_up_way = PS_DEEP_WAKEUP_RTC;
os_printf ( "enter rtc ps\r\n" );
GLOBAL_INT_DECLARATION();
GLOBAL_INT_DISABLE();
Expand Down Expand Up @@ -241,9 +241,9 @@ void idle_sleep_wakeup_with_gpio ( UINT32 gpio_index_map, UINT32 gpio_edge_map )
ps_pwm0_disable();
uart_wait_tx_over();
wifi_mac_state_set_idle();
deep_param.deep_wkway = PS_DEEP_WAKEUP_GPIO;
deep_param.param = gpio_index_map;
deep_param.gpio_lv = gpio_edge_map;
deep_param.wake_up_way = PS_DEEP_WAKEUP_GPIO;
deep_param.gpio_index_map = gpio_index_map;
deep_param.gpio_edge_map = gpio_edge_map;
sddev_control ( SCTRL_DEV_NAME, CMD_SCTRL_RTOS_IDLE_SLEEP, &deep_param );
delay ( 5 );
sddev_control ( SCTRL_DEV_NAME, CMD_SCTRL_RTOS_IDLE_WAKEUP, 0 );
Expand Down

0 comments on commit 0a4097b

Please sign in to comment.