#include "p_usart.h" #include #include #include #include #include #include "driver_init.h" #define DEBUG_MAX_BUFFER_SIZE (256) void p_usart_init(void) { usart_sync_enable(&USART_0); PDEBUG("Hello world\n"); } int p_printf(const char* str, ...) { size_t size_str = strlen(str); if (size_str >= DEBUG_MAX_BUFFER_SIZE) { return -1; } uint8_t printf_buffer[DEBUG_MAX_BUFFER_SIZE]; memset(printf_buffer, '\0', DEBUG_MAX_BUFFER_SIZE); va_list args; va_start(args, str); vsprintf((char*)printf_buffer, str, args); va_end(args); io_write(&USART_0.io, (const uint8_t*)printf_buffer, strlen((const char*)printf_buffer)); return 0; }