/*
 * @Description: 
 * @Version: 2.0
 * @Author: Seven
 * @Date: 2023-08-31 08:58:03
 * @LastEditors: Seven
 * @LastEditTime: 2023-08-31 09:00:06
 */
#include "uart.h"

void uart0_init(void)
{
    GPIO_AF_ENABLE(GPIO_AF_PIN(UART, 0, UARTRXD));
    GPIO_AF_ENABLE(GPIO_AF_PIN(UART, 0, UARTTXD));

    MSG_UART = UARTx(0);
    SYS_EnableAPBClock(APB_MASK_UARTx(0));
    UART_Init(UARTx(0), 115200, UART_LCR_DATABITS_8, UART_LCR_STOPBITS_1, UART_LCR_PARITY_NONE, UART_LCR_FIFO_1);
}


void data_dump(const char *name, uint8_t *data, uint16_t length)
{
	int index = 0;

	printf("%s Data Info: \r\n    ", name);

	for(index = 0;index < length;index++) {
		if((index%4 == 0)&&index) {
			if((index%16 == 0)&&index) {
				printf("\r\n    ");
			} else {
				printf(" ");
			}
		}
		printf("%02X ", *(data + index));
	}
	printf("\r\n");
}


