Skip to content
Snippets Groups Projects
Commit 9cad6683 authored by cnlohr's avatar cnlohr
Browse files

Add configuration item for allowing re-use of PD7 as NRST or PP/IO

parent 0c594523
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ int bootloader_len = 512; ...@@ -41,6 +41,7 @@ int bootloader_len = 512;
int main( int argc, char ** argv ) int main( int argc, char ** argv )
{ {
int status; int status;
int must_be_end = 0;
uint8_t rbuff[1024]; uint8_t rbuff[1024];
libusb_device_handle * devh = wch_link_base_setup(); libusb_device_handle * devh = wch_link_base_setup();
...@@ -50,6 +51,12 @@ int main( int argc, char ** argv ) ...@@ -50,6 +51,12 @@ int main( int argc, char ** argv )
{ {
char * argchar = argv[iarg]; char * argchar = argv[iarg];
if( argchar[0] != '-' ) goto help; if( argchar[0] != '-' ) goto help;
if( must_be_end )
{
fprintf( stderr, "Error: the command '%c' cannot be followed by other commands.\n", must_be_end );
return -1;
}
keep_going: keep_going:
switch( argchar[1] ) switch( argchar[1] )
{ {
...@@ -65,8 +72,16 @@ keep_going: ...@@ -65,8 +72,16 @@ keep_going:
case 'R': case 'R':
// Part one "immediately" places the part into reset. Part 2 says when we're done, leave part in reset. // Part one "immediately" places the part into reset. Part 2 says when we're done, leave part in reset.
wch_link_multicommands( devh, 2, 4, "\x81\x0d\x01\x02", 4, "\x81\x0d\x01\x01" ); wch_link_multicommands( devh, 2, 4, "\x81\x0d\x01\x02", 4, "\x81\x0d\x01\x01" );
must_be_end = 'R';
break; break;
// disable NRST pin (turn it into a GPIO)
case 'd':
wch_link_multicommands( devh, 2, 11, "\x81\x06\x08\x02\xf7\xff\xff\xff\xff\xff\xff", 4, "\x81\x0b\x01\x01" );
break;
case 'D':
wch_link_multicommands( devh, 2, 11, "\x81\x06\x08\x02\xff\xff\xff\xff\xff\xff\xff", 4, "\x81\x0b\x01\x01" );
break;
// PROTECTION UNTESTED! // PROTECTION UNTESTED!
/* /*
case 'p': case 'p':
...@@ -185,6 +200,8 @@ help: ...@@ -185,6 +200,8 @@ help:
fprintf( stderr, " -f Disable 5V\n" ); fprintf( stderr, " -f Disable 5V\n" );
fprintf( stderr, " -r Release from reest\n" ); fprintf( stderr, " -r Release from reest\n" );
fprintf( stderr, " -R Place into Reset\n" ); fprintf( stderr, " -R Place into Reset\n" );
fprintf( stderr, " -D Configure NRST as GPIO\n" );
fprintf( stderr, " -d Configure NRST as NRST\n" );
// fprintf( stderr, " -P Enable Read Protection (UNTESTED)\n" ); // fprintf( stderr, " -P Enable Read Protection (UNTESTED)\n" );
// fprintf( stderr, " -p Disable Read Protection (UNTESTED)\n" ); // fprintf( stderr, " -p Disable Read Protection (UNTESTED)\n" );
fprintf( stderr, " -w [binary image to write]\n" ); fprintf( stderr, " -w [binary image to write]\n" );
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
tcc wch_erase.c libusb-1.0.dll tcc wch_erase.c libusb-1.0.dll
tcc wch_reset.c libusb-1.0.dll tcc wch_reset.c libusb-1.0.dll
tcc wch_write_simple.c libusb-1.0.dll tcc wch_write_simple.c libusb-1.0.dll
tcc minichlink.c libusb-1.0.dll
wch_erase.exe rem wch_erase.exe
wch_write_simple.exe ..\barebones\barebones.bin rem wch_write_simple.exe ..\barebones\barebones.bin
wch_reset.exe rem wch_reset.exe
...@@ -61,6 +61,8 @@ int main() ...@@ -61,6 +61,8 @@ int main()
GPIOD->BSHR = 1; GPIOD->BSHR = 1;
GPIOD->BSHR = 1<<16; GPIOD->BSHR = 1<<16;
GPIOD->BSHR = 1; GPIOD->BSHR = 1;
Delay_Ms( 1 );
GPIOD->BSHR = (128+64+1)<<16; GPIOD->BSHR = (128+64+1)<<16;
Delay_Ms( 1 );
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment