Skip to content

Commit

Permalink
Merge pull request openwch#15 from cnlohr/minichlink_refactor
Browse files Browse the repository at this point in the history
Minichlink refactor
  • Loading branch information
cnlohr authored Mar 6, 2023
2 parents aeed6ac + 8501baa commit 5e71f9e
Show file tree
Hide file tree
Showing 10 changed files with 5,623 additions and 272 deletions.
7 changes: 4 additions & 3 deletions ch32v003evt/embedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ int mini_vpprintf(int (*puts)(char* s, int len, void* buf), void* buf, const cha
static int __puts_uart(char *s, int len, void *buf)
{
_write( 0, s, len );
return len;
}

int printf(const char* format, ...)
Expand Down Expand Up @@ -105,9 +106,9 @@ int wctomb(char *s, wchar_t wc)
}
size_t strlen(const char *s) { const char *a = s;for (; *s; s++);return s-a; }
size_t strnlen(const char *s, size_t n) { const char *p = memchr(s, 0, n); return p ? p-s : n;}
void *memset(void *dest, int c, size_t n) { unsigned char *s = dest; for (; n; n--, s++) *s = c; }
char *strcpy(char *d, const char *s) { for (; (*d=*s); s++, d++); }
char *strncpy(char *d, const char *s, size_t n) { for (; n && (*d=*s); n--, s++, d++); }
void *memset(void *dest, int c, size_t n) { unsigned char *s = dest; for (; n; n--, s++) *s = c; return dest; }
char *strcpy(char *d, const char *s) { for (; (*d=*s); s++, d++); return d; }
char *strncpy(char *d, const char *s, size_t n) { for (; n && (*d=*s); n--, s++, d++); return d; }
int strcmp(const char *l, const char *r)
{
for (; *l==*r && *l; l++, r++);
Expand Down
7 changes: 5 additions & 2 deletions examples/blink/blink.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ int main()
GPIOD->CFGLR &= ~(0xf<<(4*0));
GPIOD->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*0);

GPIOD->CFGLR &= ~(0xf<<(4*4));
GPIOD->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*4);

while(1)
{
GPIOD->BSHR = 1; // Turn on GPIOD0
GPIOD->BSHR = (1<<0) | (1<<4); // Turn on GPIOD0
Delay_Ms( 100 );
GPIOD->BSHR = 1<<16; // Turn off GPIOD0
GPIOD->BSHR = (1<<(16+0)) | (1<<(16+4)); // Turn off GPIOD0
Delay_Ms( 100 );
}
}
6 changes: 3 additions & 3 deletions minichlink/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ TOOLS:=minichlink

all : $(TOOLS)

CFLAGS:=-O1 -g
LDFLAGS:=-lpthread -lusb-1.0
CFLAGS:=-O0 -g3
LDFLAGS:=-lpthread -lusb-1.0 -ludev

minichlink : minichlink.c
minichlink : minichlink.c pgm-wch-linke.c pgm-esp32s2-ch32xx.c
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS)

install_udev_rules :
Expand Down
Loading

0 comments on commit 5e71f9e

Please sign in to comment.