@@ -53,6 +53,7 @@ typedef struct motor_hardware_struct {
53
53
stepper_hardware_t motor_z ;
54
54
stepper_hardware_t motor_l ;
55
55
platform_sensor_t platform_sensors ;
56
+ PinConfig estop ;
56
57
} motor_hardware_t ;
57
58
58
59
@@ -92,6 +93,7 @@ static motor_hardware_t _motor_hardware = {
92
93
.x_minus = {PLAT_SENSE_MINUS_PORT , PLAT_SENSE_MINUS_PIN , GPIO_PIN_SET },
93
94
.x_plus = {PLAT_SENSE_PLUS_PORT , PLAT_SENSE_PLUS_PIN , GPIO_PIN_SET },
94
95
},
96
+ .estop = {N_ESTOP_PORT , N_ESTOP_PIN , GPIO_PIN_RESET },
95
97
};
96
98
97
99
void motor_hardware_gpio_init (void ){
@@ -179,9 +181,6 @@ void motor_hardware_gpio_init(void){
179
181
init .Pin = L_N_RELEASED_PIN ;
180
182
HAL_GPIO_Init (L_N_RELEASED_PORT , & init );
181
183
182
- init .Pin = ESTOP_PIN ;
183
- HAL_GPIO_Init (ESTOP_PORT , & init );
184
-
185
184
/*Configure GPIO pins : INPUTs IRQ */
186
185
init .Mode = GPIO_MODE_IT_FALLING ;
187
186
init .Pull = GPIO_PULLUP ;
@@ -190,6 +189,11 @@ void motor_hardware_gpio_init(void){
190
189
init .Pin = MOTOR_DIAG0_PIN ;
191
190
HAL_GPIO_Init (MOTOR_DIAG0_PORT , & init );
192
191
HAL_NVIC_SetPriority (EXTI15_10_IRQn , 6 , 0 );
192
+
193
+ init .Pin = N_ESTOP_PIN ;
194
+ HAL_GPIO_Init (N_ESTOP_PORT , & init );
195
+ HAL_NVIC_SetPriority (EXTI9_5_IRQn , 0 , 0 );
196
+ HAL_NVIC_EnableIRQ (EXTI9_5_IRQn );
193
197
}
194
198
195
199
// X motor timer
@@ -394,12 +398,25 @@ bool hw_read_platform_sensor(bool direction) {
394
398
_motor_hardware .platform_sensors .x_minus .active_setting ;
395
399
}
396
400
401
+ bool hw_read_estop (void ) {
402
+ return HAL_GPIO_ReadPin (_motor_hardware .estop .port , _motor_hardware .estop .pin ) ==
403
+ _motor_hardware .estop .active_setting ;
404
+ }
405
+
397
406
void hw_set_diag0_irq (bool enable ) {
398
407
enable ?
399
408
HAL_NVIC_EnableIRQ (EXTI15_10_IRQn ) :
400
409
HAL_NVIC_DisableIRQ (EXTI15_10_IRQn );
401
410
}
402
411
412
+ bool hw_is_diag0_pin (uint16_t pin ) {
413
+ return pin == MOTOR_DIAG0_PIN ;
414
+ }
415
+
416
+ bool hw_is_estop_pin (uint16_t pin ) {
417
+ return pin == N_ESTOP_PIN ;
418
+ }
419
+
403
420
void TIM3_IRQHandler (void )
404
421
{
405
422
HAL_TIM_IRQHandler (& _motor_hardware .motor_l .timer );
0 commit comments