diff --git a/g2core/board/G2v9/board_gpio.cpp b/g2core/board/G2v9/board_gpio.cpp index 4daf011d..6eb45c10 100644 --- a/g2core/board/G2v9/board_gpio.cpp +++ b/g2core/board/G2v9/board_gpio.cpp @@ -56,40 +56,40 @@ /**** Setup Actual Objects ****/ -gpioDigitalInputPin> din1 {DI1_MODE, 1}; -gpioDigitalInputPin> din2 {DI2_MODE, 2}; -gpioDigitalInputPin> din3 {DI3_MODE, 3}; -gpioDigitalInputPin> din4 {DI4_MODE, 4}; -gpioDigitalInputPin> din5 {DI5_MODE, 5}; -gpioDigitalInputPin> din6 {DI6_MODE, 6}; -gpioDigitalInputPin> din7 {DI7_MODE, 7}; -gpioDigitalInputPin> din8 {DI8_MODE, 8}; -gpioDigitalInputPin> din9 {DI9_MODE, 9}; -// gpioDigitalInputPin> din10 {DI10_MODE, 10}; -// gpioDigitalInputPin> din11 {DI11_MODE, 11}; -// gpioDigitalInputPin> din12 {DI12_MODE, 12}; -gpioDigitalOutputPin> dout1 { DO1_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout2 { DO2_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout3 { DO3_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout4 { DO4_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout5 { DO5_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout6 { DO6_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout7 { DO7_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout8 { DO8_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout9 { DO9_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout10 { DO10_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout11 { DO11_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout12 { DO12_MODE, (uint32_t)200000 }; -gpioDigitalOutputPin> dout13 { DO13_MODE, (uint32_t)200000 }; - -/**** Setup Arrays - these are extern and MUST match the board_gpio.h ****/ +gpioDigitalInputPin> din1 {DI1_ENABLED, DI1_POLARITY, 1, DI1_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din2 {DI2_ENABLED, DI2_POLARITY, 2, DI2_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din3 {DI3_ENABLED, DI3_POLARITY, 3, DI3_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din4 {DI4_ENABLED, DI4_POLARITY, 4, DI4_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din5 {DI5_ENABLED, DI5_POLARITY, 5, DI5_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din6 {DI6_ENABLED, DI6_POLARITY, 6, DI6_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din7 {DI7_ENABLED, DI7_POLARITY, 7, DI7_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din8 {DI8_ENABLED, DI8_POLARITY, 8, DI8_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +gpioDigitalInputPin> din9 {DI9_ENABLED, DI9_POLARITY, 9, DI9_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +// gpioDigitalInputPin> din10 {DI10_ENABLED, DI10_POLARITY, 10, DI10_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +// gpioDigitalInputPin> din11 {DI11_ENABLED, DI11_POLARITY, 11, DI11_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; +// gpioDigitalInputPin> din12 {DI12_ENABLED, DI12_POLARITY, 12, DI12_EXTERNAL_NUMBER, Motate::kPinInterruptOnChange|Motate::kPinInterruptPriorityHigh}; gpioDigitalInput* const d_in[] = {&din1, &din2, &din3, &din4, &din5, &din6, &din7, &din8, &din9}; + + +gpioDigitalOutputPin> dout1 { DO1_ENABLED, DO1_POLARITY, DO1_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout2 { DO2_ENABLED, DO2_POLARITY, DO2_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout3 { DO3_ENABLED, DO3_POLARITY, DO3_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout4 { DO4_ENABLED, DO4_POLARITY, DO4_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout5 { DO5_ENABLED, DO5_POLARITY, DO5_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout6 { DO6_ENABLED, DO6_POLARITY, DO6_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout7 { DO7_ENABLED, DO7_POLARITY, DO7_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout8 { DO8_ENABLED, DO8_POLARITY, DO8_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout9 { DO9_ENABLED, DO9_POLARITY, DO9_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout10 { DO10_ENABLED, DO10_POLARITY, DO10_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout11 { DO11_ENABLED, DO11_POLARITY, DO11_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout12 { DO12_ENABLED, DO12_POLARITY, DO12_EXTERNAL_NUMBER, (uint32_t)200000 }; +gpioDigitalOutputPin> dout13 { DO13_ENABLED, DO13_POLARITY, DO13_EXTERNAL_NUMBER, (uint32_t)200000 }; + gpioDigitalOutput* const d_out[] = {&dout1, &dout2, &dout3, &dout4, &dout5, &dout6, &dout7, &dout8, &dout9, &dout10, &dout11, &dout12, &dout13}; -// not yet used -// gpioAnalogInput* a_in[A_IN_CHANNELS]; -// gpioAnalogOutput* a_out[A_OUT_CHANNELS]; + +gpioAnalogInput* const a_in[] = {}; /************************************************************************************ **** CODE ************************************************************************** diff --git a/g2core/board/G2v9/board_gpio.h b/g2core/board/G2v9/board_gpio.h index 25a1cddc..9b748098 100644 --- a/g2core/board/G2v9/board_gpio.h +++ b/g2core/board/G2v9/board_gpio.h @@ -56,7 +56,7 @@ extern gpioDigitalOutput* const d_out[D_OUT_CHANNELS]; using Motate::IRQPin; using Motate::PWMOutputPin; using Motate::PWMLikeOutputPin; -template +template using OutputType = typename std::conditional, PWMLikeOutputPin>::type; extern gpioDigitalInputPin> din1; diff --git a/g2core/board/G2v9/board_stepper.h b/g2core/board/G2v9/board_stepper.h index fde1f4f5..ce20ca9a 100644 --- a/g2core/board/G2v9/board_stepper.h +++ b/g2core/board/G2v9/board_stepper.h @@ -88,6 +88,8 @@ extern StepDirStepper XIOUSBDevice_t; +typedef Motate::USBDevice< Motate::USBDeviceHardware, Motate::USBCDC > XIOUSBDevice_t; #endif #if USB_SERIAL_PORTS_EXPOSED == 2 -typedef Motate::USBDevice< USBDeviceHardware, Motate::USBCDC, Motate::USBCDC > XIOUSBDevice_t; +typedef Motate::USBDevice< Motate::USBDeviceHardware, Motate::USBCDC, Motate::USBCDC > XIOUSBDevice_t; #endif extern XIOUSBDevice_t usb; diff --git a/g2core/board/G2v9/hardware.h b/g2core/board/G2v9/hardware.h index 105e8e5d..b97a1f28 100644 --- a/g2core/board/G2v9/hardware.h +++ b/g2core/board/G2v9/hardware.h @@ -106,6 +106,9 @@ using Motate::OutputPin; #define FREQUENCY_DDA 150000UL // Hz step frequency. Interrupts actually fire at 2x (300 KHz) #define FREQUENCY_DWELL 1000UL +#define PLANNER_QUEUE_SIZE (48) +#define SECONDARY_QUEUE_SIZE (10) + /**** Motate Definitions ****/ // Timer definitions. See stepper.h and other headers for setup diff --git a/g2core/device/step_dir_driver/step_dir_driver.h b/g2core/device/step_dir_driver/step_dir_driver.h index 813de444..e8ec0e7d 100644 --- a/g2core/device/step_dir_driver/step_dir_driver.h +++ b/g2core/device/step_dir_driver/step_dir_driver.h @@ -32,6 +32,7 @@ #include "MotateTimers.h" #include "stepper.h" +#include "gpio.h" // for ioPolarity using Motate::pin_number; using Motate::OutputPin; @@ -67,11 +68,11 @@ struct StepDirStepper final : Stepper { OutputPin _ms2; PWMOutputPin _vref; - ioMode _step_polarity; // IO_ACTIVE_LOW or IO_ACTIVE_HIGH - ioMode _enable_polarity; // IO_ACTIVE_LOW or IO_ACTIVE_HIGH + ioPolarity _step_polarity; // IO_ACTIVE_LOW or IO_ACTIVE_HIGH + ioPolarity _enable_polarity; // IO_ACTIVE_LOW or IO_ACTIVE_HIGH // sets default pwm freq for all motor vrefs (commented line below also sets HiZ) - StepDirStepper(ioMode step_polarity, ioMode enable_polarity, const uint32_t frequency = 250000) : + StepDirStepper(ioPolarity step_polarity, ioPolarity enable_polarity, const uint32_t frequency = 250000) : Stepper{}, _step{step_polarity==IO_ACTIVE_LOW?kStartHigh:kStartLow}, _enable{enable_polarity==IO_ACTIVE_LOW?kStartHigh:kStartLow}, @@ -179,23 +180,23 @@ struct StepDirStepper final : Stepper { } }; - ioMode getStepPolarity() const override + ioPolarity getStepPolarity() const override { return _step_polarity; }; - void setStepPolarity(ioMode new_sp) override + void setStepPolarity(ioPolarity new_sp) override { _step_polarity = new_sp; stepEnd(); }; - ioMode getEnablePolarity() const override + ioPolarity getEnablePolarity() const override { return _enable_polarity; }; - void setEnablePolarity(ioMode new_mp) override + void setEnablePolarity(ioPolarity new_mp) override { _enable_polarity = new_mp; // this is a misnomer, but handles the logic we need for asserting the newly adjusted enable line correctly