Skip to content

Commit

Permalink
Updated to use new method for registering single run tasks.
Browse files Browse the repository at this point in the history
Updated ioports code for improved core compliance.
Fixed some inconsitencies.
  • Loading branch information
terjeio committed Jan 26, 2024
1 parent 3e91174 commit 444fbea
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 41 deletions.
1 change: 1 addition & 0 deletions driver.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"caps": {
"axes": 3,
"serial_ports": 2,
"safety_door": 0,
"sdcard": 1,
"probe": 1,
"safety_door": 0,
Expand Down
2 changes: 1 addition & 1 deletion main/boards/fysetc_e4_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/

#if N_ABC_MOTORS > 0
#if N_ABC_MOTORS > 1
#error "Axis configuration is not supported!"
#endif

Expand Down
2 changes: 1 addition & 1 deletion main/boards/mks_tinybee_1_0_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions main/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions main/trinamic_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
41 changes: 8 additions & 33 deletions main/wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -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) {
Expand All @@ -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:
Expand All @@ -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);
Expand All @@ -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?
Expand Down Expand Up @@ -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:
Expand All @@ -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)) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 444fbea

Please sign in to comment.