Created
September 3, 2020 18:26
-
-
Save mvirkkunen/c94266b46efdf978ccec8c6ceae9bb77 to your computer and use it in GitHub Desktop.
sequence_parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sequence name="ResetHardware"> | |
<block> | |
__var nReset = 0x80; | |
__var canReadPins = 0; | |
// De-assert nRESET line | |
canReadPins = (DAP_SWJ_Pins(0x00, nReset, 0) != 0xFFFFFFFF); | |
</block> | |
<!-- Keep reset active for 50 ms --> | |
<control while="1" timeout="50000"/> | |
<control if="canReadPins"> | |
<!-- Assert nRESET line and wait max. 1s for recovery --> | |
<control while="(DAP_SWJ_Pins(nReset, nReset, 0) & nReset) == 0" timeout="1000000"/> | |
</control> | |
<control if="!canReadPins"> | |
<block> | |
// Assert nRESET line | |
DAP_SWJ_Pins(nReset, nReset, 0); | |
</block> | |
<!-- Wait 100ms for recovery if nRESET not readable --> | |
<control while="1" timeout="100000"/> | |
</control> | |
</sequence> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ok( | |
Sequence { | |
name: "ResetHardware", | |
pname: None, | |
disable: false, | |
info: None, | |
body: [ | |
Block( | |
Block { | |
atomic: false, | |
info: None, | |
body: [ | |
Declare( | |
"nReset", | |
Num( | |
128, | |
Hex, | |
), | |
), | |
Declare( | |
"canReadPins", | |
Num( | |
0, | |
Dec, | |
), | |
), | |
Assign( | |
"canReadPins", | |
Binary( | |
Ne, | |
( | |
Call( | |
"DAP_SWJ_Pins", | |
[ | |
Expr( | |
Num( | |
0, | |
Hex, | |
), | |
), | |
Expr( | |
Var( | |
"nReset", | |
), | |
), | |
Expr( | |
Num( | |
0, | |
Dec, | |
), | |
), | |
], | |
), | |
Num( | |
4294967295, | |
Hex, | |
), | |
), | |
), | |
), | |
], | |
}, | |
), | |
Control( | |
Control { | |
if_cond: None, | |
while_cond: Some( | |
Num( | |
1, | |
Dec, | |
), | |
), | |
timeout: Some( | |
50000, | |
), | |
info: None, | |
body: [], | |
}, | |
), | |
Control( | |
Control { | |
if_cond: Some( | |
Var( | |
"canReadPins", | |
), | |
), | |
while_cond: None, | |
timeout: None, | |
info: None, | |
body: [ | |
Control( | |
Control { | |
if_cond: None, | |
while_cond: Some( | |
Binary( | |
Eq, | |
( | |
Binary( | |
BitAnd, | |
( | |
Call( | |
"DAP_SWJ_Pins", | |
[ | |
Expr( | |
Var( | |
"nReset", | |
), | |
), | |
Expr( | |
Var( | |
"nReset", | |
), | |
), | |
Expr( | |
Num( | |
0, | |
Dec, | |
), | |
), | |
], | |
), | |
Var( | |
"nReset", | |
), | |
), | |
), | |
Num( | |
0, | |
Dec, | |
), | |
), | |
), | |
), | |
timeout: Some( | |
1000000, | |
), | |
info: None, | |
body: [], | |
}, | |
), | |
], | |
}, | |
), | |
Control( | |
Control { | |
if_cond: Some( | |
Unary( | |
Not, | |
Var( | |
"canReadPins", | |
), | |
), | |
), | |
while_cond: None, | |
timeout: None, | |
info: None, | |
body: [ | |
Block( | |
Block { | |
atomic: false, | |
info: None, | |
body: [ | |
Expr( | |
Call( | |
"DAP_SWJ_Pins", | |
[ | |
Expr( | |
Var( | |
"nReset", | |
), | |
), | |
Expr( | |
Var( | |
"nReset", | |
), | |
), | |
Expr( | |
Num( | |
0, | |
Dec, | |
), | |
), | |
], | |
), | |
), | |
], | |
}, | |
), | |
Control( | |
Control { | |
if_cond: None, | |
while_cond: Some( | |
Num( | |
1, | |
Dec, | |
), | |
), | |
timeout: Some( | |
100000, | |
), | |
info: None, | |
body: [], | |
}, | |
), | |
], | |
}, | |
), | |
], | |
}, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment