0men (29.07.2016 13:21, просмотров: 163) ответил Лагунов на В STM32Cube конфигурация SPI вот такая?
ууу... )) вот такая :)
if(HAL_SPI_GetState(&SpiHandle1) == HAL_SPI_STATE_RESET)
{
SpiHandle1.Instance = SPI1;
/* SPI baudrate is set to 1.3 MHz (PCLK2/SPI_BaudRatePrescaler = 84/64 = 1.3125 MHz)
to verify these constraints:
- PCLK2 frequency is set to 84 MHz
*/
SpiHandle1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
SpiHandle1.Init.Direction = SPI_DIRECTION_2LINES;
SpiHandle1.Init.CLKPhase = SPI_PHASE_2EDGE;
SpiHandle1.Init.CLKPolarity = SPI_POLARITY_LOW;
SpiHandle1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
SpiHandle1.Init.CRCPolynomial = 7;
SpiHandle1.Init.DataSize = SPI_DATASIZE_8BIT;
SpiHandle1.Init.FirstBit = SPI_FIRSTBIT_MSB;
SpiHandle1.Init.NSS = SPI_NSS_SOFT;
SpiHandle1.Init.TIMode = SPI_TIMODE_DISABLED;
SpiHandle1.Init.Mode = SPI_MODE_MASTER;
__SPI1_CLK_ENABLE();
/* configure SPI SCK, MOSI and MISO */
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = (GPIO_PIN_5 | GPIO_PIN_7 | GPIO_PIN_6);
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_SPI_Init(&SpiHandle1);
}