The SPI interface needs to be enabled and configured to the correct settings of a given oid before CS is asserted. The new function spi_prepare() allows ports to do that. This port only introduces the new function in all ports with no implementation and adds the call to the Klipper generic firmware code. That means everything still works as before. Ports need to be changed to fix the underlying issue. Discussion about the motivation here: https://github.com/KevinOConnor/klipper/pull/453#issuecomment-403131149 Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
#ifndef __STM32F1_GPIO_H
|
|
#define __STM32F1_GPIO_H
|
|
|
|
#include <stdint.h>
|
|
#include "stm32f1xx.h"
|
|
|
|
void gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up);
|
|
|
|
struct gpio_out {
|
|
GPIO_TypeDef *regs;
|
|
uint32_t bit;
|
|
};
|
|
struct gpio_out gpio_out_setup(uint8_t pin, uint8_t val);
|
|
void gpio_out_toggle_noirq(struct gpio_out g);
|
|
void gpio_out_toggle(struct gpio_out g);
|
|
void gpio_out_write(struct gpio_out g, uint8_t val);
|
|
|
|
struct gpio_in {
|
|
GPIO_TypeDef *regs;
|
|
uint32_t bit;
|
|
};
|
|
struct gpio_in gpio_in_setup(uint8_t pin, int8_t pull_up);
|
|
uint8_t gpio_in_read(struct gpio_in g);
|
|
|
|
struct gpio_adc {
|
|
uint32_t bit;
|
|
};
|
|
struct gpio_adc gpio_adc_setup(uint8_t pin);
|
|
uint32_t gpio_adc_sample(struct gpio_adc g);
|
|
uint16_t gpio_adc_read(struct gpio_adc g);
|
|
void gpio_adc_cancel_sample(struct gpio_adc g);
|
|
|
|
struct spi_config {
|
|
SPI_TypeDef config;
|
|
};
|
|
struct spi_config spi_setup(uint32_t bus, uint8_t mode, uint32_t rate);
|
|
void spi_prepare(struct spi_config config);
|
|
void spi_transfer(struct spi_config config, uint8_t receive_data,
|
|
uint8_t len, uint8_t *data);
|
|
|
|
#endif // gpio.h
|