add low power

This commit is contained in:
Steven Dan
2026-05-15 10:53:57 +08:00
parent b9303bccb8
commit 458978cb70
2 changed files with 28 additions and 2 deletions

View File

@@ -393,16 +393,18 @@ static int XUD_Manager_loop(XUD_chan epChans0[], XUD_chan epAddr_Ready[], chane
}
XUD_HAL_Mode_DataTransfer();
#ifndef LOW_POWER_EN
set_thread_fast_mode_on();
#endif
/* Run main IO loop */
/* flag0: Rx Error
flag1: Rx Active
flag2: Null / Valid Token */
noExit = XUD_LLD_IoLoop(p_usb_rxd, flag1_port, p_usb_txd, flag0_port, flag2_port, epTypeTableOut, epTypeTableIn, epAddr_Ready, noEpOut, c_sof);
#ifndef LOW_POWER_EN
set_thread_fast_mode_off();
#endif
if(!noExit)
break;

View File

@@ -0,0 +1,24 @@
#include <platform.h>
void power_down()
{
#if (LOW_POWER_EN == 1)
// Give the software 10 seconds to start up, then apply power optimisations below.
timer tmr;
int t;
tmr :> t;
tmr when timerafter(t+1000000000) :> void;
// Reduce switch clock frequency
// write_node_config_reg(tile[0], XS1_SSWITCH_CLK_DIVIDER_NUM, 4);
write_node_config_reg(tile[1], XS1_SSWITCH_CLK_DIVIDER_NUM, 4);
//
// // Reduce core 0 clock frequency (to 9 MHz)
// // Note, to completely disable, use:
// // write_tile_config_reg(tile[0], XS1_PSWITCH_PLL_CLK_DIVIDER_NUM, 0x80000000);
// write_tile_config_reg(tile[0], XS1_PSWITCH_PLL_CLK_DIVIDER_NUM, 0x00000040);
write_tile_config_reg(tile[1], XS1_PSWITCH_PLL_CLK_DIVIDER_NUM, 0x00000040);
setps(XS1_PS_XCORE_CTRL0, 0x10);
#endif
}