diff --git a/ch32v003fun/ch32v003fun.c b/ch32v003fun/ch32v003fun.c index 262e4cd90bd48674695c4f8f6da1579c28566f09..6972e5519b8a27eae2e1dff3e4032983395e86fe 100644 --- a/ch32v003fun/ch32v003fun.c +++ b/ch32v003fun/ch32v003fun.c @@ -897,9 +897,12 @@ int putchar(int c) return 1; } #else -// For debug writing to the debug interface. -#define DMDATA0 ((volatile uint32_t*)0xe00000f4) -#define DMDATA1 ((volatile uint32_t*)0xe00000f8) + +// MSB .... LSB +// DMDATA0: char3 char2 char1 [status word] +// where [status word] is: +// b7 = is a "printf" waiting? +// b0..b3 = # of bytes in printf (+4). (4 or higher indicates a print of some kind) int _write(int fd, const char *buf, int size) { diff --git a/ch32v003fun/ch32v003fun.h b/ch32v003fun/ch32v003fun.h index 696a45f06e33f405724515d5764a802963e38ed8..7cd507c9a84dc09bbbd6c52fa710a13870054ab4 100644 --- a/ch32v003fun/ch32v003fun.h +++ b/ch32v003fun/ch32v003fun.h @@ -4823,8 +4823,17 @@ extern "C" { #define DELAY_MS_TIME (SYSTEM_CORE_CLOCK / 8000) #if defined(__riscv) || defined(__riscv__) + +// Stuff that can only be compiled on device (not for the programmer, or other host programs) + void handle_reset() __attribute__((naked)) __attribute((section(".text.handle_reset"))) __attribute__((used)); void DefaultIRQHandler( void ) __attribute__((section(".text.vector_handler"))) __attribute__((naked)) __attribute__((used)); + + +// For debug writing to the debug interface. +#define DMDATA0 ((volatile uint32_t*)0xe00000f4) +#define DMDATA1 ((volatile uint32_t*)0xe00000f8) + #endif void DelaySysTick( uint32_t n ); @@ -4845,7 +4854,6 @@ void SystemInit24HSI( void ); // No PLL, just raw internal RC oscillator. void SystemInitHSE( int HSEBYP ); void SystemInitHSEPLL( int HSEBYP ); - #define UART_BAUD_RATE 115200 #define OVER8DIV 4 #define INTEGER_DIVIDER (((25 * (APB_CLOCK)) / ((OVER8DIV) * (UART_BAUD_RATE))))