Skip to content

Commit 531f05b

Browse files
committed
Updated to make use of the new ioports API functionality.
1 parent 88ccdc5 commit 531f05b

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

main/driver.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,13 +1895,12 @@ IRAM_ATTR static void aux_irq_handler (uint8_t port, bool state)
18951895

18961896
static bool aux_claim_explicit (aux_ctrl_t *aux_ctrl)
18971897
{
1898-
if(ioport_claim(Port_Digital, Port_Input, &aux_ctrl->aux_port, NULL)) {
1899-
ioport_assign_function(aux_ctrl, &((input_signal_t *)aux_ctrl->input)->id);
1898+
xbar_t *pin;
1899+
1900+
if((pin = ioport_claim(Port_Digital, Port_Input, &aux_ctrl->aux_port, NULL))) {
1901+
ioport_set_function(pin, aux_ctrl->function, &aux_ctrl->cap);
19001902
#ifdef PROBE_PIN
19011903
if(aux_ctrl->function == Input_Probe) {
1902-
1903-
xbar_t *pin = hal.port.get_pin_info(Port_Digital, Port_Input, aux_ctrl->aux_port);
1904-
19051904
probe_port = aux_ctrl->aux_port;
19061905
hal.probe.get_state = probeGetState;
19071906
hal.probe.configure = probeConfigure;
@@ -1928,6 +1927,8 @@ static bool aux_claim_explicit (aux_ctrl_t *aux_ctrl)
19281927

19291928
bool aux_out_claim_explicit (aux_ctrl_out_t *aux_ctrl)
19301929
{
1930+
xbar_t *pin;
1931+
19311932
#ifdef USE_EXPANDERS
19321933
if(aux_ctrl->port == (void *)EXPANDER_PORT) {
19331934
if((iox_out[aux_ctrl->pin] = malloc(sizeof(xbar_t))))
@@ -1936,10 +1937,10 @@ bool aux_out_claim_explicit (aux_ctrl_out_t *aux_ctrl)
19361937
aux_ctrl->aux_port = 0xFF;
19371938
} else
19381939
#endif
1939-
if(ioport_claim(Port_Digital, Port_Output, &aux_ctrl->aux_port, NULL))
1940-
ioport_assign_out_function(aux_ctrl, &((output_signal_t *)aux_ctrl->output)->id);
1941-
else
1942-
aux_ctrl->aux_port = 0xFF;
1940+
if((pin = ioport_claim(Port_Digital, Port_Output, &aux_ctrl->aux_port, NULL)))
1941+
ioport_set_function(pin, aux_ctrl->function, NULL);
1942+
else
1943+
aux_ctrl->aux_port = 0xFF;
19431944

19441945
return aux_ctrl->aux_port != 0xFF;
19451946
}
@@ -3430,7 +3431,7 @@ bool driver_init (void)
34303431
#else
34313432
hal.info = "ESP32";
34323433
#endif
3433-
hal.driver_version = "250404";
3434+
hal.driver_version = "250412";
34343435
hal.driver_url = GRBL_URL "/ESP32";
34353436
#ifdef BOARD_NAME
34363437
hal.board = BOARD_NAME;

main/ioports.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,24 @@ static bool register_interrupt_handler (uint8_t port, uint8_t user_port, pin_irq
202202
return ok;
203203
}
204204

205+
static bool set_function (xbar_t *port, pin_function_t function)
206+
{
207+
if(port->mode.input)
208+
aux_in[port->id].id = function;
209+
else
210+
aux_out[port->id].id = function;
211+
212+
return true;
213+
}
214+
205215
static xbar_t *get_pin_info (io_port_direction_t dir, uint8_t port)
206216
{
207217
static xbar_t pin;
208218

209219
xbar_t *info = NULL;
210220

221+
pin.set_function = set_function;
222+
211223
if(dir == Port_Input && port < digital.in.n_ports) {
212224
XBAR_SET_DIN_INFO(pin, port, aux_in[pin.id], digital_in_cfg, digital_in_state);
213225
info = &pin;

main/ioports_analog.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,30 @@ static int32_t wait_on_input (io_port_type_t type, uint8_t port, wait_mode_t wai
305305

306306
#endif
307307

308+
static bool set_function (xbar_t *port, pin_function_t function)
309+
{
310+
if(port->mode.input)
311+
aux_in_analog[port->id].id = function;
312+
#if AUX_ANALOG_OUT
313+
else
314+
aux_out_analog[port->id].id = function;
315+
316+
return true;
317+
#else
318+
return !!port->mode.input;
319+
#endif
320+
}
321+
308322
static xbar_t *get_pin_info (io_port_direction_t dir, uint8_t port)
309323
{
310324
static xbar_t pin;
325+
311326
xbar_t *info = NULL;
312327

328+
memset(&pin, 0, sizeof(xbar_t));
329+
330+
pin.set_function = set_function;
331+
313332
switch(dir) {
314333

315334
case Port_Input:

0 commit comments

Comments
 (0)