/*
 * uart.cpp
 *
 *  Created on: 11. Aug. 2015
 *      Author: martin
 */
#include "stm32f4xx_hal.h"
#include "uart.h"
#include "gpio.h"
#include "globals.h"
#include "errorHandler.h"
//#include "errorHandler.h"

uint8_t txBuffer[] = "HALLO WELT";

void uart1Init()
{
	uart1Handle.Instance = USART1;
	uart1Handle.Init.BaudRate = 9600;
	uart1Handle.Init.WordLength = UART_WORDLENGTH_8B;
	uart1Handle.Init.StopBits = UART_STOPBITS_1;
	uart1Handle.Init.Parity = UART_PARITY_NONE;
	uart1Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
	uart1Handle.Init.Mode = UART_MODE_TX_RX;

	if(HAL_UART_Init(&uart1Handle) != HAL_OK)
	{
		errorHandler(); //"Uart1 Init");
	}
	HAL_UART_Transmit(&uart1Handle, txBuffer, 10, 5000);
}

extern "C" void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{
	//GPIO_InitTypeDef init;
	__HAL_RCC_USART1_CLK_ENABLE();
	//__HAL_RCC_GPIOA_CLK_ENABLE();

	/*init.Pin = GPIO_PIN_10 | GPIO_PIN_9;
	init.Mode = GPIO_MODE_AF_PP;
	init.Pull = GPIO_NOPULL;
	init.Alternate = GPIO_AF7_USART1;
	HAL_GPIO_Init(GPIOA, &init);*/


}
