2015-04-22 08:02 AM
Hi everyone,
I'm trying to program the SPI2 of my STM32 to only transmit data at 18Mbit/s as I saw on datasheet. My problem is to configure the ''SPI_HandleTypeDef'' in order to use the function : HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); As I want to only transmit I don't know what to put into the following fields of the SPI_HandleTypeDef : uint8_t *pTxBuffPtr; /* Pointer to SPI Tx transfer Buffer */ uint16_t TxXferSize; /* SPI Tx Transfer size */ uint16_t TxXferCount; /* SPI Tx Transfer Counter */ uint8_t *pRxBuffPtr; /* Pointer to SPI Rx transfer Buffer */ uint16_t RxXferSize; /* SPI Rx Transfer size */ uint16_t RxXferCount; /* SPI Rx Transfer Counter */ uint32_t CRCSize; /* SPI CRC size used for the transfer */ void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /* function pointer on Rx IRQ handler */ void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /* function pointer on Tx IRQ handler */ DMA_HandleTypeDef *hdmatx; /* SPI Tx DMA Handle parameters * DMA_HandleTypeDef *hdmarx; /* SPI Rx DMA Handle parameters */ HAL_LockTypeDef Lock; /* Locking object */ HAL_SPI_StateTypeDef State; /* SPI communication state */ HAL_SPI_ErrorTypeDef ErrorCode; /* SPI Error code */ Here you have my main : #include ''stm32f0xx.h'' #include ''system_stm32f0xx.h'' #include ''stm32f0xx_hal_rcc.h'' #include ''stm32f0xx_hal_spi.h'' int main(void) { /***** Variables *****/ uint32_t Freq_syst; HAL_StatusTypeDef SPI_status; SPI_HandleTypeDef SPI_handle; SPI_InitTypeDef SPI_init_struct; SPI_init_struct.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; SPI_init_struct.CLKPhase = SPI_POLARITY_LOW; SPI_init_struct.CRCCalculation = SPI_CRCCALCULATION_DISABLED; SPI_init_struct.DataSize = SPI_DATASIZE_16BIT; SPI_init_struct.Direction = SPI_DIRECTION_1LINE; SPI_init_struct.FirstBit = SPI_FIRSTBIT_LSB; //peut être mettre MSB first SPI_init_struct.Mode = SPI_MODE_MASTER; SPI_init_struct.NSS = SPI_NSS_SOFT; SPI_init_struct.NSSPMode = SPI_NSS_PULSE_DISABLED; SPI_init_struct.TIMode = SPI_TIMODE_ENABLED; SPI_handle.Instance = SPI2; SPI_handle.Init = SPI_init_struct; while(1) { } } Thank you for your help,