From 458978cb70ac4d5a7dd54a2ea3ec4cbf7e2a1126 Mon Sep 17 00:00:00 2001 From: Steven Dan Date: Fri, 15 May 2026 10:53:57 +0800 Subject: [PATCH] add low power --- lib_xud/lib_xud/src/core/XUD_Main.xc | 6 +++-- .../src/extensions/power_down.xc | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/power_down.xc diff --git a/lib_xud/lib_xud/src/core/XUD_Main.xc b/lib_xud/lib_xud/src/core/XUD_Main.xc index 5709c77..939af3a 100644 --- a/lib_xud/lib_xud/src/core/XUD_Main.xc +++ b/lib_xud/lib_xud/src/core/XUD_Main.xc @@ -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; diff --git a/sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/power_down.xc b/sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/power_down.xc new file mode 100644 index 0000000..dfebeb2 --- /dev/null +++ b/sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/power_down.xc @@ -0,0 +1,24 @@ +#include + +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 +}