Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep Sleep WIP #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 12 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 Expand Up @@ -532,6 +532,8 @@ void bk_enter_deep_sleep_mode ( PS_DEEP_CTRL_PARAM *deep_param )

deep_param->sleep_time = 32768 * deep_param->sleep_time;
}

bk_misc_update_set_type(RESET_SOURCE_DEEPPS_GPIO);

GLOBAL_INT_DECLARATION();
GLOBAL_INT_DISABLE();
Expand Down