1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00
LibrePilot/flight/Bootloaders/AHRS/ahrs_slave_test.c
les 2125e2479d Added AHRS boot loader SPI protocol
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1965 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-10-16 17:54:00 +00:00

39 lines
891 B
C

#include "ahrs_bl.h"
#include "ahrs_spi_program.h"
uint8_t buf[256];
bool StartProgramming(void)
{
PIOS_COM_SendFormattedString(PIOS_COM_AUX,"Started programming\r\n");
return(true);
}
bool WriteData(uint32_t offset, uint8_t *buffer, uint32_t size)
{
if(size > SPI_MAX_PROGRAM_DATA_SIZE)
{
PIOS_COM_SendFormattedString(PIOS_COM_AUX,"oversize: %d\r\n", size);
return(false);
}
PIOS_COM_SendFormattedString(PIOS_COM_AUX,"Wrote %d bytes to %d\r\n", size, offset);
memcpy(buf,buffer,size);
PIOS_LED_Toggle(LED1);
return(true);
}
bool ReadData(uint32_t offset, uint8_t *buffer, uint32_t size)
{
if(size > SPI_MAX_PROGRAM_DATA_SIZE)
{
PIOS_COM_SendFormattedString(PIOS_COM_AUX,"oversize: %d\r\n", size);
return(false);
}
PIOS_COM_SendFormattedString(PIOS_COM_AUX,"Read %d bytes from %d\r\n", size, offset);
memcpy(buffer,buf,size);
PIOS_LED_Toggle(LED1);
return(true);
}