TMCStepper
TMC_platforms.h
Go to the documentation of this file.
1 #if defined(ARDUINO_ARCH_AVR) // 125kHz
2  typedef volatile uint8_t* fastio_reg;
3  typedef uint8_t fastio_bm;
4  #define getPort(P) digitalPinToPort(P)
5  #define writeMOSI_H *mosi_register |= mosi_bm
6  #define writeMOSI_L *mosi_register &= ~mosi_bm
7  #define writeSCK_H *sck_register |= sck_bm
8  #define writeSCK_L *sck_register &= ~sck_bm
9  #define readMISO *miso_register & miso_bm
10 #elif defined(ARDUINO_ARCH_SAM) // DUE:700kHz
11  // by stimmer https://forum.arduino.cc/index.php?topic=129868.msg980466#msg980466
12  #define writeMOSI_H g_APinDescription[mosi_pin].pPort -> PIO_SODR = g_APinDescription[mosi_pin].ulPin
13  #define writeMOSI_L g_APinDescription[mosi_pin].pPort -> PIO_CODR = g_APinDescription[mosi_pin].ulPin
14  #define writeSCK_H g_APinDescription[sck_pin].pPort -> PIO_SODR = g_APinDescription[sck_pin].ulPin
15  #define writeSCK_L g_APinDescription[sck_pin].pPort -> PIO_CODR = g_APinDescription[sck_pin].ulPin
16  #define readMISO PIO_Get( g_APinDescription[miso_pin].pPort, PIO_INPUT, g_APinDescription[miso_pin].ulPin )
17 #elif defined(TARGET_LPC1768)
18  //typedef volatile LPC_GPIO_TypeDef* fastio_reg;
19  //typedef uint32_t fastio_bm;
20  #define writeMOSI_H LPC176x::gpio_set(mosi_pin)
21  #define writeMOSI_L LPC176x::gpio_clear(mosi_pin)
22  #define writeSCK_H LPC176x::delay_ns(240); LPC176x::gpio_set(sck_pin)
23  #define writeSCK_L LPC176x::delay_ns(240); LPC176x::gpio_clear(sck_pin)
24  #define readMISO LPC176x::gpio_get(miso_pin)
25 #elif defined(__STM32F1__) || defined(TARGET_STM32F1)
26  #define writeMOSI_H digitalWrite(mosi_pin, HIGH)
27  #define writeMOSI_L digitalWrite(mosi_pin, LOW)
28  #define writeSCK_H digitalWrite(sck_pin, HIGH)
29  #define writeSCK_L digitalWrite(sck_pin, LOW)
30  #define readMISO digitalRead(miso_pin)
31 #else // DUE:116kHz
32  #define writeMOSI_H digitalWrite(mosi_pin, HIGH)
33  #define writeMOSI_L digitalWrite(mosi_pin, LOW)
34  #define writeSCK_H digitalWrite(sck_pin, HIGH)
35  #define writeSCK_L digitalWrite(sck_pin, LOW)
36  #define readMISO digitalRead(miso_pin)
37 #endif