Added wrappers/veneers for hal.port functions, plugin code should be changed to use

these instead of calling via hal.port functions or accessing hal.port properties.
Improved the ioports API, updated core code to make use of it.
Flagged some calls and (part of) some stuctures as deprecated.
This commit is contained in:
Terje Io
2025-04-13 20:54:09 +02:00
parent d51de9d98f
commit e1ea957ca4
13 changed files with 440 additions and 153 deletions

View File

@@ -1,6 +1,6 @@
## grblHAL ##
Latest build date is 20250405, see the [changelog](changelog.md) for details.
Latest build date is 20250413, see the [changelog](changelog.md) for details.
> [!NOTE]
> A settings reset will be performed on an update of builds prior to 20241208. Backup and restore of settings is recommended.
@@ -89,4 +89,4 @@ G/M-codes not supported by [legacy Grbl](https://github.com/gnea/grbl/wiki) are
Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes.
---
20250328
20250413

View File

@@ -1,5 +1,26 @@
## grblHAL changelog
<a name="20250413">20250413
Core:
* For developers: added wrappers/veneers for `hal.port` functions, plugin code should be changed to use these instead of calling via `hal.port` functions or accessing `hal.port` properties.
Improved the [ioports API](https://svn.io-engineering.com/grblHAL/html/ioports_8c.html), updated core code to make use of it. Flagged some calls and (part of) some stuctures as deprecated.
Drivers:
* Most: updated to make use of the new ioports API functionality.
* Some: removed references to deleted odometer include. Ref. odometer issue [#2](https://github.com/grblHAL/Plugin_odometer/issues/2).
Plugins:
* Fans: fixed bug preventing selection of ports to use. Possibly related to issue [#242 comment](https://github.com/grblHAL/core/issues/242#issuecomment-2798816316).
* Many: updated to make use of the new ioports API functionality.
---
<a name="20250411">20250411
Core:

View File

@@ -58,17 +58,20 @@ typedef enum {
Input_MPGSelect,
Input_ModeSelect = Input_MPGSelect, // Deprecated
Input_LimitX,
Input_LimitX_2,
Input_LimitX2,
Input_LimitX_2 = Input_LimitX2, // Deprecated
Input_LimitX_Max,
Input_HomeX,
Input_HomeX_2,
Input_LimitY,
Input_LimitY_2,
Input_LimitY2,
Input_LimitY_2 = Input_LimitY2, // Deprecated
Input_LimitY_Max,
Input_HomeY,
Input_HomeY_2,
Input_LimitZ,
Input_LimitZ_2,
Input_LimitZ2,
Input_LimitZ_2 = Input_LimitZ2, // Deprecated
Input_LimitZ_Max,
Input_HomeZ,
Input_HomeZ_2,
@@ -126,22 +129,28 @@ typedef enum {
// Output pins
Output_StepX,
Outputs = Output_StepX,
Output_StepX_2,
Output_StepX2,
Output_StepX_2 = Output_StepX2, // deprecated
Output_StepY,
Output_StepY_2,
Output_StepY2,
Output_StepY_2 = Output_StepY2, // deprecated
Output_StepZ,
Output_StepZ_2,
Output_StepZ2,
Output_StepZ_2 = Output_StepZ2, // deprecated
Output_StepA,
Output_StepB,
Output_StepC,
Output_StepU,
Output_StepV,
Output_DirX,
Output_DirX_2,
Output_DirX2,
Output_DirX_2 = Output_DirX2, // deprecated
Output_DirY,
Output_DirY_2,
Output_DirY2,
Output_DirY_2 = Output_DirY2, // deprecated
Output_DirZ,
Output_DirZ_2,
Output_DirZ2,
Output_DirZ_2 = Output_DirZ2, // deprecated
Output_DirA,
Output_DirB,
Output_DirC,
@@ -158,9 +167,13 @@ typedef enum {
Output_MotorChipSelectM7,
Output_StepperPower,
Output_StepperEnable,
Output_StepperEnableSTEPPERS = Output_StepperEnable,
Output_StepperEnableX,
Output_StepperEnableX2 = Output_StepperEnableX,
Output_StepperEnableY,
Output_StepperEnableY2 = Output_StepperEnableY,
Output_StepperEnableZ,
Output_StepperEnableZ2 = Output_StepperEnableZ,
Output_StepperEnableA,
Output_StepperEnableB,
Output_StepperEnableU,
@@ -342,17 +355,17 @@ PROGMEM static const pin_name_t pin_names[] = {
{ .function = Input_Analog_Aux7, .name = "Aux analog in 7" },
#endif
{ .function = Output_StepX, .name = "X step" },
{ .function = Output_StepX_2, .name = "X2 step" },
{ .function = Output_StepX2, .name = "X2 step" },
{ .function = Output_StepY, .name = "Y step" },
{ .function = Output_StepY_2, .name = "Y2 step" },
{ .function = Output_StepY2, .name = "Y2 step" },
{ .function = Output_StepZ, .name = "Z step" },
{ .function = Output_StepZ_2, .name = "Z2 step" },
{ .function = Output_StepZ2, .name = "Z2 step" },
{ .function = Output_DirX, .name = "X dir" },
{ .function = Output_DirX_2, .name = "X2 dir" },
{ .function = Output_DirX2, .name = "X2 dir" },
{ .function = Output_DirY, .name = "Y dir" },
{ .function = Output_DirY_2, .name = "Y2 dir" },
{ .function = Output_DirY2, .name = "Y2 dir" },
{ .function = Output_DirZ, .name = "Z dir" },
{ .function = Output_DirZ_2, .name = "Z2 dir" },
{ .function = Output_DirZ2, .name = "Z2 dir" },
{ .function = Output_StepperPower, .name = "Stepper power" },
{ .function = Output_StepperEnable, .name = "Steppers enable" },
{ .function = Output_StepperEnableX, .name = "X enable" },
@@ -726,6 +739,7 @@ typedef struct {
} aux_ctrl_out_t;
typedef struct xbar {
void *ports_id;
uint8_t id; //!< Pin id.
pin_function_t function; //!< Pin function.
pin_group_t group; //!< Pin group.

View File

@@ -61,6 +61,124 @@
#define FLASH_ENABLE 0
#endif
// Expand port shorthand names
#ifdef ENABLE_PORT
#ifdef STEPPERS_ENABLE_PIN
#ifndef STEPPERS_ENABLE_PORT
#define STEPPERS_ENABLE_PORT ENABLE_PORT
#endif
#else
#ifdef XY_ENABLE_PIN
#ifndef XY_ENABLE_PORT
#define XY_ENABLE_PORT ENABLE_PORT
#endif
#else
#ifndef X_ENABLE_PORT
#define X_ENABLE_PORT ENABLE_PORT
#endif
#ifndef Y_ENABLE_PORT
#define Y_ENABLE_PORT ENABLE_PORT
#endif
#endif
#ifndef Z_ENABLE_PORT
#define Z_ENABLE_PORT ENABLE_PORT
#endif
#if defined(M3_ENABLE_PIN) && !defined(M3_ENABLE_PORT)
#define M3_ENABLE_PORT ENABLE_PORT
#endif
#if defined(M4_ENABLE_PIN) && !defined(M4_ENABLE_PORT)
#define M4_ENABLE_PORT ENABLE_PORT
#endif
#if defined(M5_ENABLE_PIN) && !defined(M5_ENABLE_PORT)
#define M5_ENABLE_PORT ENABLE_PORT
#endif
#if defined(M6_ENABLE_PIN) && !defined(M6_ENABLE_PORT)
#define M6_ENABLE_PORT ENABLE_PORT
#endif
#if defined(M7_ENABLE_PIN) && !defined(M7_ENABLE_PORT)
#define M7_ENABLE_PORT ENABLE_PORT
#endif
#endif
#endif // ENABLE_PORT
#ifdef STEP_PORT
#ifndef X_STEP_PORT
#define X_STEP_PORT STEP_PORT
#endif
#ifndef Y_STEP_PORT
#define Y_STEP_PORT STEP_PORT
#endif
#ifndef Z_STEP_PORT
#define Z_STEP_PORT STEP_PORT
#endif
#if defined(M3_STEP_PIN) && !defined(M3_STEP_PORT)
#define M3_STEP_PORT STEP_PORT
#endif
#if defined(M4_STEP_PIN) && !defined(M4_STEP_PORT)
#define M4_STEP_PORT STEP_PORT
#endif
#if defined(M5_STEP_PIN) && !defined(M5_STEP_PORT)
#define M5_STEP_PORT STEP_PORT
#endif
#if defined(M6_STEP_PIN) && !defined(M6_STEP_PORT)
#define M6_STEP_PORT STEP_PORT
#endif
#if defined(M7_STEP_PIN) && !defined(M7_STEP_PORT)
#define M7_STEP_PORT STEP_PORT
#endif
#endif // STEP_PORT
#ifdef DIRECTION_PORT
#ifndef X_DIRECTION_PORT
#define X_DIRECTION_PORT DIRECTION_PORT
#endif
#ifndef Y_DIRECTION_PORT
#define Y_DIRECTION_PORT DIRECTION_PORT
#endif
#ifndef Z_DIRECTION_PORT
#define Z_DIRECTION_PORT DIRECTION_PORT
#endif
#if defined(M3_DIRECTION_PIN) && !defined(M3_DIRECTION_PORT)
#define M3_DIRECTION_PORT DIRECTION_PORT
#endif
#if defined(M4_DIRECTION_PIN) && !defined(M4_DIRECTION_PORT)
#define M4_DIRECTION_PORT DIRECTION_PORT
#endif
#if defined(M5_DIRECTION_PIN) && !defined(M5_DIRECTION_PORT)
#define M5_DIRECTION_PORT DIRECTION_PORT
#endif
#if defined(M6_DIRECTION_PIN) && !defined(M6_DIRECTION_PORT)
#define M6_DIRECTION_PORT DIRECTION_PORT
#endif
#if defined(M7_DIRECTION_PIN) && !defined(M7_DIRECTION_PORT)
#define M7_DIRECTION_PORT DIRECTION_PORT
#endif
#endif // DIRECTION_PORT
#ifdef SPINDLE_PORT
#ifndef SPINDLE_ENABLE_PORT
#define SPINDLE_ENABLE_PORT SPINDLE_PORT
#endif
#if defined(SPINDLE_PWM_PIN) && !defined(SPINDLE_PWM_PORT)
#define SPINDLE_PWM_PORT SPINDLE_PORT
#endif
#if defined(SPINDLE_DIRECTION_PIN) && !defined(SPINDLE_DIRECTION_PORT)
#define SPINDLE_DIRECTION_PORT SPINDLE_PORT
#endif
#endif // SPINDLE_PORT
#ifdef COOLANT_PORT
#if defined(COOLANT_FLOOD_PIN) && !defined(COOLANT_FLOOD_PORT)
#define COOLANT_FLOOD_PORT COOLANT_PORT
#endif
#if defined(COOLANT_MIST_PIN) && !defined(COOLANT_MIST_PORT)
#define COOLANT_MIST_PORT COOLANT_PORT
#endif
#endif // COOLANT_PORT
// End expand port shorthand names
#if TRINAMIC_ENABLE
#include "motors/trinamic.h"

View File

@@ -27,6 +27,8 @@
#pragma once
extern void board_ports_init (void); // default is a weak function
// I2C expanders
#if PCA9654E_ENABLE || MCP3221_ENABLE || MCP4725_ENABLE
@@ -73,6 +75,8 @@ extern void pca9654e_init(void);
static inline void io_expanders_init (void)
{
board_ports_init(); // can be implemented by board specific code
#if MCP3221_ENABLE
mcp3221_init();
#endif

14
gcode.c
View File

@@ -1383,15 +1383,15 @@ status_code_t gc_execute_block (char *block)
case 63:
case 64:
case 65:
if(hal.port.digital_out == NULL || ioports_unclaimed(Port_Digital, Port_Output) == 0)
if(!ioports_can_do().digital_out || ioports_unclaimed(Port_Digital, Port_Output) == 0)
FAIL(Status_GcodeUnsupportedCommand); // [Unsupported M command]
word_bit.modal_group.M5 = On;
port_command = (io_mcode_t)int_value;
break;
case 66:
if(hal.port.wait_on_input == NULL || (ioports_unclaimed(Port_Digital, Port_Input) == 0 &&
ioports_unclaimed(Port_Analog, Port_Input) == 0))
if(!ioports_can_do().wait_on_input || (ioports_unclaimed(Port_Digital, Port_Input) == 0 &&
ioports_unclaimed(Port_Analog, Port_Input) == 0))
FAIL(Status_GcodeUnsupportedCommand); // [Unsupported M command]
word_bit.modal_group.M5 = On;
port_command = (io_mcode_t)int_value;
@@ -1399,7 +1399,7 @@ status_code_t gc_execute_block (char *block)
case 67:
case 68:
if(hal.port.analog_out == NULL || ioports_unclaimed(Port_Analog, Port_Output) == 0)
if(!ioports_can_do().analog_out || ioports_unclaimed(Port_Analog, Port_Output) == 0)
FAIL(Status_GcodeUnsupportedCommand); // [Unsupported M command]
word_bit.modal_group.M5 = On;
port_command = (io_mcode_t)int_value;
@@ -3307,11 +3307,11 @@ status_code_t gc_execute_block (char *block)
case IoMCode_OutputOnImmediate:
case IoMCode_OutputOffImmediate:
hal.port.digital_out(gc_block.output_command.port, gc_block.output_command.value != 0.0f);
ioport_digital_out(gc_block.output_command.port, gc_block.output_command.value != 0.0f);
break;
case IoMCode_WaitOnInput:
sys.var5399 = hal.port.wait_on_input((io_port_type_t)gc_block.output_command.is_digital, gc_block.output_command.port, (wait_mode_t)gc_block.values.l, gc_block.values.q);
sys.var5399 = ioport_wait_on_input((io_port_type_t)gc_block.output_command.is_digital, gc_block.output_command.port, (wait_mode_t)gc_block.values.l, gc_block.values.q);
system_add_rt_report(Report_M66Result);
break;
@@ -3320,7 +3320,7 @@ status_code_t gc_execute_block (char *block)
break;
case IoMCode_AnalogOutImmediate:
hal.port.analog_out(gc_block.output_command.port, gc_block.output_command.value);
ioport_analog_out(gc_block.output_command.port, gc_block.output_command.value);
break;
}
}

2
grbl.h
View File

@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20250409
#define GRBL_BUILD 20250413
#define GRBL_URL "https://github.com/grblHAL"

View File

@@ -100,6 +100,11 @@ static settings_changed_ptr hal_settings_changed;
kinematics_t kinematics;
#endif
__attribute__((weak)) void board_ports_init (void)
{
// NOOP
}
void dummy_bool_handler (bool arg)
{
// NOOP

284
ioports.c

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,8 @@
#pragma once
//#define IOPORTS_KEEP_DEPRECATED
#define IOPORT_UNASSIGNED 255
typedef enum {
@@ -35,14 +37,14 @@ typedef enum {
/*! \brief Pointer to function for setting a digital output.
\param port port number
\param on true to set output high, false to set it low
\param on \a true to set output high, \a false to set it low
*/
typedef void (*digital_out_ptr)(uint8_t port, bool on);
/*! \brief Pointer to function for setting an analog output.
\param port port number.
\param value
\returns true if successful, false otherwise.
\returns \a true if successful, \a false otherwise.
*/
typedef bool (*analog_out_ptr)(uint8_t port, float value);
@@ -54,7 +56,7 @@ __NOTE:__ The latest value read is stored in \ref #sys sys.var5399.
\param port port number.
\param wait_mode a #wait_mode_t enum value.
\param timeout in seconds, ignored if wait_mode is #WaitMode_Immediate (0).
\returns read value if successful, -1 otherwise.
\returns read value if successful, \a -1 otherwise.
*/
typedef int32_t (*wait_on_input_ptr)(io_port_type_t type, uint8_t port, wait_mode_t wait_mode, float timeout);
@@ -66,7 +68,7 @@ __NOTE:__ The latest value read is stored in \ref #sys sys.var5399.
\param port port number.
\param wait_mode a #wait_mode_t enum value.
\param timeout in seconds, ignored if wait_mode is #WaitMode_Immediate (0).
\returns read value if successful, -1 otherwise.
\returns read value if successful, \a -1 otherwise.
*/
typedef int32_t (*ll_wait_on_input_ptr)(uint8_t port, wait_mode_t wait_mode, float timeout);
@@ -92,7 +94,7 @@ typedef void (*ll_set_pin_description_ptr)(io_port_direction_t dir, uint8_t port
\param type as an \a #io_port_type_t enum value.
\param dir as an \a #io_port_direction_t enum value.
\param port port number.
\returns pointer to port information in a xbar_t struct if successful, NULL if not.
\returns pointer to port information in a \a #xbar_t struct if successful, \a NULL if not.
*/
typedef xbar_t *(*get_pin_info_ptr)(io_port_type_t type, io_port_direction_t dir, uint8_t port);
@@ -101,7 +103,7 @@ typedef xbar_t *(*get_pin_info_ptr)(io_port_type_t type, io_port_direction_t dir
\param type as an \a #io_port_type_t enum value.
\param dir as an \a #io_port_direction_t enum value.
\param port port number.
\returns pointer to port information in a xbar_t struct if successful, NULL if not.
\returns pointer to port information in a \a #xbar_t struct if successful, \a NULL if not.
*/
typedef xbar_t *(*ll_get_pin_info_ptr)(io_port_direction_t dir, uint8_t port);
@@ -110,7 +112,7 @@ typedef xbar_t *(*ll_get_pin_info_ptr)(io_port_direction_t dir, uint8_t port);
\param dir as an \a #io_port_direction_t enum value.
\param port port number.
\param description description of the pin function.
\returns true if successful, false if not.
\returns \a true if successful, \a false if not.
*/
typedef bool (*claim_port_ptr)(io_port_type_t type, io_port_direction_t dir, uint8_t *port, const char *description);
@@ -119,7 +121,7 @@ typedef bool (*claim_port_ptr)(io_port_type_t type, io_port_direction_t dir, uin
\param dir as an \a #io_port_direction_t enum value.
\param port port number.
\param description description of the pin function.
\returns true if successful, false if not.
\returns \a true if successful, \a false if not.
*/
typedef bool (*ll_claim_port_ptr)(io_port_direction_t dir, uint8_t port, uint8_t user_port, const char *description);
@@ -129,13 +131,13 @@ typedef bool (*ll_claim_port_ptr)(io_port_direction_t dir, uint8_t port, uint8_t
\param dir as an \a #io_port_direction_t enum value.
\param port_from port number.
\param port_to port number.
\returns true if successful, false if not.
\returns \a true if successful, \a false if not.
*/
typedef bool (*swap_pins_ptr)(io_port_type_t type, io_port_direction_t dir, uint8_t port_from, uint8_t port_to);
/*! \brief Pointer to callback function for input port interrupt events.
\param port port number.
\param state true if port level is high, false if it is low.
\param state \a true if port level is high, \a false if it is low.
*/
typedef void (*ioport_interrupt_callback_ptr)(uint8_t port, bool state);
@@ -143,7 +145,7 @@ typedef void (*ioport_interrupt_callback_ptr)(uint8_t port, bool state);
\param port port number.
\param irq_mode a \a #pin_irq_mode_t enum value.
\param interrupt_callback pointer to the callback function to register or NULL to deregister the current callback.
\returns true if successful, false otherwise.
\returns \a true if successful, \a false otherwise.
*/
typedef bool (*ioport_register_interrupt_handler_ptr)(uint8_t port, pin_irq_mode_t irq_mode, ioport_interrupt_callback_ptr interrupt_callback);
@@ -152,7 +154,7 @@ typedef bool (*ioport_register_interrupt_handler_ptr)(uint8_t port, pin_irq_mode
\param user_port port number to be used for the callback.
\param irq_mode a \a #pin_irq_mode_t enum value.
\param interrupt_callback pointer to the callback function to register or NULL to deregister the current callback.
\returns true if successful, false otherwise.
\returns \a true if successful, \a false otherwise.
*/
typedef bool (*ll_ioport_register_interrupt_handler_ptr)(uint8_t port, uint8_t user_port, pin_irq_mode_t irq_mode, ioport_interrupt_callback_ptr interrupt_callback);
@@ -174,21 +176,46 @@ typedef struct {
ioport_register_interrupt_handler_ptr register_interrupt_handler;
} io_port_t;
typedef union {
control_signals_t *control;
coolant_state_t *coolant;
limit_signals_t *limits;
} driver_caps_t __attribute__ ((__transparent_union__));
typedef union {
uint8_t io;
struct {
uint8_t claim_explicit :1,
digital_out :1,
analog_out :1,
wait_on_input :1,
configure :1;
};
} io_port_cando_t;
uint8_t ioports_available (io_port_type_t type, io_port_direction_t dir);
uint8_t ioports_unclaimed (io_port_type_t type, io_port_direction_t dir);
xbar_t *ioport_get_info (io_port_type_t type, io_port_direction_t dir, uint8_t port);
bool ioport_claim (io_port_type_t type, io_port_direction_t dir, uint8_t *port, const char *description);
bool ioport_can_claim_explicit (void);
xbar_t *ioport_claim (io_port_type_t type, io_port_direction_t dir, uint8_t *port, const char *description);
io_port_cando_t ioports_can_do (void);
uint8_t ioport_find_free (io_port_type_t type, io_port_direction_t dir, pin_cap_t filter, const char *description);
bool ioports_enumerate (io_port_type_t type, io_port_direction_t dir, pin_cap_t filter, ioports_enumerate_callback_ptr callback, void *data);
void ioport_assign_function (aux_ctrl_t *aux_ctrl, pin_function_t *function);
void ioport_assign_out_function (aux_ctrl_out_t *aux_ctrl, pin_function_t *function);
bool ioport_set_description (io_port_type_t type, io_port_direction_t dir, uint8_t port, const char *description);
bool ioport_set_function (xbar_t *pin, pin_function_t function, driver_caps_t caps);
bool ioport_analog_out (uint8_t port, float value);
bool ioport_digital_out (uint8_t port, uint32_t value);
int32_t ioport_wait_on_input (io_port_type_t type, uint8_t port, wait_mode_t wait_mode, float timeout);
bool ioport_analog_out_config (uint8_t port, pwm_config_t *config);
bool ioport_digital_pwm_config (uint8_t port, pwm_config_t *config);
bool ioport_digital_in_config (uint8_t port, gpio_in_config_t *config);
bool ioport_enable_irq (uint8_t port, pin_irq_mode_t irq_mode, ioport_interrupt_callback_ptr handler);
bool ioport_digital_out_config (uint8_t port, gpio_out_config_t *config);
bool ioports_add (io_ports_data_t *ports, io_port_type_t type, uint8_t n_in, uint8_t n_out); //!< Deprecated - use ioports_add_analog() or ioports_add_digital() instead.
bool ioport_can_claim_explicit (void); //!< Deprecated - use ioports_can_do() instead.
void ioport_assign_function (aux_ctrl_t *aux_ctrl, pin_function_t *function); //!< Deprecated - use ioport_set_function() instead.
void ioport_assign_out_function (aux_ctrl_out_t *aux_ctrl, pin_function_t *function); //!< Deprecated - use ioport_set_function() instead.
//
struct io_ports_data;
@@ -197,14 +224,23 @@ typedef struct {
uint8_t n_ports;
uint8_t n_start;
uint8_t idx_last;
#ifdef IOPORTS_KEEP_DEPRECATED
uint8_t *map; //!< Deprecated - do not reference in new code!
#endif
} io_ports_detail_t;
typedef struct io_ports_data {
const char *pnum; //!< Deprecated - do not reference in new code!
io_ports_detail_t in;
io_ports_detail_t out;
union {
io_ports_detail_t cfg[2];
struct {
io_ports_detail_t in;
io_ports_detail_t out;
};
};
#ifdef IOPORTS_KEEP_DEPRECATED
const char *pnum; //!< Deprecated - do not reference in new code!
const char *(*get_pnum)(struct io_ports_data *data, uint8_t port); //!< Deprecated - do not reference in new code!
#endif
} io_ports_data_t;
typedef struct {
@@ -237,17 +273,18 @@ typedef struct {
bool always_on;
} ioports_pwm_t;
bool ioports_add (io_ports_data_t *ports, io_port_type_t type, uint8_t n_in, uint8_t n_out); //!< Deprecated - do not use in new code!
bool ioports_add_analog (io_analog_t *ports);
bool ioports_add_digital (io_digital_t *ports);
void ioports_add_settings (driver_settings_load_ptr settings_loaded, setting_changed_ptr setting_changed);
void ioport_save_input_settings (xbar_t *xbar, gpio_in_config_t *config);
void ioport_save_output_settings (xbar_t *xbar, gpio_out_config_t *config);
void ioport_setting_changed (setting_id_t id);
#define iports_get_pnum(type, port) type.get_pnum(&type, port)
#define ioports_map(type, port) ( type.map ? type.map[port] : port )
uint8_t ioports_map_reverse (io_ports_detail_t *type, uint8_t port);
bool ioports_precompute_pwm_values (pwm_config_t *config, ioports_pwm_t *pwm_data, uint32_t clock_hz);
uint_fast16_t ioports_compute_pwm_value (ioports_pwm_t *pwm_data, float value);
#ifdef IOPORTS_KEEP_DEPRECATED
#define iports_get_pnum(type, port) type.get_pnum(&type, port)
#define ioports_map(type, port) ( type.map ? type.map[port] : port )
#endif
/*EOF*/

View File

@@ -496,6 +496,9 @@ static aux_ctrl_out_t aux_ctrl_out[] = {
#endif
{ .function = Output_CoProc_Boot0, .aux_port = 0xFF, .pin = COPROC_BOOT0_PIN, .port = (void *)COPROC_BOOT0_PORT },
#endif
#if defined(SPI_RST_PIN) && SPI_RST_PORT == EXPANDER_PORT && defined(RP2040)
{ .function = Output_SPIRST, .aux_port = 0xFF, .pin = SPI_RST_PIN, .port = (void *)SPI_RST_PORT },
#endif
};
static inline aux_ctrl_out_t *aux_out_remap_explicit (void *port, uint8_t pin, uint8_t aux_port, void *output)
@@ -539,10 +542,8 @@ static inline void aux_ctrl_claim_out_ports (aux_claim_explicit_out_ptr aux_clai
for(idx = 0; idx < sizeof(aux_ctrl_out) / sizeof(aux_ctrl_out_t); idx++) {
if(aux_ctrl_out[idx].port == (void *)EXPANDER_PORT) {
if(ioports_enumerate(Port_Digital, Port_Output, (pin_cap_t){ .external = On, .claimable = On }, aux_claim, &aux_ctrl_out[idx])) {
if(ioport_claim(Port_Digital, Port_Output, &aux_ctrl_out[idx].aux_port, ""/*xbar_fn_to_pinname(aux_ctrl_out[idx].function)*/)) {
aux_ctrl_out[idx].output = hal.port.get_pin_info(Port_Digital, Port_Output, aux_ctrl_out[idx].aux_port);
if(((xbar_t *)aux_ctrl_out[idx].output)->set_function)
((xbar_t *)aux_ctrl_out[idx].output)->set_function((xbar_t *)aux_ctrl_out[idx].output, aux_ctrl_out[idx].function);
if((aux_ctrl_out[idx].output = ioport_claim(Port_Digital, Port_Output, &aux_ctrl_out[idx].aux_port, NULL /*xbar_fn_to_pinname(aux_ctrl_out[idx].function)*/))) {
ioport_set_function((xbar_t *)aux_ctrl_out[idx].output, aux_ctrl_out[idx].function, NULL);
// TODO: else set description?
aux_claim_explicit(&aux_ctrl_out[idx]);
}

View File

@@ -1073,9 +1073,10 @@ ISR_CODE bool ISR_FUNC(protocol_enqueue_foreground_task)(fg_task_ptr fn, void *d
if((ok = bptr != realtime_queue.tail)) { // If not buffer full
realtime_queue.task[realtime_queue.head].data = data;
realtime_queue.task[realtime_queue.head].task = fn; // add function pointer to buffer,
realtime_queue.task[realtime_queue.head].task = fn; // add function pointer to buffer,
realtime_queue.head = bptr; // update pointer and
system_set_exec_state_flag(EXEC_RT_COMMAND); // flag it for execute
if(sys.driver_started)
system_set_exec_state_flag(EXEC_RT_COMMAND); // flag it for execute
}
return ok;

View File

@@ -814,7 +814,7 @@ const char *help_pins (const char *cmd)
const char *help_pin_state (const char *cmd)
{
return hal.port.get_pin_info ? "output auxiliary pin states" : NULL;
return ioports_can_do().io ? "output auxiliary pin states" : NULL;
}
#endif