Skip to content

Commit

Permalink
add custom IO initialization code
Browse files Browse the repository at this point in the history
- add custom IO initialization code (overridable)
  • Loading branch information
Paciente8159 committed Mar 26, 2024
1 parent 76ac6d3 commit 52a9543
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions uCNC/src/cnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void cnc_init(void)
cnc_state.loop_state = LOOP_STARTUP_RESET;
// initializes all systems
mcu_init(); // mcu
mcu_io_reset(); // add custom logic to set pins initial state
io_enable_steppers(~g_settings.step_enable_invert); // disables steppers at start
io_disable_probe(); // forces probe isr disabling
serial_init(); // serial
Expand Down
8 changes: 7 additions & 1 deletion uCNC/src/hal/mcus/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,12 @@ void __attribute__((weak)) mcu_io_init(void)
#endif
}

#ifndef mcu_io_reset
void __attribute__((weak)) mcu_io_reset(void)
{
}
#endif

#ifdef BOARD_HAS_CUSTOM_SYSTEM_COMMANDS
uint8_t __attribute__((weak)) mcu_custom_grbl_cmd(uint8_t *grbl_cmd_str, uint8_t grbl_cmd_len, uint8_t next_char)
{
Expand Down Expand Up @@ -776,7 +782,7 @@ MCU_RX_CALLBACK void __attribute__((weak)) mcu_uart_rx_cb(uint8_t c) {}

#ifdef MCU_HAS_UART2
#ifdef DETACH_UART2_FROM_MAIN_PROTOCOL
MCU_RX_CALLBACK void __attribute__((weak)) mcu_uart2_rx_cb(uint8_t c){}
MCU_RX_CALLBACK void __attribute__((weak)) mcu_uart2_rx_cb(uint8_t c) {}
#endif
#endif

Expand Down
7 changes: 7 additions & 0 deletions uCNC/src/hal/mcus/mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ extern "C"
* */
void mcu_io_init(void);

/**
* This can be used to set the defaults state of IO pins on reset. (overridable)
* */
#ifndef mcu_io_reset
void mcu_io_reset(void);
#endif

/**
* initializes the mcu
* this function needs to:
Expand Down

0 comments on commit 52a9543

Please sign in to comment.