当前位置:网站首页>MicroBlaze serial port learning · 2
MicroBlaze serial port learning · 2
2022-06-30 16:18:00 【Hua Weiyun】
microblaze Serial port learning ·2
Serial initialization function 1int XUartLite_Initialize(XUartLite *InstancePtr, u16 DeviceId)
int XUartLite_Initialize(XUartLite *InstancePtr, u16 DeviceId){ XUartLite_Config *ConfigPtr; Xil_AssertNonvoid(InstancePtr != NULL); ConfigPtr = XUartLite_LookupConfig(DeviceId); if (ConfigPtr == (XUartLite_Config *)NULL) { return XST_DEVICE_NOT_FOUND; } return XUartLite_CfgInitialize(InstancePtr, ConfigPtr, ConfigPtr->RegBaseAddr);}##1 Serial initialization XUartLite_Config *ConfigPtr;
typedef struct { u16 DeviceId; /**< Unique ID of device */ UINTPTR RegBaseAddr; /**< Register base address */ u32 BaudRate; /**< Fixed baud rate */ u8 UseParity; /**< Parity generator enabled when TRUE */ u8 ParityOdd; /**< Parity generated is odd when TRUE, even when FALSE */ u8 DataBits; /**< Fixed data bits */} XUartLite_Config;ConfigPtr Is a pointer to a structure , This structure contains some parameters of serial port configuration , It should be noted that .MDM Some parameters of the serial port cannot be modified at the register level . Therefore, it is necessary to instantiate the hardware engineering . Set it up
2 Xil_AssertNonvoid(InstancePtr != NULL);
xlinx The assertion function of , Used to check the validity of parameter input , Guess it was redirected assert Output , This will be studied later . It does not affect the overall logical implementation .
3 ConfigPtr = XUartLite_LookupConfig(DeviceId);
XUartLite_Config *XUartLite_LookupConfig(u16 DeviceId){ XUartLite_Config *CfgPtr = NULL; u32 Index; for (Index=0; Index < XPAR_XUARTLITE_NUM_INSTANCES; Index++) { if (XUartLite_ConfigTable[Index].DeviceId == DeviceId) { CfgPtr = &XUartLite_ConfigTable[Index]; break; } } return CfgPtr;} The control vector is assigned in this function .
First initialize the null pointer , Then check the peripherals ID, And then through IC Inquire about , take XUartLite_ConfigTable The parameters in are passed to XUartLite_Configptr.XUartLite_ConfigTable The structure and CfgPtr The structure of is exactly the same .XUartLite_ConfigTable By vitis Automatically generated parameter configuration file ,XUartLite_ConfigTable The essence is a structural constant , All the internal parameters are defined by macros , The specific parameters are saved in xparameter in .
If you enter DeviceID illegal , Then the function will return a null pointer , Causes configuration failure .
4 return XUartLite_CfgInitialize(InstancePtr, ConfigPtr,ConfigPtr->RegBaseAddr);
int XUartLite_CfgInitialize(XUartLite *InstancePtr, XUartLite_Config *Config, UINTPTR EffectiveAddr){ (void) Config; /* * Assert validates the input arguments */ Xil_AssertNonvoid(InstancePtr != NULL); /* * Set some default values, including setting the callback * handlers to stubs. */ InstancePtr->SendBuffer.NextBytePtr = NULL; InstancePtr->SendBuffer.RemainingBytes = 0; InstancePtr->SendBuffer.RequestedBytes = 0; InstancePtr->ReceiveBuffer.NextBytePtr = NULL; InstancePtr->ReceiveBuffer.RemainingBytes = 0; InstancePtr->ReceiveBuffer.RequestedBytes = 0; InstancePtr->IsReady = XIL_COMPONENT_IS_READY;#if (XPAR_XUARTLITE_USE_DCR_BRIDGE != 0) InstancePtr->RegBaseAddress = ((EffectiveAddr >> 2)) & 0xFFF;#else InstancePtr->RegBaseAddress = EffectiveAddr;#endif InstancePtr->RecvHandler = StubHandler; InstancePtr->SendHandler = StubHandler; /* Write to the control register to disable the interrupts, don't * reset the FIFOs are the user may want the data that's present */ XUartLite_WriteReg(InstancePtr->RegBaseAddress, XUL_CONTROL_REG_OFFSET, 0); /* * Clear the statistics for this driver */ XUartLite_ClearStats(InstancePtr); return XST_SUCCESS;}The parameter passed in is a peripheral pointer , Peripheral configuration parameter pointer , Starting address of peripheral register . First of all, I will introduce Config Struct pointer cast to typeless ( I don't understand it here , Why do I have to do this ?)
Assign initial values to some variables in the external structure
about XPAR_XUARTLITE_USE_DCR_BRIDGE I found the understanding of this Xlinx A piece of file .

On-Chip Periphaeral Bus (OPB)
**device control register (DCR) **
You can see that there are many different ways to access peripheral registers , The article mentioned a kind of CPU-OPB Bridge Road .
Dig a hole in this place first , We will study the implementation details and differences later .
5 XUartLite_WriteReg(BaseAddress, RegOffset, Data)
#define XUartLite_WriteReg(BaseAddress, RegOffset, Data)
XUartLite_Out32((BaseAddress) + (RegOffset), (u32)(Data))
Then follow the configuration , Write address + Address offset + data
Then clear the peripheral Stats reg sign , So far, initialization is complete .
边栏推荐
- go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
- [unity ugui] scrollrect dynamically scales the grid size and automatically locates the middle grid
- '&lt;', hexadecimal value 0x3C, is an invalid 问题解决
- How cloudxr promotes the future development of XR
- 【时序数据库InfluxDB】Windows环境下配置InfluxDB+数据可视化,以及使用 C#进行简单操作的代码实例
- IIS无法加载字体文件(*.woff,*.svg)的解决办法
- Log4j2 进阶使用
- Policy Center > Malware > Malware
- Oculus quest2 | unity configures the oculus quest2 development environment and packages an application for real machine testing
- Warning: [antd: Menu] `children` will be removed in next major version. Please use `items` instead.
猜你喜欢

go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)

Message queue ten questions

《你的灯亮着吗》开始解决问题前,得先知道“真问题”是什么

LeCun指明下一代AI方向:自主机器智能

大学生研究生毕业找工作,该选择哪个方向?

《网络是怎么样连接的》读书笔记 - 汇总篇

Swagger's asp Net core web API help page

Hundreds of lines of code to implement a JSON parser

Compulsory national standard for electronic cigarette GB 41700-2022 issued and implemented on October 1, 2022

数据治理市场:亿信华辰朝左,华傲数据向右
随机推荐
Using asp Net core creating web API series
Swagger's asp Net core web API help page
flink sql cdc 同步sqlserver 报错什么原因啊
Three development trends of enterprise application viewed from the third technological revolution
智慧风电:数字孪生 3D 风机智能设备运维
Which direction should college students choose to find jobs after graduation?
Types of waveguides
开源 STM32 USB-CAN项目
ASP. Net core signalr series hub tutorial
How to connect the Internet Reading Notes - Summary
The difference between intermodulation and intermodulation
With as subquery in Oracle
mysql8报错:ERROR 1410 (42000): You are not allowed to create a user with GRANT解决办法
Hundreds of lines of code to implement a JSON parser
边缘计算平台如何助力物联网发展
Go micro installation
Modifying MySQL password under Linux: error 1396 (HY000): Operation alter user failed for 'root' @ 'localhost‘
MySQL proxy middleware atlas installation and configuration
交调与互调的区别
互联网研发效能之去哪儿网(Qunar)核心领域DevOps落地实践