220 #define PIN_ISINPUT(pin) (pin < Outputs)
221 #define PIN_ISOUTPUT(pin) (pin >= Outputs && pin < Bidirectional)
222 #define PIN_ISBIDIRECTIONAL(pin) (pin >= Bidirectional)
229 PROGMEM
static const pin_name_t pin_names[] = {
236 { .function =
Input_EStop, .name =
"Emergency stop" },
262 { .function =
Input_Aux0, .name =
"Aux in 0" },
263 { .function =
Input_Aux1, .name =
"Aux in 1" },
264 { .function =
Input_Aux2, .name =
"Aux in 2" },
265 { .function =
Input_Aux3, .name =
"Aux in 3" },
266 { .function =
Input_Aux4, .name =
"Aux in 4" },
267 { .function =
Input_Aux5, .name =
"Aux in 5" },
268 { .function =
Input_Aux6, .name =
"Aux in 6" },
269 { .function =
Input_Aux7, .name =
"Aux in 7" },
270 { .function =
Input_Aux8, .name =
"Aux in 8" },
271 { .function =
Input_Aux9, .name =
"Aux in 9" },
398 { .function =
Input_RX, .name =
"RX" },
491 #define PINMODE_NONE (0)
492 #define PINMODE_OUTPUT (1U<<1)
494 #define PINMODE_OD (1U<<2)
496 #define PINMODE_PULLUP (PullMode_Up<<3)
497 #define PINMODE_PULLDOWN (PullMode_Down<<3)
498 #define PINMODE_ANALOG (1U<<11)
499 #define PINMODE_PWM (1U<<12)
500 #define PINMODE_PWM_SERVO (1U<<13)
536 #define XBAR_SET_CAP(cap, mode) { cap.mask = mode.mask; cap.claimable = !mode.claimed; }
537 #define XBAR_SET_DIN_INFO(pin, pin_id, src, cfg_fn, get_val_fn) { \
539 pin.mode = src.mode; \
541 pin.cap.invert = On; \
542 pin.cap.claimable = !src.mode.claimed; \
543 pin.function = src.id; \
544 pin.group = src.group; \
546 pin.port = (void *)src.port; \
547 pin.description = src.description; \
548 pin.config = cfg_fn; \
549 pin.get_value = get_val_fn; \
551 #define XBAR_SET_DOUT_INFO(pin, pin_id, src, cfg_fn, get_val_fn) { \
553 pin.mode = src.mode; \
554 pin.cap.mask = src.mode.mask; \
555 pin.cap.invert = On; \
556 pin.cap.claimable = !src.mode.claimed; \
557 pin.function = src.id; \
558 pin.group = src.group; \
560 pin.port = (void *)src.port; \
561 pin.description = src.description; \
562 pin.config = cfg_fn; \
563 pin.get_value = get_val_fn; \
limit_signals_t xbar_get_homing_source_from_cycle(axes_signals_t homing_cycle)
Definition: crossbar.c:115
bool(* irq_callback_ptr)(uint_fast8_t id, bool level)
Definition: crossbar.h:475
const char * xbar_fn_to_pinname(pin_function_t id)
Definition: crossbar.c:131
pull_mode_t
Pin pullup and pulldown modes, may be or'ed when reporting pin capability.
Definition: crossbar.h:484
@ PullMode_Down
0b10 (0x02)
Definition: crossbar.h:487
@ PullMode_None
0b00 (0x00)
Definition: crossbar.h:485
@ PullMode_Up
0b01 (0x01)
Definition: crossbar.h:486
@ PullMode_UpDown
0b11 (0x03) - only used to report port capability.
Definition: crossbar.h:488
pin_function_t
Definition: crossbar.h:27
@ Output_DirX_2
Definition: crossbar.h:115
@ Output_SPICS
Definition: crossbar.h:189
@ Input_LimitB
Definition: crossbar.h:65
@ Input_QEI_A
Definition: crossbar.h:204
@ Input_LimitY_2
Definition: crossbar.h:53
@ Input_FeedHold
Definition: crossbar.h:30
@ Input_Aux6
Definition: crossbar.h:85
@ Output_Aux2
Definition: crossbar.h:156
@ Output_Analog_Aux0
Definition: crossbar.h:167
@ Output_MOSI
Definition: crossbar.h:187
@ Output_LED_R
Definition: crossbar.h:177
@ Input_HomeX_2
Definition: crossbar.h:51
@ Output_RTS
Definition: crossbar.h:203
@ Input_Analog_Aux1
Definition: crossbar.h:93
@ Input_SpindleIndex
Definition: crossbar.h:77
@ Input_Analog_Aux5
Definition: crossbar.h:97
@ Output_StepperEnableV
Definition: crossbar.h:142
@ Output_StepZ_2
Definition: crossbar.h:108
@ Input_HomeA
Definition: crossbar.h:64
@ Input_HomeC
Definition: crossbar.h:70
@ Output_DirX
Definition: crossbar.h:114
@ Input_Unassigned
Definition: crossbar.h:41
@ Output_TX
Definition: crossbar.h:202
@ Output_MotorChipSelectX
Definition: crossbar.h:126
@ Input_Reset
Definition: crossbar.h:29
@ Bidirectional_MotorUARTM7
Definition: crossbar.h:217
@ Input_SPIIRQ
Definition: crossbar.h:194
@ Output_StepB
Definition: crossbar.h:110
@ Input_HomeZ
Definition: crossbar.h:60
@ Bidirectional_MotorUARTM5
Definition: crossbar.h:215
@ Output_Aux4
Definition: crossbar.h:158
@ Input_Analog_Aux7
Definition: crossbar.h:99
@ Output_Analog_AuxMax
Definition: crossbar.h:175
@ Input_Probe
Definition: crossbar.h:43
@ Output_DirV
Definition: crossbar.h:124
@ Output_StepperEnableX
Definition: crossbar.h:136
@ Output_FlashCS
Definition: crossbar.h:190
@ Output_DirA
Definition: crossbar.h:120
@ Output_StepY_2
Definition: crossbar.h:106
@ Output_MotorChipSelectM6
Definition: crossbar.h:132
@ Output_DirB
Definition: crossbar.h:121
@ Input_MotorFault
Definition: crossbar.h:37
@ Output_SdCardCS
Definition: crossbar.h:191
@ Input_Analog_AuxMax
Definition: crossbar.h:100
@ Bidirectional_MotorUARTM4
Definition: crossbar.h:214
@ Input_MotorWarning
Definition: crossbar.h:38
@ Output_DirY
Definition: crossbar.h:116
@ Output_StepperEnableAB
Definition: crossbar.h:145
@ Output_MotorChipSelectM5
Definition: crossbar.h:131
@ Output_Aux1
Definition: crossbar.h:155
@ Input_ProbeDisconnect
Definition: crossbar.h:36
@ Bidirectional_I2CSDA
Definition: crossbar.h:198
@ Output_Aux11
Definition: crossbar.h:165
@ Input_LimitX
Definition: crossbar.h:47
@ Output_Analog_Aux6
Definition: crossbar.h:173
@ Output_LED
Definition: crossbar.h:176
@ Input_EStop
Definition: crossbar.h:35
@ Input_StopDisable
Definition: crossbar.h:34
@ Input_HomeZ_2
Definition: crossbar.h:61
@ Input_LimitA_Max
Definition: crossbar.h:63
@ Output_DirY_2
Definition: crossbar.h:117
@ Input_HomeX
Definition: crossbar.h:50
@ Output_StepperEnableXY
Definition: crossbar.h:144
@ Input_SdCardDetect
Definition: crossbar.h:192
@ Output_LED1_Adressable
Definition: crossbar.h:183
@ Input_SpindlePulse
Definition: crossbar.h:78
@ Input_HomeY_2
Definition: crossbar.h:56
@ Output_LED_Adressable
Definition: crossbar.h:181
@ Output_DirZ
Definition: crossbar.h:118
@ Bidirectional_MotorUARTM6
Definition: crossbar.h:216
@ Input_LimitsOverride
Definition: crossbar.h:39
@ Input_HomeU
Definition: crossbar.h:73
@ Input_Aux3
Definition: crossbar.h:82
@ Input_ModeSelect
Definition: crossbar.h:46
@ Output_LED0_Adressable
Definition: crossbar.h:182
@ Outputs
Definition: crossbar.h:103
@ Input_Aux8
Definition: crossbar.h:87
@ Output_StepV
Definition: crossbar.h:113
@ Input_Aux11
Definition: crossbar.h:90
@ Output_StepperEnableZ
Definition: crossbar.h:138
@ Output_Analog_Aux3
Definition: crossbar.h:170
@ Output_StepU
Definition: crossbar.h:112
@ Input_LimitX_Max
Definition: crossbar.h:49
@ Output_AuxMax
Definition: crossbar.h:166
@ Input_QEI_Select
Definition: crossbar.h:206
@ Output_StepperEnableU
Definition: crossbar.h:141
@ Output_StepperEnableA
Definition: crossbar.h:139
@ Input_Aux9
Definition: crossbar.h:88
@ Output_Aux7
Definition: crossbar.h:161
@ Output_MotorChipSelectY
Definition: crossbar.h:127
@ Bidirectional_MotorUARTZ
Definition: crossbar.h:212
@ Input_LimitA
Definition: crossbar.h:62
@ Output_StepperPower
Definition: crossbar.h:134
@ Input_HomeY
Definition: crossbar.h:55
@ Input_LimitY
Definition: crossbar.h:52
@ Output_Aux9
Definition: crossbar.h:163
@ Input_BlockDelete
Definition: crossbar.h:33
@ Input_KeypadStrobe
Definition: crossbar.h:199
@ Output_LED_G
Definition: crossbar.h:178
@ Input_Aux2
Definition: crossbar.h:81
@ Input_Aux4
Definition: crossbar.h:83
@ Input_HomeV
Definition: crossbar.h:76
@ Output_StepperEnable
Definition: crossbar.h:135
@ Input_LimitV_Max
Definition: crossbar.h:75
@ Output_Analog_Aux1
Definition: crossbar.h:168
@ Input_LimitU_Max
Definition: crossbar.h:72
@ Input_LimitY_Max
Definition: crossbar.h:54
@ Output_SpindleDir
Definition: crossbar.h:147
@ Output_StepperEnableY
Definition: crossbar.h:137
@ Input_LimitZ_Max
Definition: crossbar.h:59
@ Multipin
Definition: crossbar.h:186
@ Output_StepperEnableC
Definition: crossbar.h:143
@ Input_LimitX_2
Definition: crossbar.h:48
@ Input_LimitC
Definition: crossbar.h:68
@ Input_SingleBlock
Definition: crossbar.h:40
@ Output_DirU
Definition: crossbar.h:123
@ Output_SPIRST
Definition: crossbar.h:193
@ Input_LimitU
Definition: crossbar.h:71
@ Input_LimitB_Max
Definition: crossbar.h:66
@ Input_AuxMax
Definition: crossbar.h:91
@ Output_DirZ_2
Definition: crossbar.h:119
@ Output_MotorChipSelectM7
Definition: crossbar.h:133
@ Input_ProbeOvertravel
Definition: crossbar.h:42
@ Output_MotorChipSelectM3
Definition: crossbar.h:129
@ Input_LimitZ_2
Definition: crossbar.h:58
@ Output_DirC
Definition: crossbar.h:122
@ Output_Analog_Aux7
Definition: crossbar.h:174
@ Output_StepY
Definition: crossbar.h:105
@ Output_SpindleOn
Definition: crossbar.h:146
@ Input_LimitV
Definition: crossbar.h:74
@ Output_Aux8
Definition: crossbar.h:162
@ Input_I2CStrobe
Definition: crossbar.h:200
@ Input_Analog_Aux3
Definition: crossbar.h:95
@ Output_Spindle1Dir
Definition: crossbar.h:150
@ Output_Aux10
Definition: crossbar.h:164
@ Output_SpindlePWM
Definition: crossbar.h:148
@ Output_CoolantMist
Definition: crossbar.h:152
@ Input_MPGSelect
Definition: crossbar.h:45
@ Output_Spindle1On
Definition: crossbar.h:149
@ Input_Aux1
Definition: crossbar.h:80
@ Input_RX
Definition: crossbar.h:201
@ Bidirectional_MotorUARTM3
Definition: crossbar.h:213
@ Input_LimitZ
Definition: crossbar.h:57
@ Output_StepX_2
Definition: crossbar.h:104
@ Input_Analog_Aux6
Definition: crossbar.h:98
@ Output_MotorChipSelectM4
Definition: crossbar.h:130
@ Bidirectional_MotorUARTX
Definition: crossbar.h:209
@ Input_Aux0
Definition: crossbar.h:79
@ Bidirectional_SDA
Definition: crossbar.h:197
@ Output_MotorChipSelectZ
Definition: crossbar.h:128
@ Output_Analog_Aux2
Definition: crossbar.h:169
@ Input_Aux10
Definition: crossbar.h:89
@ Output_Analog_Aux4
Definition: crossbar.h:171
@ Output_Aux0
Definition: crossbar.h:154
@ Input_Analog_Aux2
Definition: crossbar.h:94
@ Input_QEI_B
Definition: crossbar.h:205
@ Output_Aux6
Definition: crossbar.h:160
@ Input_MISO
Definition: crossbar.h:185
@ Bidirectional_MotorUARTY
Definition: crossbar.h:211
@ Output_Aux5
Definition: crossbar.h:159
@ Output_StepperEnableB
Definition: crossbar.h:140
@ Output_SCK
Definition: crossbar.h:195
@ Input_CycleStart
Definition: crossbar.h:31
@ Output_LED_B
Definition: crossbar.h:179
@ Output_StepX
Definition: crossbar.h:102
@ Output_Aux3
Definition: crossbar.h:157
@ Bidirectional
Definition: crossbar.h:210
@ Output_StepZ
Definition: crossbar.h:107
@ Output_StepC
Definition: crossbar.h:111
@ Output_SPICLK
Definition: crossbar.h:188
@ Input_QEI_Index
Definition: crossbar.h:207
@ Input_Analog_Aux0
Definition: crossbar.h:92
@ Output_MotorChipSelect
Definition: crossbar.h:125
@ Input_Aux7
Definition: crossbar.h:86
@ Input_SafetyDoor
Definition: crossbar.h:32
@ Output_CoolantFlood
Definition: crossbar.h:153
@ Input_HomeB
Definition: crossbar.h:67
@ Input_Aux5
Definition: crossbar.h:84
@ Output_Analog_Aux5
Definition: crossbar.h:172
@ Input_LimitC_Max
Definition: crossbar.h:69
@ Output_LED_W
Definition: crossbar.h:180
@ Output_StepA
Definition: crossbar.h:109
@ Input_Analog_Aux4
Definition: crossbar.h:96
@ Output_I2CSCK
Definition: crossbar.h:196
@ Output_Spindle1PWM
Definition: crossbar.h:151
float(* xbar_get_value_ptr)(struct xbar *pin)
Definition: crossbar.h:601
limit_signals_t xbar_get_homing_source(void)
Definition: crossbar.c:109
void(* xbar_event_ptr)(bool on)
Definition: crossbar.h:603
axes_signals_t xbar_fn_to_axismask(pin_function_t id)
Definition: crossbar.c:26
pin_group_t
Definition: crossbar.h:415
@ PinGroup_SpindlePWM
Definition: crossbar.h:417
@ PinGroup_AuxInputAnalog
Definition: crossbar.h:426
@ PinGroup_UART1
Definition: crossbar.h:433
@ PinGroup_Control
Definition: crossbar.h:443
@ PinGroup_QEI_Select
Definition: crossbar.h:450
@ PinGroup_AuxOutput
Definition: crossbar.h:425
@ PinGroup_QEI
Definition: crossbar.h:449
@ PinGroup_Keypad
Definition: crossbar.h:447
@ PinGroup_StepperDir
Definition: crossbar.h:424
@ PinGroup_USB
Definition: crossbar.h:438
@ PinGroup_SPI
Definition: crossbar.h:432
@ PinGroup_UART3
Definition: crossbar.h:436
@ PinGroup_StepperPower
Definition: crossbar.h:421
@ PinGroup_UART4
Definition: crossbar.h:437
@ PinGroup_CAN
Definition: crossbar.h:439
@ PinGroup_MotorChipSelect
Definition: crossbar.h:429
@ PinGroup_AuxOutputAnalog
Definition: crossbar.h:427
@ PinGroup_SdCard
Definition: crossbar.h:428
@ PinGroup_Motor_Warning
Definition: crossbar.h:452
@ PinGroup_I2C
Definition: crossbar.h:431
@ PinGroup_LED
Definition: crossbar.h:440
@ PinGroup_MotorUART
Definition: crossbar.h:430
@ PinGroup_UART2
Definition: crossbar.h:435
@ PinGroup_Limit
Definition: crossbar.h:444
@ PinGroup_QEI_Index
Definition: crossbar.h:451
@ PinGroup_SpindleIndex
Definition: crossbar.h:420
@ PinGroup_AuxInput
Definition: crossbar.h:454
@ PinGroup_Home
Definition: crossbar.h:441
@ PinGroup_Probe
Definition: crossbar.h:446
@ PinGroup_LimitMax
Definition: crossbar.h:445
@ PinGroup_MPG
Definition: crossbar.h:448
@ PinGroup_StepperStep
Definition: crossbar.h:423
@ PinGroup_StepperEnable
Definition: crossbar.h:422
@ PinGroup_SpindlePulse
Definition: crossbar.h:419
@ PinGroup_Coolant
Definition: crossbar.h:418
@ PinGroup_Motor_Fault
Definition: crossbar.h:453
@ PinGroup_SpindleControl
Definition: crossbar.h:416
@ PinGroup_UART
Definition: crossbar.h:434
irq_type_t
Definition: crossbar.h:470
@ IRQ_I2C_Strobe
Definition: crossbar.h:471
@ IRQ_SPI
Definition: crossbar.h:472
bool(* xbar_config_ptr)(struct xbar *pin, xbar_cfg_ptr_t cfg_data, bool persistent)
Definition: crossbar.h:604
struct driver_irq_handler driver_irq_handler_t
control_signals_t xbar_fn_to_signals_mask(pin_function_t id)
Definition: crossbar.c:144
pin_irq_mode_t
Pin interrupt modes, may be or'ed when reporting pin capability.
Definition: crossbar.h:458
@ IRQ_Mode_Low
0b10000 (0x10)
Definition: crossbar.h:466
@ IRQ_Mode_Rising
0b00001 (0x01)
Definition: crossbar.h:460
@ IRQ_Mode_RisingFalling
0b00011 (0x03) - only used to report port capability.
Definition: crossbar.h:462
@ IRQ_Mode_None
0b00000 (0x00)
Definition: crossbar.h:459
@ IRQ_Mode_High
0b01000 (0x08)
Definition: crossbar.h:465
@ IRQ_Mode_All
0b11111 (0x1F) - only used to report port capability.
Definition: crossbar.h:467
@ IRQ_Mode_Change
0b00100 (0x04)
Definition: crossbar.h:463
@ IRQ_Mode_Falling
0b00010 (0x02)
Definition: crossbar.h:461
@ IRQ_Mode_Edges
0b00111 (0x07) - only used to report port capability.
Definition: crossbar.h:464
void xbar_set_homing_source(void)
Definition: crossbar.c:98
void(* xbar_set_value_ptr)(struct xbar *pin, float value)
Definition: crossbar.h:602
struct periph_signal periph_signal_t
__attribute__
Definition: errors.h:30
Definition: crossbar.h:616
uint8_t aux_port
Definition: crossbar.h:618
uint8_t pin
Definition: crossbar.h:619
void * output
Definition: crossbar.h:621
void * port
Definition: crossbar.h:620
Definition: crossbar.h:606
uint8_t aux_port
Definition: crossbar.h:608
control_signals_t cap
Definition: crossbar.h:610
pin_irq_mode_t irq_mode
Definition: crossbar.h:609
void * input
Definition: crossbar.h:613
uint8_t pin
Definition: crossbar.h:611
void * port
Definition: crossbar.h:612
Definition: crossbar.h:477
irq_callback_ptr callback
Definition: crossbar.h:479
struct driver_irq_handler * next
Definition: crossbar.h:480
irq_type_t type
Definition: crossbar.h:478
/a cfg_data argument to /a xbar_config_ptr for gpio input pins
Definition: crossbar.h:567
bool debounce
Definition: crossbar.h:569
bool inverted
Definition: crossbar.h:568
pull_mode_t pull_mode
Definition: crossbar.h:570
/a cfg_data argument to /a xbar_config_ptr for gpio output pins
Definition: crossbar.h:574
bool inverted
Definition: crossbar.h:575
bool open_drain
Definition: crossbar.h:576
bool pwm
Definition: crossbar.h:577
Limit switches struct, consists of four packed axes_signals_t structs in 32 bits.
Definition: nuts_bolts.h:157
Definition: crossbar.h:639
pin_mode_t mode
Definition: crossbar.h:644
const char * description
Definition: crossbar.h:645
uint_fast8_t pin
Definition: crossbar.h:643
void * port
Definition: crossbar.h:642
pin_group_t group
Definition: crossbar.h:641
Definition: crossbar.h:648
struct periph_signal * next
Definition: crossbar.h:650
periph_pin_t pin
Definition: crossbar.h:649
Definition: crossbar.h:224
const char * name
Definition: crossbar.h:226
pin_function_t function
Definition: crossbar.h:225
/a cfg_data argument to /a xbar_config_ptr for PWM pins
Definition: crossbar.h:581
float freq_hz
Definition: crossbar.h:582
bool invert
Definition: crossbar.h:588
float max
Definition: crossbar.h:584
bool servo_mode
Definition: crossbar.h:589
float off_value
Definition: crossbar.h:585
float min_value
Definition: crossbar.h:586
float max_value
Definition: crossbar.h:587
float min
Definition: crossbar.h:583
Definition: crossbar.h:624
xbar_event_ptr on_event
Not used - might be removed.
Definition: crossbar.h:636
uint8_t id
Pin id.
Definition: crossbar.h:625
pin_mode_t mode
Current pin configuration.
Definition: crossbar.h:632
const char * description
Optional pointer to description string.
Definition: crossbar.h:629
xbar_config_ptr config
Optional pointer to function for configuring the port.
Definition: crossbar.h:633
xbar_set_value_ptr set_value
Optional pointer to function to set port value.
Definition: crossbar.h:635
xbar_get_value_ptr get_value
Optional pointer to function to get current port value.
Definition: crossbar.h:634
uint_fast8_t pin
Pin number.
Definition: crossbar.h:630
pin_cap_t cap
Pin capabilities.
Definition: crossbar.h:631
void * port
Optional pointer to the underlying peripheral or pin specific data.
Definition: crossbar.h:628
pin_group_t group
Pin group.
Definition: crossbar.h:627
Definition: nuts_bolts.h:130
Definition: crossbar.h:502
uint16_t output
Definition: crossbar.h:506
uint16_t irq_mode
Definition: crossbar.h:509
uint16_t debounce
Definition: crossbar.h:515
uint16_t pwm
Definition: crossbar.h:512
uint16_t open_drain
Definition: crossbar.h:507
uint16_t mask
Definition: crossbar.h:503
uint16_t input
Definition: crossbar.h:505
uint16_t analog
Definition: crossbar.h:511
uint16_t claimable
Definition: crossbar.h:514
uint16_t invert
Definition: crossbar.h:510
uint16_t pull_mode
Definition: crossbar.h:508
uint16_t servo_pwm
Definition: crossbar.h:513
Definition: crossbar.h:653
uint8_t qei_select
Definition: crossbar.h:659
uint8_t aux_inputs
Definition: crossbar.h:657
uint8_t limits
Definition: crossbar.h:656
uint8_t unassigned
Definition: crossbar.h:660
uint8_t mask
Definition: crossbar.h:654
uint8_t safety_door
Definition: crossbar.h:658
Definition: crossbar.h:519
uint16_t output
Definition: crossbar.h:523
uint16_t irq_mode
Definition: crossbar.h:526
uint16_t claimed
Definition: crossbar.h:531
uint16_t debounce
Definition: crossbar.h:532
uint16_t pwm
Definition: crossbar.h:529
uint16_t open_drain
Definition: crossbar.h:524
uint16_t mask
Definition: crossbar.h:520
uint16_t input
Definition: crossbar.h:522
uint16_t analog
Definition: crossbar.h:528
uint16_t inverted
Definition: crossbar.h:527
uint16_t pull_mode
Definition: crossbar.h:525
uint16_t servo_pwm
Definition: crossbar.h:530
Definition: crossbar.h:593
pwm_config_t * pwm_config
Definition: crossbar.h:594
gpio_out_config_t * gpio_out_config
Definition: crossbar.h:596
gpio_in_config_t * gpio_in_config
Definition: crossbar.h:595