mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
...and again.
This commit is contained in:
@@ -233,13 +233,12 @@ public:
|
|||||||
Bytes read(int side, bool synced, nanoseconds_t readTime,
|
Bytes read(int side, bool synced, nanoseconds_t readTime,
|
||||||
nanoseconds_t hardSectorThreshold)
|
nanoseconds_t hardSectorThreshold)
|
||||||
{
|
{
|
||||||
uint8_t threshold_ms = (hardSectorThreshold + 5e5) / 1e6; /* round to nearest ms */
|
|
||||||
struct read_frame f = {
|
struct read_frame f = {
|
||||||
.f = { .type = F_FRAME_READ_CMD, .size = sizeof(f) },
|
.f = { .type = F_FRAME_READ_CMD, .size = sizeof(f) },
|
||||||
.side = (uint8_t) side,
|
.side = (uint8_t) side,
|
||||||
.synced = (uint8_t) synced,
|
.synced = (uint8_t) synced,
|
||||||
.hardsec_threshold_ms = threshold_ms,
|
|
||||||
};
|
};
|
||||||
|
f.hardsec_threshold_ms = (hardSectorThreshold + 5e5) / 1e6; /* round to nearest ms */
|
||||||
uint16_t milliseconds = readTime / 1e6;
|
uint16_t milliseconds = readTime / 1e6;
|
||||||
((uint8_t*)&f.milliseconds)[0] = milliseconds;
|
((uint8_t*)&f.milliseconds)[0] = milliseconds;
|
||||||
((uint8_t*)&f.milliseconds)[1] = milliseconds >> 8;
|
((uint8_t*)&f.milliseconds)[1] = milliseconds >> 8;
|
||||||
@@ -260,12 +259,11 @@ public:
|
|||||||
unsigned safelen = bytes.size() & ~(FRAME_SIZE-1);
|
unsigned safelen = bytes.size() & ~(FRAME_SIZE-1);
|
||||||
Bytes safeBytes = bytes.slice(0, safelen);
|
Bytes safeBytes = bytes.slice(0, safelen);
|
||||||
|
|
||||||
uint8_t threshold_ms = (hardSectorThreshold + 5e5) / 1e6; /* round to nearest ms */
|
|
||||||
struct write_frame f = {
|
struct write_frame f = {
|
||||||
.f = { .type = F_FRAME_WRITE_CMD, .size = sizeof(f) },
|
.f = { .type = F_FRAME_WRITE_CMD, .size = sizeof(f) },
|
||||||
.side = (uint8_t) side,
|
.side = (uint8_t) side,
|
||||||
.hardsec_threshold_ms = threshold_ms,
|
|
||||||
};
|
};
|
||||||
|
f.hardsec_threshold_ms = (hardSectorThreshold + 5e5) / 1e6; /* round to nearest ms */
|
||||||
((uint8_t*)&f.bytes_to_write)[0] = safelen;
|
((uint8_t*)&f.bytes_to_write)[0] = safelen;
|
||||||
((uint8_t*)&f.bytes_to_write)[1] = safelen >> 8;
|
((uint8_t*)&f.bytes_to_write)[1] = safelen >> 8;
|
||||||
((uint8_t*)&f.bytes_to_write)[2] = safelen >> 16;
|
((uint8_t*)&f.bytes_to_write)[2] = safelen >> 16;
|
||||||
@@ -279,12 +277,11 @@ public:
|
|||||||
|
|
||||||
void erase(int side, nanoseconds_t hardSectorThreshold)
|
void erase(int side, nanoseconds_t hardSectorThreshold)
|
||||||
{
|
{
|
||||||
uint8_t threshold_ms = (hardSectorThreshold + 5e5) / 1e6; /* round to nearest ms */
|
|
||||||
struct erase_frame f = {
|
struct erase_frame f = {
|
||||||
.f = { .type = F_FRAME_ERASE_CMD, .size = sizeof(f) },
|
.f = { .type = F_FRAME_ERASE_CMD, .size = sizeof(f) },
|
||||||
.side = (uint8_t) side,
|
.side = (uint8_t) side,
|
||||||
.hardsec_threshold_ms = threshold_ms,
|
|
||||||
};
|
};
|
||||||
|
f.hardsec_threshold_ms = (hardSectorThreshold + 5e5) / 1e6; /* round to nearest ms */
|
||||||
usb_cmd_send(&f, f.f.size);
|
usb_cmd_send(&f, f.f.size);
|
||||||
|
|
||||||
await_reply<struct any_frame>(F_FRAME_ERASE_REPLY);
|
await_reply<struct any_frame>(F_FRAME_ERASE_REPLY);
|
||||||
|
|||||||
Reference in New Issue
Block a user