diff options
Diffstat (limited to 'src/stm32f0/log.c')
-rw-r--r-- | src/stm32f0/log.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/stm32f0/log.c b/src/stm32f0/log.c deleted file mode 100644 index be9c48b1..00000000 --- a/src/stm32f0/log.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * log.c - * This file not required for regular Klipper usage, but hw/sw developer - * can use USART TX pin instead SWO for debugging purposes - * - * Copyright (C) 2019 Eug Krashtan <eug.krashtan@gmail.com> - * This file may be distributed under the terms of the GNU GPLv3 license. - */ - -#include "string.h" -#include "stm32f0xx_hal.h" -#include "log.h" - -UART_HandleTypeDef huart2; - -void LogInit(void) -{ - huart2.Instance = USART2; - huart2.Init.BaudRate = 115200; - huart2.Init.WordLength = UART_WORDLENGTH_8B; - huart2.Init.StopBits = UART_STOPBITS_1; - huart2.Init.Parity = UART_PARITY_NONE; - huart2.Init.Mode = UART_MODE_TX; - huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart2.Init.OverSampling = UART_OVERSAMPLING_16; - huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; - huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; - HAL_UART_Init(&huart2); - - lprint("hello"); -} - -/** -* @brief String out -* @param msg: Null-terminated string -* @retval None -*/ -void lprint(char *msg) -{ - HAL_UART_Transmit(&huart2, (uint8_t *)msg, strlen(msg), 100); -} - -/** -* @brief Binary data out -* @param msg: binary data -* @param len: data length -* @retval None -*/ -void lnprint(char *msg, size_t len) -{ - HAL_UART_Transmit(&huart2, (uint8_t *)msg, len, 100); -} - -/** -* @brief UART MSP Initialization -* @param huart: UART handle pointer -* @retval None -*/ -void HAL_UART_MspInit(UART_HandleTypeDef* huart) -{ - - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(huart->Instance==USART2) - { - __HAL_RCC_USART2_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USART2 GPIO Configuration - PA2 ------> USART2_TX - PA3 ------> USART2_RX - */ - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF1_USART2; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - } -} |