aboutsummaryrefslogtreecommitdiff
path: root/stm32f091/util.h
blob: 9f5c1ec5f290e85fa2ccc49f70d3a01551ecd2c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include <stdlib.h>
#include <stdio.h>
#include <stm32f0xx_hal.h>
#include <string.h>

#include "setup.h"
#include "../shared/util.h"

#define ws_usb_printf(fmt, ...) { \
	char temp[255]; \
	snprintf(temp, 255, fmt, ##__VA_ARGS__); \
	HAL_UART_Transmit(&huart2, (uint8_t*) temp, sizeof(char) * strlen(temp), HAL_MAX_DELAY); \
}

#define ws_dbg_set_usart2_tty_color(color) { \
	uint8_t sgr[] = { 0x1b, 0x5b, 0x33, 0x30 + color, 0x6d }; \
	HAL_UART_Transmit(&huart2, sgr, sizeof(sgr), 100); \
}