GadgetSeed  0.9.6
usart.c ファイル

STM32 シリアル(USARTドライバ) [詳解]

#include "sysconfig.h"
#include "device.h"
#include "interrupt.h"
#include "fifo.h"
#include "tkprintf.h"
#include "device/uart_ioctl.h"
#include "task/event.h"
#include "task/syscall.h"
#include "stm32f4xx_hal.h"
usart.c の依存先関係図:

[ソースコード]

マクロ定義

#define MAXBUFSIZE   256
 
#define USART_TC_TIMEOUT   100000
 
#define USART_TE_TIMEOUT   1000
 

型定義

typedef struct st_usart_data st_usart_data
 

関数

static void init_rcc_usart2 (void)
 
static void init_gpio_usart2 (void)
 
static void init_rcc_usart6 (void)
 
static void init_gpio_usart6 (void)
 
static void init_usart (st_usart_data *usart_dt, USART_TypeDef *usart, int irq)
 
void inthdr_usart (unsigned int intnum, void *sp)
 
static int usart_init (struct st_device *dev, char *param)
 
static int usart_getc (struct st_device *dev, unsigned char *rd)
 
static int usart_putc (struct st_device *dev, unsigned char td)
 
static int usart_ioctl (struct st_device *dev, unsigned int com, unsigned int arg, void *param)
 
static int usart_select (struct st_device *dev, unsigned int timeout)
 
static int usart_init_low (struct st_device *dev, char *param)
 
static int usart_getc_low (struct st_device *dev, unsigned char *rd)
 
static int usart_putc_low (struct st_device *dev, unsigned char td)
 

変数

const struct st_device usart2_device
 
const struct st_device usart6_device
 
static st_usart_data usart_data [3]
 
static const char usart_rx_eventqueue_name [2][10]
 
static const char usart_tx_eventqueue_name [2][10]
 
static UART_HandleTypeDef huart_low
 
const struct st_device usart2_low_device
 

詳解

STM32 シリアル(USARTドライバ)

日付
2015.08.09
著者
Takashi SHUDO

NUCLEO-F411RE Virtual COM port USART2_TX PA2 USART2_RX PA3

USART6_TX PA11 USART6_RX PA12

32F469IDISCOVERY Virtual COM port USART3_TX PB10 USART3_RX PB11

usart.c に定義があります。

変数詳解

◆ usart2_device

const struct st_device usart2_device
初期値:
= {
.explan = "STM32F4 USART2",
.private_data = (void *)&usart_data[0],
.register_dev = usart_init,
.getc = usart_getc,
.putc = usart_putc,
.ioctl = usart_ioctl,
.select = usart_select
}
#define DEF_DEV_NAME_UART
標準入出力用UARTデバイス名
Definition: uart_ioctl.h:16

usart.c50 行目に定義があります。

◆ usart2_low_device

const struct st_device usart2_low_device
初期値:
= {
.explan = "Debug/Error Console",
.private_data = (void *)&usart_data[2],
.register_dev = usart_init_low,
.getc = usart_getc_low,
.putc = usart_putc_low
}
#define DEF_DEV_NAME_DEBUG
標準エラー出力用UARTデバイス名
Definition: uart_ioctl.h:15

usart.c431 行目に定義があります。

◆ usart6_device

const struct st_device usart6_device
初期値:
= {
.name = DEF_DEV_NAME_UART "1",
.explan = "STM32F4 USART6",
.private_data = (void *)&usart_data[1],
.register_dev = usart_init,
.getc = usart_getc,
.putc = usart_putc,
.ioctl = usart_ioctl,
.select = usart_select
}
#define DEF_DEV_NAME_UART
標準入出力用UARTデバイス名
Definition: uart_ioctl.h:16

usart.c109 行目に定義があります。

◆ usart_rx_eventqueue_name

const char usart_rx_eventqueue_name[2][10]
static
初期値:
= {
"usart2_rx",
"usart6_rx"
}

usart.c198 行目に定義があります。

◆ usart_tx_eventqueue_name

const char usart_tx_eventqueue_name[2][10]
static
初期値:
= {
"usart2_tx",
"usart6_tx"
}

usart.c208 行目に定義があります。