♻️ Move watchdog to MarlinHAL

This commit is contained in:
Scott Lahteine
2022-05-22 20:45:37 -05:00
parent 209c792ef7
commit 07cd248b91
64 changed files with 510 additions and 1106 deletions

View File

@ -74,7 +74,7 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8
LOOP_S_L_N(x, 1, sizex - 1) DrawMeshVLine(x);
LOOP_S_L_N(y, 1, sizey - 1) DrawMeshHLine(y);
LOOP_L_N(y, sizey) {
watchdog_refresh();
hal.watchdog_refresh();
LOOP_L_N(x, sizex) {
uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz));
uint8_t radius = rm(zmesh[x][y]);

View File

@ -402,7 +402,7 @@ void lv_gcode_file_read(uint8_t *data_buf) {
char temp_test[200];
volatile uint16_t *p_index;
watchdog_refresh();
hal.watchdog_refresh();
memset(public_buf, 0, 200);
while (card.isFileOpen()) {

View File

@ -104,7 +104,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
sync_plan_position();
// Raise Z as if it was homed
do_z_clearance(Z_POST_CLEARANCE);
watchdog_refresh();
hal.watchdog_refresh();
draw_return_ui();
return;
case ID_M_RETURN:
@ -117,7 +117,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
#else // Otherwise do a Z clearance move like after Homing
do_z_clearance(Z_POST_CLEARANCE);
#endif
watchdog_refresh();
hal.watchdog_refresh();
draw_return_ui();
return;
}

View File

@ -267,12 +267,12 @@ void spiFlashErase_PIC() {
W25QXX.init(SPI_QUARTER_SPEED);
// erase 0x001000 -64K
for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) {
watchdog_refresh();
hal.watchdog_refresh();
W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024);
}
// erase 64K -- 6M
for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) {
watchdog_refresh();
hal.watchdog_refresh();
W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024);
}
}
@ -282,7 +282,7 @@ void spiFlashErase_PIC() {
volatile uint32_t Font_sectorcnt = 0;
W25QXX.init(SPI_QUARTER_SPEED);
for (Font_sectorcnt = 0; Font_sectorcnt < 32 - 1; Font_sectorcnt++) {
watchdog_refresh();
hal.watchdog_refresh();
W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024);
}
}
@ -414,7 +414,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) {
return;
}
watchdog_refresh();
hal.watchdog_refresh();
disp_assets_update_progress(fn);
W25QXX.init(SPI_QUARTER_SPEED);
@ -427,21 +427,21 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) {
totalSizeLoaded += pfileSize;
if (assetType == ASSET_TYPE_LOGO) {
do {
watchdog_refresh();
hal.watchdog_refresh();
pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
Pic_Logo_Write((uint8_t*)fn, public_buf, pbr);
} while (pbr >= BMP_WRITE_BUF_LEN);
}
else if (assetType == ASSET_TYPE_TITLE_LOGO) {
do {
watchdog_refresh();
hal.watchdog_refresh();
pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
Pic_TitleLogo_Write((uint8_t*)fn, public_buf, pbr);
} while (pbr >= BMP_WRITE_BUF_LEN);
}
else if (assetType == ASSET_TYPE_G_PREVIEW) {
do {
watchdog_refresh();
hal.watchdog_refresh();
pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
default_view_Write(public_buf, pbr);
} while (pbr >= BMP_WRITE_BUF_LEN);
@ -451,7 +451,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) {
SPIFlash.beginWrite(Pic_Write_Addr);
#if HAS_SPI_FLASH_COMPRESSION
do {
watchdog_refresh();
hal.watchdog_refresh();
pbr = file.read(public_buf, SPI_FLASH_PageSize);
TERN_(MARLIN_DEV_MODE, totalSizes += pbr);
SPIFlash.writeData(public_buf, SPI_FLASH_PageSize);
@ -472,7 +472,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) {
else if (assetType == ASSET_TYPE_FONT) {
Pic_Write_Addr = UNIGBK_FLASH_ADDR;
do {
watchdog_refresh();
hal.watchdog_refresh();
pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr);
Pic_Write_Addr += pbr;
@ -493,11 +493,11 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) {
disp_assets_update();
disp_assets_update_progress(F("Erasing pics..."));
watchdog_refresh();
hal.watchdog_refresh();
spiFlashErase_PIC();
#if HAS_SPI_FLASH_FONT
disp_assets_update_progress(F("Erasing fonts..."));
watchdog_refresh();
hal.watchdog_refresh();
spiFlashErase_FONT();
#endif

View File

@ -125,13 +125,13 @@ void tft_lvgl_init() {
ui_cfg_init();
disp_language_init();
watchdog_refresh(); // LVGL init takes time
hal.watchdog_refresh(); // LVGL init takes time
// Init TFT first!
SPI_TFT.spi_init(SPI_FULL_SPEED);
SPI_TFT.LCD_init();
watchdog_refresh(); // LVGL init takes time
hal.watchdog_refresh(); // LVGL init takes time
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
uint16_t usb_flash_loop = 1000;
@ -142,21 +142,21 @@ void tft_lvgl_init() {
#endif
do {
card.media_driver_usbFlash.idle();
watchdog_refresh();
hal.watchdog_refresh();
delay(2);
} while (!card.media_driver_usbFlash.isInserted() && usb_flash_loop--);
card.mount();
#elif HAS_LOGO_IN_FLASH
delay(1000);
watchdog_refresh();
hal.watchdog_refresh();
delay(1000);
#endif
watchdog_refresh(); // LVGL init takes time
hal.watchdog_refresh(); // LVGL init takes time
#if ENABLED(SDSUPPORT)
UpdateAssets();
watchdog_refresh(); // LVGL init takes time
hal.watchdog_refresh(); // LVGL init takes time
TERN_(MKS_TEST, mks_test_get());
#endif

View File

@ -123,7 +123,7 @@ uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) {
void wifi_delay(int n) {
const uint32_t start = getWifiTick();
while (getWifiTickDiff(start, getWifiTick()) < (uint32_t)n)
watchdog_refresh();
hal.watchdog_refresh();
}
void wifi_reset() {
@ -1882,7 +1882,7 @@ void wifi_rcv_handle() {
void wifi_looping() {
do {
wifi_rcv_handle();
watchdog_refresh();
hal.watchdog_refresh();
} while (wifi_link_state == WIFI_TRANS_FILE);
}
@ -1897,7 +1897,7 @@ void mks_esp_wifi_init() {
esp_state = TRANSFER_IDLE;
esp_port_begin(1);
watchdog_refresh();
hal.watchdog_refresh();
wifi_reset();
#if 0
@ -1950,14 +1950,14 @@ void mks_esp_wifi_init() {
}
void mks_wifi_firmware_update() {
watchdog_refresh();
hal.watchdog_refresh();
card.openFileRead((char *)ESP_FIRMWARE_FILE);
if (card.isFileOpen()) {
card.closefile();
wifi_delay(2000);
watchdog_refresh();
hal.watchdog_refresh();
if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) return;
clear_cur_ui();
@ -1965,7 +1965,7 @@ void mks_wifi_firmware_update() {
lv_draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMWARE);
lv_task_handler();
watchdog_refresh();
hal.watchdog_refresh();
if (wifi_upload(0) >= 0) {
card.removeFile((char *)ESP_FIRMWARE_FILE_RENAME);

View File

@ -265,7 +265,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
EspUploadResult stat;
//IWDG_ReloadCounter();
watchdog_refresh();
hal.watchdog_refresh();
if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout)
return timeout;
@ -445,7 +445,7 @@ EspUploadResult Sync(uint16_t timeout) {
for (;;) {
size_t bodyLen;
EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout);
watchdog_refresh();
hal.watchdog_refresh();
if (rc != success || bodyLen != 2) break;
}
}
@ -673,7 +673,7 @@ int32_t wifi_upload(int type) {
while (esp_upload.state != upload_idle) {
upload_spin();
watchdog_refresh();
hal.watchdog_refresh();
}
ResetWiFiForUpload(1);