Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
spi.h
Go to the documentation of this file.
1 #pragma once
3 #include <inttypes.h>
4 #include "gpio.h"
5 
6 #ifdef __AVR__
7 #define SPI0 ((hal::spi::SPI_TypeDef *const) & SPCR)
8 #endif
9 
10 namespace hal {
11 
13 namespace spi {
14 
15 struct SPI_TypeDef {
16  volatile uint8_t SPCRx;
17  volatile uint8_t SPSRx;
18  volatile uint8_t SPDRx;
19 };
20 
22  hal::gpio::GPIO_pin miso_pin;
23  hal::gpio::GPIO_pin mosi_pin;
24  hal::gpio::GPIO_pin sck_pin;
25  hal::gpio::GPIO_pin ss_pin;
26  uint8_t prescaler;
27  uint8_t cpha;
28  uint8_t cpol;
29 };
30 
31 void Init(SPI_TypeDef *const hspi, SPI_InitTypeDef *const conf);
32 
33 uint8_t TxRx(SPI_TypeDef *hspi, uint8_t val);
34 
35 #ifdef __AVR__
36 static SPI_TypeDef *const TmcSpiBus = SPI0;
37 #else
38 static SPI_TypeDef *const TmcSpiBus = nullptr;
39 #endif
40 
41 }
42 }
Definition: gpio.h:51
Definition: spi.h:21
Definition: spi.h:15