* AT45_PAGE_SIZE
*/
command void write(at45page_t page, at45pageoffset_t offset,
- void *PASS data, at45pageoffset_t n);
+ void *PASS COUNT(n) data, at45pageoffset_t n);
/**
* Signal completion of a write operation. The buffer passed to write
* is implictly returned.
* AT45_PAGE_SIZE
*/
command void read(at45page_t page, at45pageoffset_t offset,
- void *PASS data, at45pageoffset_t n);
+ void *PASS COUNT(n) data, at45pageoffset_t n);
/**
* Signal completion of a read operation. The buffer passed to read
* is implictly returned.
BROKEN // Write failed. Fail all subsequent requests.
};
uint8_t request;
- uint8_t *reqBuf;
at45pageoffset_t reqOffset, reqBytes;
+ uint8_t * COUNT_NOK(reqBytes) reqBuf;
at45page_t reqPage;
enum {
}
void newRequest(uint8_t req, at45page_t page, at45pageoffset_t offset,
- void *reqdata, at45pageoffset_t n) {
+ void * COUNT_NOK(n) reqdata, at45pageoffset_t n) {
request = req;
reqBuf = reqdata;
at45pageoffset_t n,
uint16_t baseCrc) {
/* This is a hack (store crc in reqBuf), but it saves 2 bytes of RAM */
- reqBuf = (uint8_t *)baseCrc;
+ reqBuf = TCAST(uint8_t * COUNT(baseCrc), baseCrc);
newRequest(R_READCRC, page, offset, reqBuf, n);
}
struct {
/* The latest request made for this client, and it's arguments */
uint8_t request; /* automatically initialised to R_IDLE */
- uint8_t *buf;
+ uint8_t * COUNT_NOK(len) buf;
storage_addr_t addr;
storage_len_t len;
} s[N];
}
error_t newRequest(uint8_t newState, uint8_t id,
- storage_addr_t addr, uint8_t* buf, storage_len_t len) {
+ storage_addr_t addr, uint8_t* COUNT_NOK(len) buf, storage_len_t len) {
storage_len_t vsize;
if (s[id].request != R_IDLE)
/* ------------------------------------------------------------------ */
command error_t BlockRead.computeCrc[uint8_t id](storage_addr_t addr, storage_len_t len, uint16_t basecrc) {
- return newRequest(R_CRC, id, addr, (void *)basecrc, len);
+ return newRequest(R_CRC, id, addr, TCAST(void * COUNT(len),basecrc), len);
}
/* ------------------------------------------------------------------ */
* AT45_PAGE_SIZE
*/
command void readBuffer(uint8_t cmd, at45pageoffset_t offset,
- uint8_t *PASS data, uint16_t n);
+ uint8_t *PASS COUNT_NOK(n) data, uint16_t n);
/**
* Read directly from flash. readDone will be signaled.
* @param n Number of bytes to read (> 0).
*/
command void read(uint8_t cmd, at45page_t page, at45pageoffset_t offset,
- uint8_t *PASS data, at45pageoffset_t n);
+ uint8_t *PASS COUNT_NOK(n) data, at45pageoffset_t n);
/**
* Signaled when data has been read from the buffer. The data buffer
* AT45_PAGE_SIZE
*/
command void write(uint8_t cmd, at45page_t page, at45pageoffset_t offset,
- uint8_t *PASS data, at45pageoffset_t n);
+ uint8_t *PASS COUNT_NOK(n) data, at45pageoffset_t n);
/**
* Signaled when data has been written to the buffer. The data buffer
};
uint8_t status = P_IDLE;
uint8_t flashCmd[4];
- uint8_t *data;
at45pageoffset_t dataCount;
+ uint8_t * COUNT_NOK(dataCount) data;
uint8_t dontCare;
void complete(uint16_t crc) {
void execCommand(uint8_t op, uint8_t reqCmd, uint8_t reqDontCare,
at45page_t reqPage, at45pageoffset_t reqOffset,
- uint8_t *reqData, at45pageoffset_t reqCount) {
+ uint8_t * COUNT_NOK(reqCount) reqData, at45pageoffset_t reqCount) {
status = op;
// page (2 bytes) and highest bit of offset
at45page_t page, at45pageoffset_t offset,
at45pageoffset_t count,
uint16_t baseCrc) {
- execCommand(P_READ_CRC, cmd, 2, page, offset, (uint8_t *)baseCrc, count);
+ execCommand(P_READ_CRC, cmd, 2, page, offset, TCAST(uint8_t * COUNT(count), baseCrc), count);
}
command void HplAt45db.write(uint8_t cmd,