add reboot 0x33

This commit is contained in:
pvvx 2024-01-31 23:06:37 +03:00
parent bba88d9ee5
commit 9c0c645ab0
11 changed files with 6628 additions and 6622 deletions

View file

@ -56,17 +56,9 @@ const cfg_t def_cfg = {
.averaging_measurements = 180 // 180*10 = 1800 sec, 30 min
};
/*
uint32_t get_delta_time_rtc(uint32_t start_time_rtc) {
uint32_t new_time_rtc = clock_time_rtc();
if(new_time_rtc < start_time_rtc)
new_time_rtc += 0x1000000; // + 512 sec
return new_time_rtc - start_time_rtc;
}
*/
void restore_utc_time_sec(void) {
if(clkt.utc_set_time_sec == 0) {
clkt.utc_time_add = AP_AON->SLEEP_R[2] + 10;
clkt.utc_time_add = (AP_AON->SLEEP_R[2] &((1<<15) - 1)) + 10;
clkt.utc_time_sec = AP_AON->SLEEP_R[3];
//if(clkt.utc_time_sec < 1704067200ul) clkt.utc_time_sec = 1704067200ul;
}
@ -74,8 +66,8 @@ void restore_utc_time_sec(void) {
}
uint32_t get_utc_time_sec(void) {
// HAL_ENTER_CRITICAL_SECTION();
uint32_t new_time_tik;
HAL_ENTER_CRITICAL_SECTION();
do {
new_time_tik = AP_AON->RTCCNT;
} while(new_time_tik != AP_AON->RTCCNT);
@ -88,7 +80,7 @@ uint32_t get_utc_time_sec(void) {
clkt.utc_time_add &= (1<<15) - 1;
AP_AON->SLEEP_R[2] = clkt.utc_time_add; // сохранить для восстановления часов после перезагрузки
AP_AON->SLEEP_R[3] = clkt.utc_time_sec; // сохранить для восстановления часов после перезагрузки
// HAL_EXIT_CRITICAL_SECTION();
HAL_EXIT_CRITICAL_SECTION();
#if (DEV_SERVICES & SERVICE_TIME_ADJUST)
// TODO
#endif

View file

@ -45,7 +45,7 @@
// supported services by the device (bits)
#define SERVICE_OTA 0x00000001 // есть функция OTA
#define SERVICE_OTA_EXT 0x00000002 // есть расширенная функция OTA
#define SERVICE_OTA_EXT 0x00000002 // пока нет: есть расширенная функция OTA
#define SERVICE_PINCODE 0x00000004 // пока нет: есть установка pin-code
#define SERVICE_BINDKEY 0x00000008 // пока нет: есть шифрование
#define SERVICE_HISTORY 0x00000010 // есть запись истории
@ -61,13 +61,17 @@
#define OTA_TYPE_NONE 0 // нет OTA, только переключение из APP на boot прошивку
#define OTA_TYPE_BOOT SERVICE_OTA // вариант для прошивки boot + OTA
#define OTA_TYPE_APP SERVICE_OTA_EXT // пока не реализовано
#define OTA_TYPE_APP OTA_TYPE_NONE
#ifndef OTA_TYPE
#define OTA_TYPE OTA_TYPE_NONE
#define OTA_TYPE OTA_TYPE_BOOT
#endif
#if OTA_TYPE == OTA_TYPE_BOOT
#define DEF_SOFTWARE_REVISION {'B', '0'+ (APP_VERSION >> 4), '.' , '0'+ (APP_VERSION & 0x0F), 0}
#else
#define DEF_SOFTWARE_REVISION {'V', '0'+ (APP_VERSION >> 4), '.' , '0'+ (APP_VERSION & 0x0F), 0}
#endif
#if DEVICE == DEVICE_THB2
/* Model: THB2 */
@ -214,7 +218,8 @@ extern adv_work_t adv_wrk;
#define OTA_MODE_SELECT_REG 0x4000f034
//#define OTA_MODE_SELECT_REG (AP_AON->RTCCC2) // [0x4000f034] == 0x55 -> OTA
#define BOOT_FLG_OTA 0x55
#define BOOT_FLG_OTA 0x55 // перезагрузка в FW Boot для OTA (ожидание соединения 80 сек)
#define BOOT_FLG_FW0 0x33 // перезагрузка в FW Boot
typedef struct _work_parm_t {
#if (DEV_SERVICES & SERVICE_SCREEN)

View file

@ -59,10 +59,12 @@ uint8_t display_out_buff[LCD_BUF_SIZE+1];
const uint8_t lcd_init_cmd[] = {
// LCD controller initialize:
//0xC8, // Mode Set (MODE SET): Display enable, 1/3 Bias
0xD8, // Mode Set (MODE SET): Display enable, 1/3 Bias, power saving
0xea, // Set IC Operation(ICSET): Software Reset, Internal oscillator circuit
0xC8, // Mode Set (MODE SET): Display enable, 1/3 Bias, power saving
0xbc, // Display control (DISCTL): Power save mode 3, FRAME flip, Power save mode 1
0x80, // load data pointer
0xF0, // blink control 0xf2
0xf0, // blink control 0xf2
0xfc, // All pixel control (APCTL): Normal
0x60,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};

View file

@ -319,17 +319,21 @@ int main(void) {
#endif
wrk.boot_flg = (uint8_t)read_reg(OTA_MODE_SELECT_REG);
#if defined(OTA_TYPE) && OTA_TYPE == OTA_TYPE_BOOT
if (wrk.boot_flg != BOOT_FLG_OTA
#if (DEV_SERVICES & SERVICE_KEY)
&& hal_gpio_read(GPIO_KEY)
if (hal_gpio_read(GPIO_KEY) == 0
|| wrk.boot_flg == BOOT_FLG_OTA
|| wrk.boot_flg == BOOT_FLG_FW0) {
#else
if (wrk.boot_flg == BOOT_FLG_OTA
|| wrk.boot_flg == BOOT_FLG_FW0) {
#endif
) {
write_reg(OTA_MODE_SELECT_REG,0);
} else { // boot FW OTA
spif_config(SYS_CLK_DLL_64M, 1, XFRD_FCMD_READ_DUAL, 0, 0);
AP_PCR->CACHE_BYPASS = 1; // just bypass cache
startup_app();
} else
write_reg(OTA_MODE_SELECT_REG,0);
#endif
}
#endif // OTA_TYPE == OTA_TYPE_BOOT
watchdog_config(WDG_2S);