2015-06-07 15:08:30 -03:00
|
|
|
/*
|
|
|
|
simple test of Storage API
|
|
|
|
*/
|
|
|
|
|
2015-10-20 09:34:10 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2015-06-07 15:08:30 -03:00
|
|
|
|
2015-10-16 17:22:11 -03:00
|
|
|
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
|
2015-06-07 15:08:30 -03:00
|
|
|
|
|
|
|
AP_HAL::Storage *st;
|
|
|
|
|
|
|
|
void setup(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
init Storage API
|
|
|
|
*/
|
|
|
|
hal.console->printf_P(PSTR("Starting AP_HAL::Storage test\r\n"));
|
2015-06-09 20:27:41 -03:00
|
|
|
st->init(NULL);
|
2015-06-07 15:08:30 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
Calculate XOR of the full conent of memory
|
|
|
|
Do it by block of 8 bytes
|
|
|
|
*/
|
|
|
|
unsigned int i, j;
|
|
|
|
unsigned char buff[8], XOR_res = 0;
|
|
|
|
|
|
|
|
for(i = 0; i < HAL_STORAGE_SIZE; i += 8)
|
|
|
|
{
|
|
|
|
st->read_block((void *) buff, i, 8);
|
|
|
|
for(j = 0; j < 8; j++)
|
|
|
|
XOR_res ^= buff[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
print XORed result
|
|
|
|
*/
|
|
|
|
hal.console->printf_P(PSTR("XORed ememory: %u\r\n"), (unsigned) XOR_res);
|
|
|
|
}
|
|
|
|
|
|
|
|
// In main loop do nothing
|
|
|
|
void loop(void)
|
|
|
|
{
|
|
|
|
hal.scheduler->delay(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
AP_HAL_MAIN();
|