1 #ifndef STM32F103CB_SPI_H_ 2 #define STM32F103CB_SPI_H_ 39 #include <libopencm3/stm32/f1/spi.h> 42 #define SPI_DEFAULT_SPEED SPI_SPEED_8 43 #define SPI_DEFAULT_CLOCK SPI_CLOCK_HIGH 44 #define SPI_DEFAULT_PHASE SPI_PHASE_SECOND 45 #define SPI_DEFAULT_DATA SPI_DATA_8 46 #define SPI_DEFAULT_ENDIAN SPI_MSB 283 spi_csPol polarity, uint16_t address, uint16_t data);
295 spi_csPol polarity, uint16_t address, uint16_t *data, uint16_t count);
319 spi_csPol polarity, uint16_t address, uint16_t *data, uint16_t count);
gpio_port
GPIO ports available for the MCU.
mcu_error SPI_setClockPolarity(spi_periph periph, spi_clock polarity)
Sets the polarity of the clock during the idle state.
The second SPI peripheral.
mcu_error SPI_setDataFrame(spi_periph periph, spi_data data)
Sets the size of the data frame for one transmission.
Header file for stm32f103cb DEBUG.
Header file for stm32f103 GPIO.
mcu_error SPI_enableTxISR(spi_periph periph, void(*handler)(void))
Enable the peripheral's transmit interrupt.
spi_speed
Clock rates for the serial clock.
spi_u16_fp_v SPI_getGetAdd(spi_periph periph)
Get the function address of the get function for the port.
spi_v_fp_u16 SPI_getPutAdd(spi_periph periph)
Get the function address of the put function for the port.
One data frame is 16 bits.
One data frame is 8 bits.
void SPI_write(spi_periph periph, gpio_port port, gpio_pin pin, spi_csPol polarity, uint16_t address, uint16_t data)
Write a data frame to a slave device using standard protocole.
Captured on first transition.
spi_clock
The idle state the clock line is left with no activity.
Maximum 32MHz serial clock.
Captured on second transition.
Maximum 4MHz serial clock.
mcu_error SPI_setPhase(spi_periph periph, spi_phase phase)
Sets the phase of the clock.
void(* spi_v_fp_u16)(uint16_t)
Funtion point typedef for void(*fp)(uint8_t)
spi_data
The number of data bits send in one transmission.
gpio_pin
GPIO pins available for each port.
spi_csPol
The polarity of the chip select pin.
mcu_error SPI_setSpeed(spi_periph periph, spi_speed speed)
Sets the speed of the serial clock.
mcu_error SPI_enableRxISR(spi_periph periph, void(*handler)(uint16_t))
Enable the peripheral's receive interrupt.
Maximum 500KHz serial clock.
mcu_error SPI_setEndian(spi_periph periph, spi_endian endian)
Sets order of the transmitted data frame.
mcu_error SPI_disableTxISR(spi_periph periph)
Disable the peripheral's transmit interrupt.
spi_endian
Byte order for send data.
Maximum 8MHz serial clock.
Chip select pin is active high.
uint16_t SPI_read(spi_periph periph, gpio_port port, gpio_pin pin, spi_csPol polarity, uint16_t address)
Read a data frame from the slave device using standard protocole.
Chip select pin is active low.
void SPI_repeatRead(spi_periph periph, gpio_port port, gpio_pin pin, spi_csPol polarity, uint16_t address, uint16_t *data, uint16_t count)
Read multiple data frames from the slave device using standard protocole.
mcu_error SPI_setup(spi_periph periph)
Sets up the SPI peripheral with standard setting doneted with macro defines.
uint16_t SPI_get(spi_periph periph)
Recieve a byte from the recieve buffer. (blocking)
Header file for stm32f103 CLOCK.
Maximum 1MHz serial clock.
The first SPI peripheral.
spi_phase
The phase at which the data is captured on the clock line.
mcu_error SPI_disableRxISR(spi_periph periph)
Disable the peripheral's receive interrupt.
Maximum 16MHz serial clock.
void SPI_repeatWrite(spi_periph periph, gpio_port port, gpio_pin pin, spi_csPol polarity, uint16_t address, uint16_t *data, uint16_t count)
Write multiple data frames to a slave device using standard protocole.
spi_periph
Peripheral SPI ports available.
Maximum 250KHz serial clock.
uint16_t(* spi_u16_fp_v)(void)
Funtion point typedef for void(*fp)(void)
mcu_error SPI_put(spi_periph periph, uint16_t data)
Send one data frame on the data bus. (blocking)
mcu_error
Error enumerators for the Debug peripheral.