Skip to content

Commit

Permalink
Updated for refactored spindle handling and configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Dec 12, 2023
1 parent d65df30 commit d866647
Show file tree
Hide file tree
Showing 37 changed files with 11,219 additions and 887 deletions.
594 changes: 151 additions & 443 deletions .cproject

Large diffs are not rendered by default.

900 changes: 900 additions & 0 deletions Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc.h

Large diffs are not rendered by default.

409 changes: 409 additions & 0 deletions Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h

Large diffs are not rendered by default.

4,781 changes: 4,781 additions & 0 deletions Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_adc.h

Large diffs are not rendered by default.

2,109 changes: 2,109 additions & 0 deletions Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c

Large diffs are not rendered by default.

1,114 changes: 1,114 additions & 0 deletions Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions Inc/MCP3221.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
MCP3221.h - analog input from a MCP3221 I2C ADC
Driver code for STM32F4xx processors
Part of grblHAL
Copyright (c) 2021-2023 Terje Io
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

bool MCP3221_init (void);
uint16_t MCP3221_read (void);

/*EOF*/
32 changes: 24 additions & 8 deletions Inc/blackpill_alt2_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,31 @@
#define AUXOUTPUT2_PIN 15
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 2
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 10
// Define driver spindle pins

// Define spindle PWM output pin.
#if DRIVER_SPINDLE_PWM_ENABLE
#define SPINDLE_PWM_PORT_BASE GPIOA_BASE
#define SPINDLE_PWM_PIN 8
#else
#define AUXOUTPUT3_PORT GPIOA
#define AUXOUTPUT3_PIN 8
#endif

#if DRIVER_SPINDLE_DIR_ENABLE
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 10
#else
#define AUXOUTPUT4_PORT GPIOB
#define AUXOUTPUT4_PIN 10
#endif

#if DRIVER_SPINDLE_ENABLE
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 2
#else
#define AUXOUTPUT5_PORT GPIOB
#define AUXOUTPUT5_PIN 2
#endif

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOC
Expand All @@ -138,7 +154,7 @@
#elif I2C_STROBE_ENABLE
#define I2C_STROBE_PORT GPIOA
#define I2C_STROBE_PIN 1
#elif SPINDLE_SYNC_ENABLE && N_ABC_MOTORS == 1
#elif SPINDLE_ENCODER_ENABLE && N_ABC_MOTORS == 1
#define AUXOUTPUT0_PORT GPIOA
#define AUXOUTPUT0_PIN 1
#else
Expand All @@ -152,7 +168,7 @@
#define PROBE_PIN 5

// Spindle encoder pins.
#if SPINDLE_SYNC_ENABLE
#if SPINDLE_ENCODER_ENABLE
#define RPM_COUNTER_N 2
#define RPM_TIMER_N 3
#define SPINDLE_INDEX_PORT GPIOB
Expand Down
33 changes: 23 additions & 10 deletions Inc/blackpill_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
#endif

#define BOARD_NAME "BlackPill"
//#undef SPINDLE_SYNC_ENABLE
//#define SPINDLE_SYNC_ENABLE 1

// Define step pulse output pins.
#define STEP_PORT GPIOA
Expand Down Expand Up @@ -91,15 +89,31 @@
#endif
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 1
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 2
// Define driver spindle pins

// Define spindle PWM output pin.
#if DRIVER_SPINDLE_PWM_ENABLE
#define SPINDLE_PWM_PORT_BASE GPIOA_BASE
#define SPINDLE_PWM_PIN 8
#else
#define AUXOUTPUT2_PORT GPIOA
#define AUXOUTPUT2_PIN 8
#endif

#if DRIVER_SPINDLE_DIR_ENABLE
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 2
#else
#define AUXOUTPUT3_PORT GPIOB
#define AUXOUTPUT3_PIN 2
#endif

#if DRIVER_SPINDLE_ENABLE
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 1
#else
#define AUXOUTPUT4_PORT GPIOB
#define AUXOUTPUT4_PIN 1
#endif

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOC
Expand All @@ -124,7 +138,7 @@
#endif

// Spindle encoder pins.
#if SPINDLE_SYNC_ENABLE
#if SPINDLE_ENCODER_ENABLE

#define RPM_COUNTER_N 2
#define RPM_TIMER_N 3
Expand All @@ -136,7 +150,6 @@
#endif

#if N_ABC_MOTORS == 0
#define HAS_IOPORTS
#if !SAFETY_DOOR_ENABLE
#define AUXINPUT0_PORT GPIOB
#define AUXINPUT0_PIN 9
Expand Down
30 changes: 23 additions & 7 deletions Inc/btt_skr_2.0_dac_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,31 @@
#define M4_ENABLE_PIN 13
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 6 // FAN1
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 5 // FAN2
// Define driver spindle pins

// Define spindle PWM output pin.
#if DRIVER_SPINDLE_PWM_ENABLE // EXP1 - PB0, pin 2
#define SPINDLE_PWM_PORT_BASE GPIOB_BASE
#define SPINDLE_PWM_PIN 0 // EXP1 - PB0, pin 2
#define SPINDLE_PWM_PIN 0
#else
#define AUXOUTPUT0_PORT GPIOB
#define AUXOUTPUT0_PIN 0
#endif

#if DRIVER_SPINDLE_DIR_ENABLE // FAN2
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 5
#else
#define AUXOUTPUT1_PORT GPIOB
#define AUXOUTPUT1_PIN 5
#endif

#if DRIVER_SPINDLE_ENABLE // FAN1
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 6
#else
#define AUXOUTPUT2_PORT GPIOB
#define AUXOUTPUT2_PIN 6
#endif

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOB
Expand Down
32 changes: 24 additions & 8 deletions Inc/btt_skr_2.0_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,34 @@
#define M4_ENABLE_PIN 13
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 6 // FAN1
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 5 // FAN2
// Define driver spindle pins

// Define spindle PWM output pin.
#if DRIVER_SPINDLE_PWM_ENABLE // EXP1 - PB0, pin 2
#define SPINDLE_PWM_PORT_BASE GPIOB_BASE
#define SPINDLE_PWM_PIN 0 // EXP1 - PB0, pin 9
// Alt. spindle output, comment out definitions above and uncomment these to change:
#define SPINDLE_PWM_PIN 0
// Alt. spindle PWM output, comment out definitions above and uncomment these to change:
//#define SPINDLE_PWM_PORT_BASE GPIOE_BASE
//#define SPINDLE_PWM_PIN 5 // SERVOS - PE5, pin 1
#else
#define AUXOUTPUT0_PORT GPIOB
#define AUXOUTPUT0_PIN 0
#endif

#if DRIVER_SPINDLE_DIR_ENABLE // FAN2
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 5
#else
#define AUXOUTPUT1_PORT GPIOB
#define AUXOUTPUT1_PIN 5
#endif

#if DRIVER_SPINDLE_ENABLE // FAN1
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 6
#else
#define AUXOUTPUT2_PORT GPIOB
#define AUXOUTPUT2_PIN 6
#endif

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOB
Expand Down
38 changes: 26 additions & 12 deletions Inc/btt_skr_pro_v1_1_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// IMPORTANT: Control inputs are mapped differently when build is configured for more than 3 axes!

#if N_ABC_MOTORS > 3 || N_AUTO_SQUARED > 1
#if N_ABC_MOTORS > 3 || N_AUTO_SQUARED > 2
#error "Axis configuration is not supported!"
#endif

Expand Down Expand Up @@ -102,8 +102,8 @@
#define M4_STEP_PIN 15
#define M4_DIRECTION_PORT GPIOE
#define M4_DIRECTION_PIN 7
//#define M4_LIMIT_PORT GPIOE // Conflict with X limit switch IRQ
//#define M4_LIMIT_PIN 10
#define M4_LIMIT_PORT GPIOG // NOTE: Cannot use the E1 input due to conflict
#define M4_LIMIT_PIN 5 // with X limit switch IRQ. Using E2 input instead.
#define M4_ENABLE_PORT GPIOA
#define M4_ENABLE_PIN 3
#endif
Expand All @@ -115,21 +115,35 @@
#define M5_STEP_PIN 13
#define M5_DIRECTION_PORT GPIOG
#define M5_DIRECTION_PIN 9
#define M5_LIMIT_PORT GPIOG
#define M5_LIMIT_PIN 5
#define M5_ENABLE_PORT GPIOF
#define M5_ENABLE_PIN 0
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOE
#define SPINDLE_ENABLE_PIN 5 // FAN1
#define SPINDLE_DIRECTION_PORT GPIOE
#define SPINDLE_DIRECTION_PIN 6 // FAN2
// Define driver spindle pins

// Define spindle PWM output pin.
#if DRIVER_SPINDLE_PWM_ENABLE // EXP1 - PA8
#define SPINDLE_PWM_PORT_BASE GPIOA_BASE
#define SPINDLE_PWM_PIN 8 // EXT1 - PA8
#define SPINDLE_PWM_PIN 8
#else
#define AUXOUTPUT0_PORT GPIOA
#define AUXOUTPUT0_PIN 8
#endif

#if DRIVER_SPINDLE_DIR_ENABLE // FAN2
#define SPINDLE_DIRECTION_PORT GPIOE
#define SPINDLE_DIRECTION_PIN 6
#else
#define AUXOUTPUT1_PORT GPIOE
#define AUXOUTPUT1_PIN 6
#endif

#if DRIVER_SPINDLE_ENABLE // FAN1
#define SPINDLE_ENABLE_PORT GPIOE
#define SPINDLE_ENABLE_PIN 5
#else
#define AUXOUTPUT2_PORT GPIOE
#define AUXOUTPUT2_PIN 5
#endif

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOB
Expand Down
28 changes: 22 additions & 6 deletions Inc/cnc3040_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,31 @@
//#define SERIAL1_PORT 1 // GPIOA: TX = 9, RX = 10
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 1
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 0
// Define driver spindle pins

// Define spindle PWM output pin.
#if DRIVER_SPINDLE_PWM_ENABLE
#define SPINDLE_PWM_PORT_BASE GPIOA_BASE
#define SPINDLE_PWM_PIN 8
#else
#define AUXOUTPUT0_PORT GPIOA
#define AUXOUTPUT0_PIN 8
#endif

#if DRIVER_SPINDLE_DIR_ENABLE
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 0
#else
#define AUXOUTPUT1_PORT GPIOB
#define AUXOUTPUT1_PIN 0
#endif

#if DRIVER_SPINDLE_ENABLE
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 1
#else
#define AUXOUTPUT2_PORT GPIOB
#define AUXOUTPUT2_PIN 1
#endif

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOB
Expand Down
28 changes: 22 additions & 6 deletions Inc/cnc_boosterpack_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,31 @@
#endif
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 1
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 0
// Define driver spindle pins

// Define spindle PWM output pin.
#if DRIVER_SPINDLE_PWM_ENABLE
#define SPINDLE_PWM_PORT_BASE GPIOA_BASE
#define SPINDLE_PWM_PIN 8
#else
#define AUXOUTPUT0_PORT GPIOA
#define AUXOUTPUT0_PIN 8
#endif

#if DRIVER_SPINDLE_DIR_ENABLE
#define SPINDLE_DIRECTION_PORT GPIOB
#define SPINDLE_DIRECTION_PIN 0
#else
#define AUXOUTPUT1_PORT GPIOB
#define AUXOUTPUT1_PIN 0
#endif

#if DRIVER_SPINDLE_ENABLE
#define SPINDLE_ENABLE_PORT GPIOB
#define SPINDLE_ENABLE_PIN 1
#else
#define AUXOUTPUT2_PORT GPIOB
#define AUXOUTPUT2_PIN 1
#endif

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOC
Expand Down
Loading

0 comments on commit d866647

Please sign in to comment.