Update boot_detect.c
This commit is contained in:
1 parent
1c497e1f1e
commit
d2e58f6a8a
1 file changed
+13
-8
+13
-8
@@ -12,7 +12,7 @@ bool board_detected = false;
|
|||||||
|
|
||||||
bool wait_for_boot(int timeout_ms) {
|
bool wait_for_boot(int timeout_ms) {
|
||||||
absolute_time_t tio_full = make_timeout_time_ms(timeout_ms);
|
absolute_time_t tio_full = make_timeout_time_ms(timeout_ms);
|
||||||
absolute_time_t tio_cmd1 = tio_full;
|
absolute_time_t tio_shrt = tio_full;
|
||||||
init_glitch_pio();
|
init_glitch_pio();
|
||||||
reset_cpu();
|
reset_cpu();
|
||||||
uint32_t word=0, last_word=0;
|
uint32_t word=0, last_word=0;
|
||||||
@@ -21,14 +21,19 @@ bool wait_for_boot(int timeout_ms) {
|
|||||||
int reset_attempts = 0;
|
int reset_attempts = 0;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
if (time_reached(tio_cmd1))
|
if (time_reached(tio_full))
|
||||||
{
|
{
|
||||||
if (reset_attempts > 4)
|
halt_with_error(3, 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (time_reached(tio_shrt))
|
||||||
|
{
|
||||||
|
if (reset_attempts > 10)
|
||||||
{
|
{
|
||||||
if (was_read_zero) {
|
if (was_read_zero) {
|
||||||
halt_with_error(1, 3);
|
halt_with_error(1, 3);
|
||||||
}
|
}
|
||||||
else if (tio_cmd1 != tio_full) {
|
else if (tio_shrt != tio_full) {
|
||||||
halt_with_error(0, 3);
|
halt_with_error(0, 3);
|
||||||
}
|
}
|
||||||
else if (was_cmd1) {
|
else if (was_cmd1) {
|
||||||
@@ -40,23 +45,23 @@ bool wait_for_boot(int timeout_ms) {
|
|||||||
}
|
}
|
||||||
reset_attempts++;
|
reset_attempts++;
|
||||||
reset_cpu();
|
reset_cpu();
|
||||||
tio_cmd1 = tio_full;
|
tio_shrt = tio_full;
|
||||||
}
|
}
|
||||||
if(!pio_sm_is_rx_fifo_empty(pio1, 0))
|
if(!pio_sm_is_rx_fifo_empty(pio1, 0))
|
||||||
{
|
{
|
||||||
word = pio_sm_get(pio1, 0);
|
word = pio_sm_get(pio1, 0);
|
||||||
if (last_word == 0x41000000 && word == 0x00F9) // cmd1 request
|
if (last_word == 0x41000000 && word == 0x00F9) // cmd1 request
|
||||||
{
|
{
|
||||||
tio_cmd1 = make_timeout_time_ms(20);
|
tio_shrt = make_timeout_time_ms(50);
|
||||||
was_cmd1 = true;
|
was_cmd1 = true;
|
||||||
}
|
}
|
||||||
else if (last_word == 0x00F9 && (word >> 24) == 0x3F) // cmd1 responce
|
else if (last_word == 0x00F9 && (word >> 24) == 0x3F) // cmd1 responce
|
||||||
{
|
{
|
||||||
tio_cmd1 = tio_full;
|
tio_shrt = tio_full;
|
||||||
}
|
}
|
||||||
else if (last_word == 0x51000000 && word == 0x0055) //read block 0
|
else if (last_word == 0x51000000 && word == 0x0055) //read block 0
|
||||||
{
|
{
|
||||||
tio_cmd1 = make_timeout_time_ms(400);
|
tio_shrt = make_timeout_time_ms(400);
|
||||||
was_read_zero = true;
|
was_read_zero = true;
|
||||||
} else if (was_read_zero && last_word == 0x4D000200 && word == 0x00B1) // read status - erista only
|
} else if (was_read_zero && last_word == 0x4D000200 && word == 0x00B1) // read status - erista only
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user