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

Merge branch 'testbranch' of https://github.com/cnlohr/ch32v003fun into testbranch

parents a4744699 689710f9
No related branches found
No related tags found
No related merge requests found
...@@ -8,15 +8,6 @@ ...@@ -8,15 +8,6 @@
// Working on WS2812 driving. // Working on WS2812 driving.
static inline uint32_t __get_dscratch0(void)
{
uint32_t result;
__ASM volatile("csrr %0," "0x7b2": "=r"(result));
return (result);
}
int main() int main()
{ {
SystemInit48HSI(); SystemInit48HSI();
......
TOOLS:=wch_erase wch_reset wch_write_simple minichlink TOOLS:=wch_erase wch_reset wch_write_simple wch_printf minichlink
all : $(TOOLS) all : $(TOOLS)
...@@ -9,6 +9,8 @@ wch_erase : wch_erase.c ...@@ -9,6 +9,8 @@ wch_erase : wch_erase.c
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) gcc -o $@ $^ $(LDFLAGS) $(CFLAGS)
wch_reset : wch_reset.c wch_reset : wch_reset.c
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) gcc -o $@ $^ $(LDFLAGS) $(CFLAGS)
wch_printf : wch_printf.c
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS)
wch_write_simple : wch_write_simple.c wch_write_simple : wch_write_simple.c
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) gcc -o $@ $^ $(LDFLAGS) $(CFLAGS)
minichlink : minichlink.c minichlink : minichlink.c
......
#include <stdio.h>
#include "wch_link_base.h"
// TESTED
int main()
{
libusb_device_handle * devh = wch_link_base_setup();
// Issue reset
// wch_link_command( devh, "\x81\x0b\x01\x01", 4, 0, 0, 0 );
// Why does db[1] = 6 appear to be some sort of query?
// Also 0x0b appears to be a query. But it wrecks up the chip.
// db[1] = 0xd DOES WRITE TO 0xe0000000. But is it predictable?
// DO NOT 0x0f!
unsigned char databuff[11] = { 0x81, 0x0d, 0x08, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
unsigned char rbuff[1024];
int i, j;
for( i = 1; i < 20; i++ )
for( j = 1; j < 20; j++ )
{
databuff[2] = i;
databuff[3] = j;
int transferred;
wch_link_command( devh, databuff, 11, &transferred, rbuff, 1024 );
int k;
printf( "%d, %d: %d: ", i, j, transferred );
for( k = 0; k < transferred; k++ ) printf( "%02x ", rbuff[k] );
printf( "\n" );
usleep(10000);
}
// Close out.
wch_link_command( devh, "\x81\x0d\x01\xff", 4, 0, 0, 0 );
}
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