Implement PIO-Pulser as Class for two channels Channel

This commit is contained in:
AlexanderHD27
2024-09-25 18:12:19 +02:00
parent 9640a5b747
commit bba35c9622
5 changed files with 269 additions and 3 deletions

View File

@@ -14,6 +14,7 @@
#include "hardware/uart.h"
#include "pulser.pio.h"
#include "tmc2209/step.hpp"
#define LED_PIN 25
@@ -26,6 +27,7 @@
#define DIR1_PIN 9
int main() {
/*
gpio_init(ENABLE0_PIN);
gpio_set_dir(ENABLE0_PIN, GPIO_OUT);
gpio_put(ENABLE0_PIN, 0);
@@ -50,7 +52,7 @@ int main() {
gpio_set_dir(DIR1_PIN, GPIO_OUT);
gpio_put(DIR1_PIN, 0);
PIO pio_core = pio0;
int SM_DIV0 = 0;
int SM_COUNT0 = 2;
@@ -86,6 +88,19 @@ int main() {
const double double_div_freq_khz = 0.5;
const uint32_t cycles = (target_freq_khz/double_div_freq_khz) - 6;
pio_sm_put_blocking(pio_core, SM_DIV0, cycles);
*/
TMC2209_step_dual step_driver = TMC2209_step_dual(STEP0_PIN, STEP1_PIN, DIR0_PIN, DIR1_PIN, ENABLE0_PIN, ENABLE1_PIN, pio0);
step_driver.set_conf0(5000, 0);
step_driver.set_conf1(10000, 0);
step_driver.pulse0(UINT32_MAX - 10);
sleep_ms(5);
step_driver.pulse1(UINT32_MAX - 10);
step_driver.pulse0(5);
sleep_ms(3);
//step_driver.pulse0(5);
step_driver.pulse1(5);
TMC2209_UART uart_driver0 = TMC2209_UART(uart0, 0, 19200, 0, 1);
TMC2209_UART uart_driver1 = TMC2209_UART(uart1, 0, 19200, 4, 5);