You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
672 B
C

#include "p_usart.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "driver_init.h"
#define DEBUG_MAX_BUFFER_SIZE (256)
void p_usart_init(void)
{
usart_sync_enable(&USART_0);
}
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;
}