correct INITIAL_STACK_PTR

This commit is contained in:
pvvx 2024-01-12 00:58:29 +03:00
parent 409461232d
commit c0f85786ad
8 changed files with 2821 additions and 2898 deletions

View file

@ -5,7 +5,7 @@ Custom firmware for Tuya [THB2](https://pvvx.github.io/THB2).
В плане проекта предусматривается дальнейшая поддержка BTH01 и [TH-05](https://pvvx.github.io/TH-05).
Прошивка V0.3 для THB2 (файл TestTHB2.hex). Всё, кроме OTA работает стабильно.
Прошивка V0.4 для THB2 (файл TestTHB2.hex). Всё, кроме OTA работает стабильно.
## Основные характеристики:

File diff suppressed because it is too large Load diff

View file

@ -301,11 +301,11 @@ void peripheral_interrupt_restore_default(void)
int __attribute__((used)) hal_pwrmgr_wakeup_process(void)
{
int i;
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
extern void spif_release_deep_sleep(void);
spif_release_deep_sleep();
WaitRTCCount(8);
#endif
#endif
AP_PCR->SW_CLK = s_config_swClk0;
AP_PCR->SW_CLK1 = s_config_swClk1|0x01;//force set M0 CPU
s_gpio_wakeup_src_group1 = AP_AON->GPIO_WAKEUP_SRC[0];

View file

@ -455,6 +455,7 @@ void wakeupProcess0(void)
// uart_tx0(" 111 ");
ll_debug_output(DEBUG_WAKEUP);
set_sleep_flag(0);
// ==== measure value, from RTC counter meet comparator 0 -> here : 260us ~ 270us
// start task loop
osal_start_system();

View file

@ -5445,16 +5445,16 @@ void wakeup_init1()
// < 14>:en_dig_clk_48M;
// < 15>:en_dig_clk_64M;
// < 16>:en_dig_clk_96M;
#if (DBG_BUILD_LL_TIMING)
#if (DBG_BUILD_LL_TIMING)
//====== for timing debug============
gpio_write(DBG_PIN_SYS_CLK_SWITCH, 1);
gpio_write(DBG_PIN_SYS_CLK_SWITCH, 0);
//PHY_REG_WT(AP_IOMUX_BASE+8,1);//en debugMux[0]
#endif
#endif
//each rtc count is about 30.5us
//after 15count , xtal will be feedout to dll and doubler
//WaitRTCCount(pGlobal_config[WAKEUP_DELAY]);
#if 0
#if 0
volatile uint32_t delay=0;
for(uint8_t i=0; i<10; i++)
@ -5465,7 +5465,7 @@ void wakeup_init1()
while(delay -- > 0) {};
}
#endif
#endif
if(g_system_clk == SYS_CLK_XTAL_16M )
{
@ -5550,14 +5550,14 @@ void wakeup_init1()
set_max_length(0xff);
ll_hw_set_empty_head(0x0001);
//time related setting
ll_hw_set_rx_timeout_1st( 500);
ll_hw_set_rx_timeout( 88); //ZQ 20180606, reduce rx timeout for power saving
ll_hw_set_rx_timeout_1st(500);
ll_hw_set_rx_timeout(88); //ZQ 20180606, reduce rx timeout for power saving
//preamble + syncword=40us, sync process = 8us
//timeout should be larger then 48us,
//ll_hw_set_rx_timeout( 268); //for ble shoulde be larger than 80+128. if sync, the timeout timer stop.
// (80 + 128) - BLE 5.0 preamble + access time, 60 for HW process delay
// this time doesn't consider HW startup time, it is set in other regs
ll_hw_set_loop_timeout( 30000);
ll_hw_set_loop_timeout(30000);
// ll_hw_set_tx_rx_release (10, 1);
// ll_hw_set_rx_tx_interval( 57); //T_IFS=150us for BLE 1M
// ll_hw_set_tx_rx_interval( 65); //T_IFS=150us for BLE 1M
@ -5615,10 +5615,10 @@ void config_RTC1(uint32 time)
}
}
#if 0
#if 0
extern uint32 sleep_total;
LOG("%d %d %d\n",conn_param[0].currentEvent,sleep_total,counter_tracking);
#endif
#endif
}
#if 1
@ -5821,6 +5821,8 @@ void wakeupProcess1(void)
// start task loop
osal_start_system();
}
void enter_sleep_off_mode1(Sleep_Mode mode)
{
if(mode==SYSTEM_SLEEP_MODE)
@ -7651,7 +7653,7 @@ __ATTR_SECTION_XIP__ void init_config(void)
pGlobal_config[i] = 0;
//save the app initial_sp which will be used in wakeupProcess 20180706 by ZQ
pGlobal_config[INITIAL_STACK_PTR] = (uint32_t)&g_top_irqstack;
// pGlobal_config[INITIAL_STACK_PTR] = 0x400 + (uint32_t)&_ebss; // g_top_irqstack;
// LL switch setting
pGlobal_config[LL_SWITCH] = LL_DEBUG_ALLOW | SLAVE_LATENCY_ALLOW | LL_WHITELIST_ALLOW
| SIMUL_CONN_ADV_ALLOW | SIMUL_CONN_SCAN_ALLOW; //RC32_TRACKINK_ALLOW

View file

@ -65,7 +65,7 @@ SECTIONS
_ebss = ABSOLUTE(.);
} > sram
/*
/*
.int_stack : {
. = ALIGN(4);
*(int_stack)
@ -73,7 +73,7 @@ SECTIONS
_stack_top = ABSOLUTE(.);
} > sram
*/
/* stack 32 kbytes */
g_top_irqstack = ORIGIN(sram) + LENGTH(sram);
.common_text : {

View file

@ -5,6 +5,7 @@
#include "bus_dev.h"
#include "gpio.h"
#include "clock.h"
#include "global_config.h"
#include "timer.h"
#include "jump_function.h"
#include "pwrmgr.h"
@ -152,10 +153,19 @@ static void hal_low_power_io_init(void) {
DIG_LDO_CURRENT_SETTING(0x01);
#if defined ( __GNUC__ )
extern int _ebss;
if ((uint32_t) &_ebss >= 0x1fff8000)
/*
if ((uint32_t) &_ebss >= (0x20000000 - 0x400)) { // - INITIAL_STACK 1kbytes
hal_pwrmgr_RAM_retention(RET_SRAM0 | RET_SRAM1 | RET_SRAM2); // RET_SRAM0|RET_SRAM1|RET_SRAM2
pGlobal_config[INITIAL_STACK_PTR] = 0x20000000;
} else
*/
if ((uint32_t) &_ebss >= (0x1fff8000 - 0x400)) { // - INITIAL_STACK 1kbytes
hal_pwrmgr_RAM_retention(RET_SRAM0 | RET_SRAM1); // RET_SRAM0|RET_SRAM1|RET_SRAM2
else
pGlobal_config[INITIAL_STACK_PTR] = 0x1fffC000;
} else {
hal_pwrmgr_RAM_retention(RET_SRAM0); // RET_SRAM0|RET_SRAM1|RET_SRAM2
pGlobal_config[INITIAL_STACK_PTR] = 0x1fff8000;
}
#else
#if DEBUG_INFO || SDK_VER_RELEASE_ID != 0x03010102

View file

@ -151,7 +151,7 @@ __ATTR_SECTION_XIP__ void init_sensor(void) {
send_i2c_byte(0, 0x06); // Reset command using the general call address
WaitMs(3);
send_i2c_wreg(CHT8310_I2C_ADDR0, CHT8310_REG_CRT, 0x0300); // Set conversion ratio 5 sec
WaitMs(1);
//WaitMs(1);
read_i2c_bytes(CHT8310_I2C_ADDR0, CHT8310_REG_ID, (uint8 *)&th_sensor_id, 2);
deinit_i2c();
}