stm32f3: i2c support increased. Now it works.
- Several functions added (that only work on the f3) - The data register now has a 8bit access counter part that is necessary for 8bit transmissions, together with the access functions. - The init master functions doesn't work for the f3.
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
9b2873d874
commit
011124c33f
@@ -119,6 +119,8 @@ spi_lsbfirst.
|
||||
@returns int. Error code.
|
||||
*/
|
||||
|
||||
#ifndef STM32F3
|
||||
|
||||
int spi_init_master(uint32_t spi, uint32_t br, uint32_t cpol, uint32_t cpha,
|
||||
uint32_t dff, uint32_t lsbfirst)
|
||||
{
|
||||
@@ -142,6 +144,8 @@ int spi_init_master(uint32_t spi, uint32_t br, uint32_t cpol, uint32_t cpha,
|
||||
return 0; /* TODO */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* TODO: Error handling? */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief SPI Enable.
|
||||
@@ -394,7 +398,47 @@ void spi_set_next_tx_from_crc(uint32_t spi)
|
||||
SPI_CR1(spi) |= SPI_CR1_CRCNEXT;
|
||||
}
|
||||
|
||||
#if !defined(STM32F3)
|
||||
#ifdef STM32F3
|
||||
|
||||
void spi_send8(uint32_t spi, uint8_t data)
|
||||
{
|
||||
/* Wait for transfer finished. */
|
||||
while (!(SPI_SR(spi) & SPI_SR_TXE));
|
||||
|
||||
/* Write data (8 or 16 bits, depending on DFF) into DR. */
|
||||
SPI_DR8(spi) = data;
|
||||
}
|
||||
|
||||
uint8_t spi_read8(uint32_t spi)
|
||||
{
|
||||
/* Wait for transfer finished. */
|
||||
while (!(SPI_SR(spi) & SPI_SR_RXNE));
|
||||
|
||||
/* Read the data (8 or 16 bits, depending on DFF bit) from DR. */
|
||||
return SPI_DR8(spi);
|
||||
}
|
||||
|
||||
void spi_set_data_size(uint32_t spi, uint16_t data_s)
|
||||
{
|
||||
SPI_CR2(spi) = (SPI_CR2(spi) & ~SPI_CR2_DS_MASK) | (data_s & SPI_CR2_DS_MASK);
|
||||
}
|
||||
|
||||
void spi_fifo_reception_threshold_8bit(uint32_t spi)
|
||||
{
|
||||
SPI_CR2(spi) |= SPI_CR2_FRXTH;
|
||||
}
|
||||
|
||||
void spi_fifo_reception_threshold_16bit(uint32_t spi)
|
||||
{
|
||||
SPI_CR2(spi) &= ~SPI_CR2_FRXTH;
|
||||
}
|
||||
|
||||
void spi_i2s_mode_spi_mode(uint32_t spi)
|
||||
{
|
||||
SPI_I2SCFGR(spi) &= ~SPI_I2SCFGR_I2SMOD;
|
||||
}
|
||||
|
||||
#else /*STM32F3*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief SPI Set Data Frame Format to 8 bits
|
||||
|
||||
Reference in New Issue
Block a user