36#include "driverlib/rom.h"
37#include "driverlib/rom_map.h"
38#include "driverlib/flash.h"
48 size = std::min(size,
len_ - (
size_t)f->
offset);
55static uint32_t write_buf[32];
66 size = std::min(size,
len_ - (
size_t)f->
offset);
68 uint32_t write_address =
reinterpret_cast<uint32_t
>(
base_) + f->
offset;
69 const uint8_t *read_buf =
static_cast<const uint8_t *
>(buf);
70 uint32_t end_address = write_address + size;
72 while (write_address < end_address)
74 HASSERT((write_address & 3) == 0);
78 MAP_FlashErase(
reinterpret_cast<uint32_t
>(write_address));
80 uint32_t current_end_address = end_address;
89 uint32_t current_len = current_end_address - write_address;
90 HASSERT(current_len <=
sizeof(write_buf));
91 memcpy(write_buf, read_buf, current_len);
92 if (MAP_FlashProgram(write_buf, write_address, (current_len + 3) & ~3) < 0)
96 write_address += current_len;
97 read_buf += current_len;
uint32_t write_page_mask()
Returns a bitmask with one bits to get the page address.
size_t len_
Number of bytes in the file.
uint32_t write_page_size()
Returns a bitmask with one bits to get the page address.
uint32_t subpage_mask()
Returns a bitmask with one bits to get the within-page address.
const uint8_t * base_
Base pointer.
ssize_t read(File *, void *, size_t) OVERRIDE
Read method.
ssize_t write(File *, const void *, size_t) OVERRIDE
Write method.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
off_t offset
current offset within file