uart tx running

This commit is contained in:
tkl
2016-08-17 10:06:18 +02:00
parent a8a4cb263d
commit 4a9da1a9fd
14 changed files with 324 additions and 168 deletions

View File

@@ -10,13 +10,14 @@
#include <stdint.h>
#if 0
#include "../../../driver/include/stm32f4_pwm.h"
#include "../../../driver/include/stm32f4_uart.h"
#include "pwm.h"
#include "uart.h"
#include "ringbuffer.h"
#endif
#include "stm32f4xx.h"
#include "uart.h"
#include "stm32f4_uart.h"
#include "ringbuffer.h"
#include "timer.h"
#include "stm32_sys_tick.h"
#include "sys_tick.h"
@@ -222,51 +223,55 @@ const struct driver pwm_1 = {
&pwm_ch1,
};
#endif
#if 0
// UART 1
static char console_linear_buffer[80];
static const GPIO_InitTypeDef port_cfg_uart1 = {
.Pin = GPIO_PIN_6 | GPIO_PIN_7,
.Mode = GPIO_MODE_AF_PP,
.Pull = GPIO_PULLUP,
.Speed = GPIO_SPEED_FREQ_HIGH,
.Alternate = GPIO_AF7_USART1,
};
static const struct stm32f4_gpio stm32f4_uart1_gpio = {
.port = GPIOB,
.pin = &port_cfg_uart1,
};
static UART_HandleTypeDef stm32f4_discovery_uart1_handle = {
.Instance = USART1,
.Init.BaudRate = 115200,
.Init.WordLength = UART_WORDLENGTH_8B,
.Init.StopBits = UART_STOPBITS_1,
.Init.Parity = UART_PARITY_NONE,
.Init.Mode = UART_MODE_TX_RX,
.Init.HwFlowCtl = UART_HWCONTROL_NONE,
.Init.OverSampling = UART_OVERSAMPLING_16,
.pTxBuffPtr = NULL,
.TxXferSize = 0,
.TxXferCount = 0,
.pRxBuffPtr = NULL,
.RxXferSize = 0,
.RxXferCount = 0,
.hdmatx = NULL,
.hdmarx = NULL,
.Lock = HAL_UNLOCKED,
.gState = HAL_UART_STATE_RESET,
.ErrorCode = 0,
};
static const struct stm32f4_uart stm32f4_uart1 = {
.uart_gpio = &stm32f4_uart1_gpio,
.uart_handle = &stm32f4_discovery_uart1_handle,
};
static char console_linear_buffer[10];
static struct ringbuffer console_buffer = {
console_linear_buffer,
console_linear_buffer,
console_linear_buffer,
sizeof(console_linear_buffer),
10,
0
};
static const GPIO_InitTypeDef stm32f4_discovery_uart1_gpio = {
GPIO_Pin_6 | GPIO_Pin_7,
GPIO_Mode_AF,
GPIO_Speed_50MHz,
GPIO_OType_PP,
GPIO_PuPd_UP
};
static const USART_InitTypeDef stm32f4_discovery_uart1_usart_init = {
115200,
USART_WordLength_8b,
USART_StopBits_1,
USART_Parity_No,
USART_Mode_Tx | USART_Mode_Rx,
USART_HardwareFlowControl_None,
};
static const NVIC_InitTypeDef stm32f4_discovery_uart1_nvic_init = {
USART1_IRQn,
0,
0,
ENABLE,
};
static const struct stm32f4_uart stm32f4_uart1 = {
&stm32f4_discovery_uart1_gpio,
GPIOB,
GPIO_PinSource7,
GPIO_PinSource6,
&stm32f4_discovery_uart1_usart_init,
USART1,
USART_IT_RXNE /* | USART_IT_TXE*/,
&stm32f4_discovery_uart1_nvic_init,
};
static const struct uart __uart_1 = {
&stm32f4_uart1,
@@ -282,7 +287,7 @@ const struct driver uart_1 = {
DRIVER_TYPE_UART,
&__uart_1,
};
#endif
#if 0
// GPIOC0
static const GPIO_InitTypeDef port_cfg_C0 = {