working on master init fuction

spi
polymurph 3 years ago
parent f22ef7450b
commit 78ce1a0ec4

@ -39,6 +39,12 @@ void spiSetMode(spiCH_t spi_hw_ch, spi_mode_t mode)
{ {
SPI_BASE->CR1 &= ~(mode << SPI_CR1_MSTR_Pos); SPI_BASE->CR1 &= ~(mode << SPI_CR1_MSTR_Pos);
SPI_BASE->CR1 |= mode << SPI_CR1_MSTR_Pos; SPI_BASE->CR1 |= mode << SPI_CR1_MSTR_Pos;
// TODO: find out if this is the correct place to set the SSOE bit
SPI_BASE->CR2 &= ~SPI_CR2_SSOE;
if(mode == SPI_MASTER) {
SPI_BASE->CR2 |= SPI_CR2_SSOE;
}
} }
void spiSetPolarity(spiCH_t spi_hw_ch, spi_clkPol_t clkPol) void spiSetPolarity(spiCH_t spi_hw_ch, spi_clkPol_t clkPol)

@ -24,23 +24,17 @@ void spiInitMaster(spiCH_t spi_hw_ch,
spiSetSoftwareSlaveManagement(spi_hw_ch,1); spiSetSoftwareSlaveManagement(spi_hw_ch,1);
spiSetInternalSlaveSelect(spi_hw_ch,0); spiSetInternalSlaveSelect(spi_hw_ch,0);
//SPI1->CR1 &= ~(1<<10); // RXONLY = 0, full-duplex //SPI1->CR1 &= ~(1<<10); // RXONLY = 0, full-duplex
//SPI_BASE->CR1 &= ~(1<<10); //SPI_BASE->CR1 &= ~(1<<10);
spiSetComMode(spi_hw_ch, comMode); spiSetComMode(spi_hw_ch, comMode);
//TODO: test this for relevance of functionality. Leave it away, compilw it and run it
//SPI1->CR1 &= ~(1<<11); // CRCL =0, 8 bit data
//SPI_BASE->CR1 |= SPI_CR1_CRCL;
spiSetClockPrescaler(spi_hw_ch, prescaler); spiSetClockPrescaler(spi_hw_ch, prescaler);
spiSetBitFrameLength(spi_hw_ch, SPI_FRAME_LENGTH_8BIT); spiSetBitFrameLength(spi_hw_ch, SPI_FRAME_LENGTH_8BIT);
// TODO: find out what SSOE does // TODO: find out what SSOE does
// TODO: find out what FRXTH does // TODO: find out what FRXTH does
SPI_BASE->CR2 |= SPI_CR2_SSOE;// | SPI_CR2_FRXTH;// | SPI_CR2_DS_0 | SPI_CR2_DS_1 | SPI_CR2_DS_2; //SPI_BASE->CR2 |= SPI_CR2_SSOE;
} }
void spiSetupCH(spi_ch_t *ch, spiCH_t spi_hw_ch, pinNo_t chipselectPin) void spiSetupCH(spi_ch_t *ch, spiCH_t spi_hw_ch, pinNo_t chipselectPin)

Loading…
Cancel
Save