/* * arinc429.c * * Created on: 8 juil. 2024 * Author: houssni.slamti */ /*includes --------------------------------------------------------*/ #include "arinc429.h" extern SPI_HandleTypeDef hspi2; void arinc429_transfer(uint32_t data){ uint8_t buffer[4]; buffer[0] = (data >> 24) & 0xFF; buffer[1] = (data >> 16) & 0xFF; buffer[2] = (data >> 8) & 0xFF; buffer[3] = data & 0xFF; HAL_GPIO_WritePin(ARINC_CS_Port, ARINC_CS_Pin, GPIO_PIN_RESET); for (int i = 0; i < 4; i++){ while (__HAL_SPI_GET_FLAG(&hspi2, SPI_FLAG_TXE) == RESET); // Attendre que le buffer TX soit vide HAL_SPI_Transmit(&hspi2, (uint8_t*)&buffer[i], 8, HAL_MAX_DELAY); while (__HAL_SPI_GET_FLAG(&hspi2, SPI_FLAG_BSY) == SET); // Attendre la fin de la transmission } HAL_GPIO_WritePin(ARINC_CS_Port, ARINC_CS_Pin, GPIO_PIN_SET); }