Files
Upsilon/ion/test/device/n0110/external_flash_helper.h
Émilie Feral 6b3d2cc8df [ion] test.external_flash: split this test target into two targets -
test.external_flash.write and test.external_flash.read
2019-08-08 17:22:00 +02:00

23 lines
976 B
C

#include <drivers/config/external_flash.h>
// Choose some not too uniform data to program and test the external flash memory with.
inline uint8_t expected_value_at(uint8_t * ptr) {
uint32_t address = reinterpret_cast<uint32_t>(ptr) - Ion::Device::ExternalFlash::Config::StartAddress;
return (address / 0x10000) + (address / 0x100) + address;
// Example: the value expected at the address 0x123456 is 0x12 + 0x34 + 0x56.
}
inline uint16_t expected_value_at(uint16_t * ptr) {
uint8_t * ptr8 = reinterpret_cast<uint8_t *>(ptr);
return (static_cast<uint16_t>(expected_value_at(ptr8+1)) << 8) | static_cast<uint16_t>(expected_value_at(ptr8));
}
inline uint32_t expected_value_at(uint32_t * ptr) {
uint16_t * ptr16 = reinterpret_cast<uint16_t *>(ptr);
return (static_cast<uint32_t>(expected_value_at(ptr16+1)) << 16) + static_cast<uint32_t>(expected_value_at(ptr16));
}
size_t uint64ToString(uint64_t n, char buffer[]);
void printElapsedTime(uint64_t startTime);