grblHAL core  20240318
crossbar.h File Reference
#include "nuts_bolts.h"

Go to the source code of this file.

Data Structures

struct  pin_name_t
 
struct  driver_irq_handler
 
union  pin_cap_t
 
union  pin_mode_t
 
struct  gpio_in_config_t
 /a cfg_data argument to /a xbar_config_ptr for gpio input pins More...
 
struct  gpio_out_config_t
 /a cfg_data argument to /a xbar_config_ptr for gpio output pins More...
 
struct  pwm_config_t
 /a cfg_data argument to /a xbar_config_ptr for PWM pins More...
 
union  xbar_cfg_ptr_t
 
struct  aux_ctrl_t
 
struct  aux_ctrl_out_t
 
struct  xbar
 
struct  periph_pin_t
 
struct  periph_signal
 
union  pin_debounce_t
 

Macros

#define PIN_ISINPUT(pin)   (pin < Outputs)
 
#define PIN_ISOUTPUT(pin)   (pin >= Outputs && pin < Bidirectional)
 
#define PIN_ISBIDIRECTIONAL(pin)   (pin >= Bidirectional)
 
#define PINMODE_NONE   (0)
 
#define PINMODE_OUTPUT   (1U<<1)
 
#define PINMODE_OD   (1U<<2)
 
#define PINMODE_PULLUP   (PullMode_Up<<3)
 
#define PINMODE_PULLDOWN   (PullMode_Down<<3)
 
#define PINMODE_ANALOG   (1U<<11)
 
#define PINMODE_PWM   (1U<<12)
 
#define PINMODE_PWM_SERVO   (1U<<13)
 
#define XBAR_SET_CAP(cap, mode)   { cap.mask = mode.mask; cap.claimable = !mode.claimed; }
 
#define XBAR_SET_DIN_INFO(pin, pin_id, src, cfg_fn, get_val_fn)
 
#define XBAR_SET_DOUT_INFO(pin, pin_id, src, cfg_fn, get_val_fn)
 

Typedefs

typedef bool(* irq_callback_ptr) (uint_fast8_t id, bool level)
 
typedef struct driver_irq_handler driver_irq_handler_t
 
typedef float(* xbar_get_value_ptr) (struct xbar *pin)
 
typedef void(* xbar_set_value_ptr) (struct xbar *pin, float value)
 
typedef void(* xbar_event_ptr) (bool on)
 
typedef bool(* xbar_config_ptr) (struct xbar *pin, xbar_cfg_ptr_t cfg_data, bool persistent)
 
typedef struct xbar xbar_t
 
typedef struct periph_signal periph_signal_t
 

Enumerations

enum  pin_function_t {
  Input_Reset = 0 , Input_FeedHold , Input_CycleStart , Input_SafetyDoor ,
  Input_BlockDelete , Input_StopDisable , Input_EStop , Input_ProbeDisconnect ,
  Input_MotorFault , Input_MotorWarning , Input_LimitsOverride , Input_SingleBlock ,
  Input_Unassigned , Input_ProbeOvertravel , Input_Probe , Input_MPGSelect ,
  Input_ModeSelect = Input_MPGSelect , Input_LimitX , Input_LimitX_2 , Input_LimitX_Max ,
  Input_HomeX , Input_HomeX_2 , Input_LimitY , Input_LimitY_2 ,
  Input_LimitY_Max , Input_HomeY , Input_HomeY_2 , Input_LimitZ ,
  Input_LimitZ_2 , Input_LimitZ_Max , Input_HomeZ , Input_HomeZ_2 ,
  Input_LimitA , Input_LimitA_Max , Input_HomeA , Input_LimitB ,
  Input_LimitB_Max , Input_HomeB , Input_LimitC , Input_LimitC_Max ,
  Input_HomeC , Input_LimitU , Input_LimitU_Max , Input_HomeU ,
  Input_LimitV , Input_LimitV_Max , Input_HomeV , Input_SpindleIndex ,
  Input_SpindlePulse , Input_Aux0 , Input_Aux1 , Input_Aux2 ,
  Input_Aux3 , Input_Aux4 , Input_Aux5 , Input_Aux6 ,
  Input_Aux7 , Input_Aux8 , Input_Aux9 , Input_Aux10 ,
  Input_Aux11 , Input_AuxMax = Input_Aux11 , Input_Analog_Aux0 , Input_Analog_Aux1 ,
  Input_Analog_Aux2 , Input_Analog_Aux3 , Input_Analog_Aux4 , Input_Analog_Aux5 ,
  Input_Analog_Aux6 , Input_Analog_Aux7 , Input_Analog_AuxMax = Input_Analog_Aux7 , Output_StepX ,
  Outputs = Output_StepX , Output_StepX_2 , Output_StepY , Output_StepY_2 ,
  Output_StepZ , Output_StepZ_2 , Output_StepA , Output_StepB ,
  Output_StepC , Output_StepU , Output_StepV , Output_DirX ,
  Output_DirX_2 , Output_DirY , Output_DirY_2 , Output_DirZ ,
  Output_DirZ_2 , Output_DirA , Output_DirB , Output_DirC ,
  Output_DirU , Output_DirV , Output_MotorChipSelect , Output_MotorChipSelectX ,
  Output_MotorChipSelectY , Output_MotorChipSelectZ , Output_MotorChipSelectM3 , Output_MotorChipSelectM4 ,
  Output_MotorChipSelectM5 , Output_MotorChipSelectM6 , Output_MotorChipSelectM7 , Output_StepperPower ,
  Output_StepperEnable , Output_StepperEnableX , Output_StepperEnableY , Output_StepperEnableZ ,
  Output_StepperEnableA , Output_StepperEnableB , Output_StepperEnableU , Output_StepperEnableV ,
  Output_StepperEnableC , Output_StepperEnableXY , Output_StepperEnableAB , Output_SpindleOn ,
  Output_SpindleDir , Output_SpindlePWM , Output_Spindle1On , Output_Spindle1Dir ,
  Output_Spindle1PWM , Output_CoolantMist , Output_CoolantFlood , Output_Aux0 ,
  Output_Aux1 , Output_Aux2 , Output_Aux3 , Output_Aux4 ,
  Output_Aux5 , Output_Aux6 , Output_Aux7 , Output_Aux8 ,
  Output_Aux9 , Output_Aux10 , Output_Aux11 , Output_AuxMax = Output_Aux11 ,
  Output_Analog_Aux0 , Output_Analog_Aux1 , Output_Analog_Aux2 , Output_Analog_Aux3 ,
  Output_Analog_Aux4 , Output_Analog_Aux5 , Output_Analog_Aux6 , Output_Analog_Aux7 ,
  Output_Analog_AuxMax = Output_Analog_Aux7 , Output_LED , Output_LED_R , Output_LED_G ,
  Output_LED_B , Output_LED_W , Output_LED_Adressable , Output_LED0_Adressable = Output_LED_Adressable ,
  Output_LED1_Adressable , Input_MISO , Multipin = Input_MISO , Output_MOSI ,
  Output_SPICLK , Output_SPICS , Output_SdCardCS , Input_SdCardDetect ,
  Output_SPIRST , Input_SPIIRQ , Output_SCK , Output_I2CSCK = Output_SCK ,
  Bidirectional_SDA , Bidirectional_I2CSDA = Bidirectional_SDA , Input_KeypadStrobe , Input_I2CStrobe ,
  Input_RX , Output_TX , Output_RTS , Input_QEI_A ,
  Input_QEI_B , Input_QEI_Select , Input_QEI_Index , Bidirectional_MotorUARTX ,
  Bidirectional = Bidirectional_MotorUARTX , Bidirectional_MotorUARTY , Bidirectional_MotorUARTZ , Bidirectional_MotorUARTM3 ,
  Bidirectional_MotorUARTM4 , Bidirectional_MotorUARTM5 , Bidirectional_MotorUARTM6 , Bidirectional_MotorUARTM7
}
 
enum  pin_group_t {
  PinGroup_SpindleControl = 0 , PinGroup_SpindlePWM , PinGroup_Coolant , PinGroup_SpindlePulse ,
  PinGroup_SpindleIndex , PinGroup_StepperPower , PinGroup_StepperEnable , PinGroup_StepperStep ,
  PinGroup_StepperDir , PinGroup_AuxOutput , PinGroup_AuxInputAnalog , PinGroup_AuxOutputAnalog ,
  PinGroup_SdCard , PinGroup_MotorChipSelect , PinGroup_MotorUART , PinGroup_I2C ,
  PinGroup_SPI , PinGroup_UART1 , PinGroup_UART = PinGroup_UART1 , PinGroup_UART2 ,
  PinGroup_UART3 , PinGroup_UART4 , PinGroup_USB , PinGroup_CAN ,
  PinGroup_LED , PinGroup_Home , PinGroup_Control = (1<<8) , PinGroup_Limit = (1<<9) ,
  PinGroup_LimitMax = (1<<10) , PinGroup_Probe = (1<<11) , PinGroup_Keypad = (1<<12) , PinGroup_MPG = (1<<13) ,
  PinGroup_QEI = (1<<14) , PinGroup_QEI_Select = (1<<15) , PinGroup_QEI_Index = (1<<16) , PinGroup_Motor_Warning = (1<<17) ,
  PinGroup_Motor_Fault = (1<<18) , PinGroup_AuxInput = (1<<19)
}
 
enum  pin_irq_mode_t {
  IRQ_Mode_None = 0b00000 , IRQ_Mode_Rising = 0b00001 , IRQ_Mode_Falling = 0b00010 , IRQ_Mode_RisingFalling = 0b00011 ,
  IRQ_Mode_Change = 0b00100 , IRQ_Mode_Edges = 0b00111 , IRQ_Mode_High = 0b01000 , IRQ_Mode_Low = 0b10000 ,
  IRQ_Mode_All = 0b11111
}
 Pin interrupt modes, may be or'ed when reporting pin capability. More...
 
enum  irq_type_t { IRQ_I2C_Strobe = 0 , IRQ_SPI }
 
enum  pull_mode_t { PullMode_None = 0b00 , PullMode_Up = 0b01 , PullMode_Down = 0b10 , PullMode_UpDown = 0b11 }
 Pin pullup and pulldown modes, may be or'ed when reporting pin capability. More...
 

Functions

void xbar_set_homing_source (void)
 
limit_signals_t xbar_get_homing_source (void)
 
limit_signals_t xbar_get_homing_source_from_cycle (axes_signals_t homing_cycle)
 
axes_signals_t xbar_fn_to_axismask (pin_function_t id)
 
const char * xbar_fn_to_pinname (pin_function_t id)
 
control_signals_t xbar_fn_to_signals_mask (pin_function_t id)
 

Macro Definition Documentation

◆ PIN_ISBIDIRECTIONAL

#define PIN_ISBIDIRECTIONAL (   pin)    (pin >= Bidirectional)

◆ PIN_ISINPUT

#define PIN_ISINPUT (   pin)    (pin < Outputs)

◆ PIN_ISOUTPUT

#define PIN_ISOUTPUT (   pin)    (pin >= Outputs && pin < Bidirectional)

◆ PINMODE_ANALOG

#define PINMODE_ANALOG   (1U<<11)

◆ PINMODE_NONE

#define PINMODE_NONE   (0)

◆ PINMODE_OD

#define PINMODE_OD   (1U<<2)

◆ PINMODE_OUTPUT

#define PINMODE_OUTPUT   (1U<<1)

◆ PINMODE_PULLDOWN

#define PINMODE_PULLDOWN   (PullMode_Down<<3)

◆ PINMODE_PULLUP

#define PINMODE_PULLUP   (PullMode_Up<<3)

◆ PINMODE_PWM

#define PINMODE_PWM   (1U<<12)

◆ PINMODE_PWM_SERVO

#define PINMODE_PWM_SERVO   (1U<<13)

◆ XBAR_SET_CAP

#define XBAR_SET_CAP (   cap,
  mode 
)    { cap.mask = mode.mask; cap.claimable = !mode.claimed; }

◆ XBAR_SET_DIN_INFO

#define XBAR_SET_DIN_INFO (   pin,
  pin_id,
  src,
  cfg_fn,
  get_val_fn 
)
Value:
{ \
pin.id = pin_id; \
pin.mode = src.mode; \
pin.cap = src.cap; \
pin.cap.invert = On; \
pin.cap.claimable = !src.mode.claimed; \
pin.function = src.id; \
pin.group = src.group; \
pin.pin = src.pin; \
pin.port = (void *)src.port; \
pin.description = src.description; \
pin.config = cfg_fn; \
pin.get_value = get_val_fn; \
}
#define On
Definition: nuts_bolts.h:36

◆ XBAR_SET_DOUT_INFO

#define XBAR_SET_DOUT_INFO (   pin,
  pin_id,
  src,
  cfg_fn,
  get_val_fn 
)
Value:
{ \
pin.id = pin_id; \
pin.mode = src.mode; \
pin.cap.mask = src.mode.mask; \
pin.cap.invert = On; \
pin.cap.claimable = !src.mode.claimed; \
pin.function = src.id; \
pin.group = src.group; \
pin.pin = src.pin; \
pin.port = (void *)src.port; \
pin.description = src.description; \
pin.config = cfg_fn; \
pin.get_value = get_val_fn; \
}

Typedef Documentation

◆ driver_irq_handler_t

◆ irq_callback_ptr

typedef bool(* irq_callback_ptr) (uint_fast8_t id, bool level)

◆ periph_signal_t

◆ xbar_config_ptr

typedef bool(* xbar_config_ptr) (struct xbar *pin, xbar_cfg_ptr_t cfg_data, bool persistent)

◆ xbar_event_ptr

typedef void(* xbar_event_ptr) (bool on)

◆ xbar_get_value_ptr

typedef float(* xbar_get_value_ptr) (struct xbar *pin)

◆ xbar_set_value_ptr

typedef void(* xbar_set_value_ptr) (struct xbar *pin, float value)

◆ xbar_t

typedef struct xbar xbar_t

Enumeration Type Documentation

◆ irq_type_t

enum irq_type_t
Enumerator
IRQ_I2C_Strobe 
IRQ_SPI 

◆ pin_function_t

Enumerator
Input_Reset 
Input_FeedHold 
Input_CycleStart 
Input_SafetyDoor 
Input_BlockDelete 
Input_StopDisable 
Input_EStop 
Input_ProbeDisconnect 
Input_MotorFault 
Input_MotorWarning 
Input_LimitsOverride 
Input_SingleBlock 
Input_Unassigned 
Input_ProbeOvertravel 
Input_Probe 
Input_MPGSelect 
Input_ModeSelect 
Input_LimitX 
Input_LimitX_2 
Input_LimitX_Max 
Input_HomeX 
Input_HomeX_2 
Input_LimitY 
Input_LimitY_2 
Input_LimitY_Max 
Input_HomeY 
Input_HomeY_2 
Input_LimitZ 
Input_LimitZ_2 
Input_LimitZ_Max 
Input_HomeZ 
Input_HomeZ_2 
Input_LimitA 
Input_LimitA_Max 
Input_HomeA 
Input_LimitB 
Input_LimitB_Max 
Input_HomeB 
Input_LimitC 
Input_LimitC_Max 
Input_HomeC 
Input_LimitU 
Input_LimitU_Max 
Input_HomeU 
Input_LimitV 
Input_LimitV_Max 
Input_HomeV 
Input_SpindleIndex 
Input_SpindlePulse 
Input_Aux0 
Input_Aux1 
Input_Aux2 
Input_Aux3 
Input_Aux4 
Input_Aux5 
Input_Aux6 
Input_Aux7 
Input_Aux8 
Input_Aux9 
Input_Aux10 
Input_Aux11 
Input_AuxMax 
Input_Analog_Aux0 
Input_Analog_Aux1 
Input_Analog_Aux2 
Input_Analog_Aux3 
Input_Analog_Aux4 
Input_Analog_Aux5 
Input_Analog_Aux6 
Input_Analog_Aux7 
Input_Analog_AuxMax 
Output_StepX 
Outputs 
Output_StepX_2 
Output_StepY 
Output_StepY_2 
Output_StepZ 
Output_StepZ_2 
Output_StepA 
Output_StepB 
Output_StepC 
Output_StepU 
Output_StepV 
Output_DirX 
Output_DirX_2 
Output_DirY 
Output_DirY_2 
Output_DirZ 
Output_DirZ_2 
Output_DirA 
Output_DirB 
Output_DirC 
Output_DirU 
Output_DirV 
Output_MotorChipSelect 
Output_MotorChipSelectX 
Output_MotorChipSelectY 
Output_MotorChipSelectZ 
Output_MotorChipSelectM3 
Output_MotorChipSelectM4 
Output_MotorChipSelectM5 
Output_MotorChipSelectM6 
Output_MotorChipSelectM7 
Output_StepperPower 
Output_StepperEnable 
Output_StepperEnableX 
Output_StepperEnableY 
Output_StepperEnableZ 
Output_StepperEnableA 
Output_StepperEnableB 
Output_StepperEnableU 
Output_StepperEnableV 
Output_StepperEnableC 
Output_StepperEnableXY 
Output_StepperEnableAB 
Output_SpindleOn 
Output_SpindleDir 
Output_SpindlePWM 
Output_Spindle1On 
Output_Spindle1Dir 
Output_Spindle1PWM 
Output_CoolantMist 
Output_CoolantFlood 
Output_Aux0 
Output_Aux1 
Output_Aux2 
Output_Aux3 
Output_Aux4 
Output_Aux5 
Output_Aux6 
Output_Aux7 
Output_Aux8 
Output_Aux9 
Output_Aux10 
Output_Aux11 
Output_AuxMax 
Output_Analog_Aux0 
Output_Analog_Aux1 
Output_Analog_Aux2 
Output_Analog_Aux3 
Output_Analog_Aux4 
Output_Analog_Aux5 
Output_Analog_Aux6 
Output_Analog_Aux7 
Output_Analog_AuxMax 
Output_LED 
Output_LED_R 
Output_LED_G 
Output_LED_B 
Output_LED_W 
Output_LED_Adressable 
Output_LED0_Adressable 
Output_LED1_Adressable 
Input_MISO 
Multipin 
Output_MOSI 
Output_SPICLK 
Output_SPICS 
Output_SdCardCS 
Input_SdCardDetect 
Output_SPIRST 
Input_SPIIRQ 
Output_SCK 
Output_I2CSCK 
Bidirectional_SDA 
Bidirectional_I2CSDA 
Input_KeypadStrobe 
Input_I2CStrobe 
Input_RX 
Output_TX 
Output_RTS 
Input_QEI_A 
Input_QEI_B 
Input_QEI_Select 
Input_QEI_Index 
Bidirectional_MotorUARTX 
Bidirectional 
Bidirectional_MotorUARTY 
Bidirectional_MotorUARTZ 
Bidirectional_MotorUARTM3 
Bidirectional_MotorUARTM4 
Bidirectional_MotorUARTM5 
Bidirectional_MotorUARTM6 
Bidirectional_MotorUARTM7 

◆ pin_group_t

Enumerator
PinGroup_SpindleControl 
PinGroup_SpindlePWM 
PinGroup_Coolant 
PinGroup_SpindlePulse 
PinGroup_SpindleIndex 
PinGroup_StepperPower 
PinGroup_StepperEnable 
PinGroup_StepperStep 
PinGroup_StepperDir 
PinGroup_AuxOutput 
PinGroup_AuxInputAnalog 
PinGroup_AuxOutputAnalog 
PinGroup_SdCard 
PinGroup_MotorChipSelect 
PinGroup_MotorUART 
PinGroup_I2C 
PinGroup_SPI 
PinGroup_UART1 
PinGroup_UART 
PinGroup_UART2 
PinGroup_UART3 
PinGroup_UART4 
PinGroup_USB 
PinGroup_CAN 
PinGroup_LED 
PinGroup_Home 
PinGroup_Control 
PinGroup_Limit 
PinGroup_LimitMax 
PinGroup_Probe 
PinGroup_Keypad 
PinGroup_MPG 
PinGroup_QEI 
PinGroup_QEI_Select 
PinGroup_QEI_Index 
PinGroup_Motor_Warning 
PinGroup_Motor_Fault 
PinGroup_AuxInput 

◆ pin_irq_mode_t

Pin interrupt modes, may be or'ed when reporting pin capability.

Enumerator
IRQ_Mode_None 

0b00000 (0x00)

IRQ_Mode_Rising 

0b00001 (0x01)

IRQ_Mode_Falling 

0b00010 (0x02)

IRQ_Mode_RisingFalling 

0b00011 (0x03) - only used to report port capability.

IRQ_Mode_Change 

0b00100 (0x04)

IRQ_Mode_Edges 

0b00111 (0x07) - only used to report port capability.

IRQ_Mode_High 

0b01000 (0x08)

IRQ_Mode_Low 

0b10000 (0x10)

IRQ_Mode_All 

0b11111 (0x1F) - only used to report port capability.

◆ pull_mode_t

Pin pullup and pulldown modes, may be or'ed when reporting pin capability.

Enumerator
PullMode_None 

0b00 (0x00)

PullMode_Up 

0b01 (0x01)

PullMode_Down 

0b10 (0x02)

PullMode_UpDown 

0b11 (0x03) - only used to report port capability.

Function Documentation

◆ xbar_fn_to_axismask()

axes_signals_t xbar_fn_to_axismask ( pin_function_t  id)

◆ xbar_fn_to_pinname()

const char* xbar_fn_to_pinname ( pin_function_t  id)

◆ xbar_fn_to_signals_mask()

control_signals_t xbar_fn_to_signals_mask ( pin_function_t  id)

◆ xbar_get_homing_source()

limit_signals_t xbar_get_homing_source ( void  )

◆ xbar_get_homing_source_from_cycle()

limit_signals_t xbar_get_homing_source_from_cycle ( axes_signals_t  homing_cycle)

◆ xbar_set_homing_source()

void xbar_set_homing_source ( void  )