1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-03 11:24:10 +01:00
LibrePilot/flight/Libraries/ahrs_spi_program_master.c
peabody124 0fd9fda7a6 Flight/AHRS Comms: Whitespace fixes
gnuindent -npro -kr -i8 -ts8 -sob -ss -ncs -cp1 -il0 -hnl -l150

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1836 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-10-02 02:17:22 +00:00

24 lines
696 B
C

#include "ahrs_program_master.h"
#include "ahrs_program.h"
#include "pios_spi.h"
char connectTxBuf[SPI_PROGRAM_REQUEST_LENGTH] = { SPI_PROGRAM_REQUEST };
char connectRxBuf[SPI_PROGRAM_REQUEST_LENGTH];
#define MAX_CONNECT_TRIES 10
uint32_t AhrsProgramConnect(void)
{
memset(connectRxBuf, 0, SPI_PROGRAM_REQUEST_LENGTH);
for (int ct = 0; ct < MAX_CONNECT_TRIES; ct++) {
uint32_t res = PIOS_SPI_TransferBlock(PIOS_SPI_OP, (uint8_t *) & connectTxBuf,
(uint8_t *) & connectRxBuf, SPI_PROGRAM_REQUEST_LENGTH, NULL);
if (res == 0 && memcmp(connectRxBuf, SPI_PROGRAM_ACK, SPI_PROGRAM_REQUEST_LENGTH) == 0) {
return (0);
}
vTaskDelay(1 / portTICK_RATE_MS);
}
return (-1);
}