通用异步收发传输器(Universal Asynchronous Receiver/Transmitter),通常称作UART。它将要传输的资料在串行通信与并行通信之间加以转换。作为把并行输入信号转成串行输出信号的芯片,UART通常被集成于其他通讯接口的连结上。
本模块目前支持FT2000-4/D2000/E2000
本模块可使用MIO的uart功能
相关源文件为:
fpl011
├── fpl011.c
├── fpl011.h
├── fpl011_g.c
├── fpl011_hw.c
├── fpl011_hw.h
├── fpl011_intr.c
├── fpl011_options.c
└── fpl011_sinit.c
FPl011SetDataFormat()并将一个FPl011Format结构传递给它。FPl011Format结构应该包含所有必需的参数。参见下面的示例。
FPl011Format format =
{
u32 baudrate = 115200; /* In bps, ie 1200 */
u32 data_bits = FPL011_FORMAT_WORDLENGTH_8BIT ; /* Number of data bits */
u32 parity = FPL011_FORMAT_NO_PARITY ; /* Parity */
u8 stopbits = FPL011_FORMAT_1_STOP_BIT ; /* Number of stop bits */
};
FPl011SetDataFormat(&uart,&format);
Transmitting ,此接口兼容轮询与中断模式,用户传入特定buffer,函数外通过判断标志位确认发送是否完成。
u8 buffer_p[10] ;
u32 len = 0 ;
len = FPl011Send(&uart,buffer_p,sizeof(buffer_p)) ;
Receiving ,此接口兼容轮询与中断模式,用户传入特定buffer,函数外通过判断标志位确认发送是否完成。
u8 buffer_p[10] ;
u32 len = 0 ;
len = FPl011Receive(&uart,buffer_p,sizeof(buffer_p)) ;
baremetal/example/uart_test
初始化特定的FPl011实例,以便它可以被使用。
Initializes a specific FPl011 instance such that it is ready to be used.
参数 instance_id 是对应驱动的编号
Parameters
instance_id contains the ID of the device
FPl011Config *指向配置结构的指针,如果指定的设备不在系统中,则为NULL。
FPl011Config *A pointer to the configuration structure or NULL if the specified device is not in the system.
这个函数使用设备发送指定的缓冲区,采用轮询或中断驱动模式。
This functions sends the specified buffer using the device in either polled or interrupt driven mode.
uart_p 是指向FPl011实例的指针。 byte_p 是指向要发送的数据缓冲区的指针。 length 表示发送的字节数。任何已经放入传输FIFO的数据将被发送。
Parameters uart_p is a pointer to the FPl011 instance. byte_p is pointer to a buffer of data to be sent. length contains the number of bytes to be sent. Any data that was already put into the transmit FIFO will be sent.
返回
实际发送的字节数。
The number of bytes actually sent.
此函数尝试从设备接收指定字节数的数据,并将其存储到指定的缓冲区中。
This function attempts to receive a specified number of bytes of data from the device and store it into the specified buffer.
uart_p 是指向FPl011实例的指针
byte_p 是用于接收数据的缓冲区指针
length 表示接收的字节数。
uart_p is a pointer to the FPl011 instance byte_p is pointer to buffer for data to be received into length is the number of bytes to be received.
接收的字节数。
The number of bytes received.
This function reprograms the control register according to the following sequence mentioned in the TRM
参数
uart_p 是指向FPl011实例的指针
ctrl_reg 想要被写入的控制寄存器的参数
uart_p is a pointer to the FPl011 instance ctrl_reg value to be written
该函数设置UART的操作模式。 UART可以操作 两种模式之一:正常模式、本地环回模式。
This function sets the operational mode of the UART. The UART can operate in one of four modes: Normal, Local Loopback.
uart_p是指向FPl011实例的指针。
operation mode为UART模式。
uart_p is a pointer to the FPl011 instance.
operation_mode is the mode of the UART.
为指定的驱动程序实例设置选项。
Sets the options for the specified driver instance.
uart_p是指向FPl011实例的指针。
uart_p is a pointer to the FPl011 instance.
options contains the options to be set which are bit masks contained in the file FPl011_uart.h and named FUARTOPTION*.
清除指定驱动程序实例的选项。
Clear the options for the specified driver instance.
uart_p是指向fpl011实例的指针。
options 包含要设置的选项,这些选项是包含在文件FPl011_uart.h和名为FUARTOPTION*的位掩码。
uart_p is a pointer to the fpl011 instance.
options contains the options to be set which are bit masks contained in the file FPl011_uart.h and named FUARTOPTION*.
设置设备波特率。
Sets the baud rate for the device.
uart p是指向FPl011实例的指针
BaudRate 所要设置波特率
uart_p is a pointer to the FPl011 instance
BaudRate to be set
如果一切都按照预期配置,则返回FT_SUCCESS
如果请求的速率不可用,则返回FPL011_ERROR_PARAM
FT_SUCCESS if everything configured as expected
FPL011_ERROR_PARAM if the requested rate is not available because there was too much error
获取指定UART的数据格式。
Gets the data format for the specified UART.
uart_p 是指向fpl011实例的指针。
format_p 是一个指向格式结构的指针,该结构将在调用完成后包含数据格式。
uart_p is a pointer to the fpl011 instance.
format_p is a pointer to a format structure that will contain the data format after this call completes.
将需要的参数格式,设置至特定的串口驱动中
Sets the data format for the specified UART.
Uart_p 是指向fpl011实例的指针。
format_p 是一个指向格式结构的指针,该结构将在调用完成后包含数据格式。
uart_p is a pointer to the fpl011 instance.
format_p is a pointer to a format structure that will contain the data format after this call completes.
如果一切都按照预期配置,则使用FT_SUCCESS
如果其中一个参数无效,则返回FPL011_ERROR_PARAM
FT_SUCCESS if everything configured as expected FPL011_ERROR_PARAM if one of the parameters was not valid.
这个函数设置Tx FIFO触发器级别为'TriggerLevel'参数。
This functions sets the Tx FIFO trigger level to the 'TriggerLevel' argument.
uart_p 是指向fpl011实例的指针。 Trigger_level包含要设置的触发器级别。 这个值从0-32 (FPL011IFLS_TXIFLSEL_1_8 - FPL011IFLS_TXIFLSEL_7_8)
uart_p is a pointer to the fpl011 instance.
trigger_level contains the trigger level to set. This is a value from 0-32 (FPL011IFLS_TXIFLSEL_1_8 - FPL011IFLS_TXIFLSEL_7_8)
这个函数将Rx FIFO触发器级别设置为'TriggerLevel'参数。
This functions sets the Rx FIFO trigger level to the 'TriggerLevel' argument.
uart_p 是指向fpl011实例的指针。 Trigger_level包含要设置的触发器级别。 这个值从0-32 (FPL011IFLS_RXIFLSEL_1_8 - FPL011IFLS_RXIFLSEL_7_8)
uart_p is a pointer to the fpl011 instance.
trigger_level contains the trigger level to set. This is a value from 0-32 (FPL011IFLS_RXIFLSEL_1_8 - FPL011IFLS_RXIFLSEL_7_8)
这个函数获取中断掩码。
This function gets the interrupt mask.
uart_p是指向PFl011实例的指针
uart_p is a pointer to the PFl011 instance
这个函数设置中断掩码。
This function sets the interrupt mask.
uart_p是指向PFl011实例的指针
mask包含要启用或禁用的中断。 '1'启用中断,'0'禁用中断。
uart_p is a pointer to the PFl011 instance
mask contains the interrupts to be enabled or disabled. A '1' enables an interrupt, and a '0' disables.