Implemented TMC2209 Register Read/Write
This commit is contained in:
@@ -9,6 +9,68 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tmc2209/tmc2209.hpp"
|
||||
#include "pico/stdio.h"
|
||||
#include "hardware/uart.h"
|
||||
|
||||
#define LED_PIN 25
|
||||
|
||||
#define ENABLE0_PIN 2
|
||||
#define ENABLE1_PIN 3
|
||||
|
||||
#define STEP0_PIN 6
|
||||
#define STEP1_PIN 7
|
||||
#define DIR0_PIN 8
|
||||
#define DIR1_PIN 9
|
||||
|
||||
int main() {
|
||||
gpio_init(ENABLE0_PIN);
|
||||
gpio_set_dir(ENABLE0_PIN, GPIO_OUT);
|
||||
gpio_put(ENABLE0_PIN, 0);
|
||||
|
||||
gpio_init(ENABLE1_PIN);
|
||||
gpio_set_dir(ENABLE1_PIN, GPIO_OUT);
|
||||
gpio_put(ENABLE1_PIN, 0);
|
||||
|
||||
gpio_init(STEP0_PIN);
|
||||
gpio_set_dir(STEP0_PIN, GPIO_OUT);
|
||||
gpio_put(STEP0_PIN, 0);
|
||||
|
||||
gpio_init(STEP1_PIN);
|
||||
gpio_set_dir(STEP1_PIN, GPIO_OUT);
|
||||
gpio_put(STEP1_PIN, 0);
|
||||
|
||||
gpio_init(DIR0_PIN);
|
||||
gpio_set_dir(DIR0_PIN, GPIO_OUT);
|
||||
gpio_put(DIR0_PIN, 0);
|
||||
|
||||
gpio_init(DIR1_PIN);
|
||||
gpio_set_dir(DIR1_PIN, GPIO_OUT);
|
||||
gpio_put(DIR1_PIN, 0);
|
||||
|
||||
TMC2209_UART uart_driver0 = TMC2209_UART(uart0, 0, 19200, 0, 1);
|
||||
TMC2209_UART uart_driver1 = TMC2209_UART(uart1, 0, 19200, 4, 5);
|
||||
uart_driver0.init();
|
||||
uart_driver1.init();
|
||||
|
||||
sleep_ms(100);
|
||||
|
||||
volatile uint32_t res1 = uart_driver1.read(0x00);
|
||||
volatile uint32_t res0 = uart_driver0.read(0x00);
|
||||
|
||||
//TMC2209_Registers registers(uart_driver);
|
||||
//registers.read_all_state();
|
||||
|
||||
gpio_init(LED_PIN);
|
||||
gpio_set_dir(LED_PIN, GPIO_OUT);
|
||||
|
||||
while (true) {
|
||||
sleep_ms(50);
|
||||
gpio_put(LED_PIN, 1);
|
||||
sleep_ms(50);
|
||||
gpio_put(LED_PIN, 0);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user