From 444fbea2379c33a2590875092bb4b2e3595197f1 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Fri, 26 Jan 2024 11:24:17 +0100 Subject: [PATCH] Updated to use new method for registering single run tasks. Updated ioports code for improved core compliance. Fixed some inconsitencies. --- driver.json | 1 + main/boards/fysetc_e4_map.h | 2 +- main/boards/mks_tinybee_1_0_map.h | 2 +- main/driver.c | 12 ++++----- main/trinamic_if.c | 2 ++ main/wifi.c | 41 ++++++------------------------- 6 files changed, 19 insertions(+), 41 deletions(-) diff --git a/driver.json b/driver.json index 56f83fc..b8ded2d 100644 --- a/driver.json +++ b/driver.json @@ -83,6 +83,7 @@ "caps": { "axes": 3, "serial_ports": 2, + "safety_door": 0, "sdcard": 1, "probe": 1, "safety_door": 0, diff --git a/main/boards/fysetc_e4_map.h b/main/boards/fysetc_e4_map.h index a27ae6c..3336f87 100644 --- a/main/boards/fysetc_e4_map.h +++ b/main/boards/fysetc_e4_map.h @@ -19,7 +19,7 @@ along with Grbl. If not, see . */ -#if N_ABC_MOTORS > 0 +#if N_ABC_MOTORS > 1 #error "Axis configuration is not supported!" #endif diff --git a/main/boards/mks_tinybee_1_0_map.h b/main/boards/mks_tinybee_1_0_map.h index 027210a..db35c72 100644 --- a/main/boards/mks_tinybee_1_0_map.h +++ b/main/boards/mks_tinybee_1_0_map.h @@ -28,7 +28,7 @@ #define USE_I2S_OUT #define I2S_OUT_PIN_BASE 64 -#define SERIAL2_ENABLE 1 +//#define SERIAL2_ENABLE 1 #define UART2_RX_PIN GPIO_NUM_16 // EXP_1 #define UART2_TX_PIN GPIO_NUM_17 // EXP_1 diff --git a/main/driver.c b/main/driver.c index a74ce65..8c12542 100644 --- a/main/driver.c +++ b/main/driver.c @@ -1922,12 +1922,12 @@ static inline uint64_t getElapsedMicros (void) #if MPG_MODE == 1 -static void modeChange(sys_state_t state) +static void modeChange (void *data) { stream_mpg_enable(!DIGITAL_IN(MPG_ENABLE_PIN)); } -static void modeEnable (sys_state_t state) +static void modeEnable (void *data) { if(sys.mpg_mode == DIGITAL_IN(MPG_ENABLE_PIN)) stream_mpg_enable(true); @@ -3050,10 +3050,10 @@ bool driver_init (void) #if MPG_MODE == 1 #if KEYPAD_ENABLE == 2 if((hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL), MPG_STREAM_DUPLEX, keypad_enqueue_keycode))) - protocol_enqueue_rt_command(modeEnable); + protocol_enqueue_foreground_task(modeEnable, NULL); #else if((hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL), MPG_STREAM_DUPLEX, NULL))) - protocol_enqueue_rt_command(modeEnable); + protocol_enqueue_foreground_task(modeEnable, NULL); #endif #elif MPG_MODE == 2 hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL), 0, keypad_enqueue_keycode); @@ -3129,7 +3129,7 @@ IRAM_ATTR static void gpio_mpg_isr (void *signal) if(!mpg_mutex) { mpg_mutex = true; - protocol_enqueue_rt_command(modeChange); + protocol_enqueue_foreground_task(modeChange, NULL); mpg_mutex = false; } } @@ -3190,7 +3190,7 @@ IRAM_ATTR static void gpio_isr (void *arg) if((grp & PinGroup_MPG) && !mpg_mutex) { mpg_mutex = true; - protocol_enqueue_rt_command(modeChange); + protocol_enqueue_foreground_task(modeChange, NULL); mpg_mutex = false; } #endif diff --git a/main/trinamic_if.c b/main/trinamic_if.c index 834548b..e4422d8 100644 --- a/main/trinamic_if.c +++ b/main/trinamic_if.c @@ -263,6 +263,8 @@ void board_init (void) if((stream = stream_open_instance(TRINAMIC_STREAM, 230400, NULL)) == NULL) stream = stream_null_init(230400); + else + stream_set_description(stream, "Trinamic UART"); if(stream) { memcpy(&tmc_uart, stream, sizeof(io_stream_t)); diff --git a/main/wifi.c b/main/wifi.c index f46cde4..57d15b4 100644 --- a/main/wifi.c +++ b/main/wifi.c @@ -385,27 +385,7 @@ void wifi_ap_scan (void) xEventGroupSetBits(wifi_event_group, SCANNING_BIT); } -static void msg_ap_ready (sys_state_t state) -{ - hal.stream.write_all("[MSG:WIFI AP READY]" ASCII_EOL); -} - -static void msg_ap_connected (sys_state_t state) -{ - hal.stream.write_all("[MSG:WIFI AP CONNECTED]" ASCII_EOL); -} - -static void msg_ap_scan_completed (sys_state_t state) -{ - hal.stream.write_all("[MSG:WIFI AP SCAN COMPLETED]" ASCII_EOL); -} - -static void msg_ap_disconnected (sys_state_t state) -{ - hal.stream.write_all("[MSG:WIFI AP DISCONNECTED]" ASCII_EOL); -} - -static void msg_sta_active (sys_state_t state) +static void msg_sta_active (void *data) { char buf[50 + 45]; // + 45 due to compiler issue? @@ -414,11 +394,6 @@ static void msg_sta_active (sys_state_t state) hal.stream.write_all(buf); } -static void msg_sta_disconnected (sys_state_t state) -{ - hal.stream.write_all("[MSG:WIFI STA DISCONNECTED]" ASCII_EOL); -} - static void ip_event_handler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { switch(event_id) { @@ -440,7 +415,7 @@ static void ip_event_handler (void *arg, esp_event_base_t event_base, int32_t ev // commit to EEPROM? } else wifi_ap_scan(); - protocol_enqueue_rt_command(msg_sta_active); + protocol_enqueue_foreground_task(msg_sta_active, NULL); break; default: @@ -453,7 +428,7 @@ static void wifi_event_handler (void *arg, esp_event_base_t event_base, int32_t if(event_base == WIFI_EVENT) switch(event_id) { case WIFI_EVENT_AP_START: - protocol_enqueue_rt_command(msg_ap_ready); + protocol_enqueue_foreground_task(report_plain, "WIFI AP READY"); if(xEventGroupGetBits(wifi_event_group) & APSTA_BIT) { start_services(false); services.dns = dns_server_start(sta_netif); @@ -462,12 +437,12 @@ static void wifi_event_handler (void *arg, esp_event_base_t event_base, int32_t break; /*?? case WIFI_EVENT_AP_STOP: - protocol_enqueue_rt_command(msg_ap_disconnected); + protocol_enqueue_foreground_task(report_plain, "WIFI AP SCAN COMPLETED"); wifi_stop(); break; */ case WIFI_EVENT_AP_STACONNECTED: - protocol_enqueue_rt_command(msg_ap_connected); + protocol_enqueue_foreground_task(report_plain, "WIFI AP CONNECTED"); if(xEventGroupGetBits(wifi_event_group) & APSTA_BIT) { if(!(xEventGroupGetBits(wifi_event_group) & CONNECTED_BIT)) { /* // screws up dns? @@ -496,7 +471,7 @@ static void wifi_event_handler (void *arg, esp_event_base_t event_base, int32_t else if(!(xEventGroupGetBits(wifi_event_group) & CONNECTED_BIT)) ssdp_stop(); #endif - protocol_enqueue_rt_command(msg_ap_disconnected); + protocol_enqueue_foreground_task(report_plain, "WIFI AP DISCONNECTED"); break; case WIFI_EVENT_STA_START: @@ -512,7 +487,7 @@ static void wifi_event_handler (void *arg, esp_event_base_t event_base, int32_t #if WEBSOCKET_ENABLE websocketd_close_connections(); #endif - protocol_enqueue_rt_command(msg_sta_disconnected); + protocol_enqueue_foreground_task(report_plain, "WIFI STA DISCONNECTED"); memset(&wifi_sta_config, 0, sizeof(wifi_config_t)); esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_sta_config); if((xEventGroupGetBits(wifi_event_group) & APSTA_BIT) && !(xEventGroupGetBits(wifi_event_group) & CONNECTED_BIT)) { @@ -562,7 +537,7 @@ static void wifi_event_handler (void *arg, esp_event_base_t event_base, int32_t if((ap_list.ap_records = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * ap_list.ap_num)) != NULL) esp_wifi_scan_get_ap_records(&ap_list.ap_num, ap_list.ap_records); - protocol_enqueue_rt_command(msg_ap_scan_completed); + protocol_enqueue_foreground_task(report_plain, "WIFI AP SCAN COMPLETED"); xSemaphoreGive(aplist_mutex); }