diff --git a/spi.c b/spi.c --- a/spi.c +++ b/spi.c @@ -1,7 +1,26 @@ void init_spi(void) { - SPI_InitTypeDef SPI_InitStructure; + + SPI_HandleTypeDef hspi1; + + hspi1.Instance = SPI1; + hspi1.Init.Mode = SPI_MODE_MASTER; + hspi1.Init.Direction = SPI_DIRECTION_2LINES; + hspi1.Init.DataSize = SPI_DATASIZE_8BIT; + hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi1.Init.NSS = SPI_NSS_SOFT; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; + hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi1.Init.TIMode = SPI_TIMODE_DISABLED; + hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; + hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLED; + HAL_SPI_Init(&hspi1); + + + /* OLD: + SPI_InitTypeDef SPI_InitStructure; // OLED IC SPI_Cmd(SPI1, DISABLE); @@ -15,7 +34,7 @@ void init_spi(void) SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI_InitStructure); - SPI_Cmd(SPI1, ENABLE); /* Enable the SPI */ + SPI_Cmd(SPI1, ENABLE); // MAX IC @@ -30,7 +49,8 @@ void init_spi(void) SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI2, &SPI_InitStructure); - SPI_Cmd(SPI2, ENABLE); /* Enable the SPI */ + SPI_Cmd(SPI2, ENABLE); + */ } // vim:softtabstop=4 shiftwidth=4 expandtab