zoukankan      html  css  js  c++  java
  • 深入分析GPIOPS驱动代码1,Zedboard,zynq7000

    How to use the GpioPs in zedboard

    Different from other micro controller, the zynq-7000 cortex a9 has only a gpio module ,and the gpio driver api is designed for the only module, which is called XPAR_XGPIOPS_0_DEIVICE_ID,so when you want to invoke the gpiops module ,the following 2 sentences is neccssary.

    XGpioPs_Config* pGpioPsCfg;

    pGpioPsCfg=XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);

    XGpioPs gpiops;

    XGpioPs_CfgInitialize(&gpiopps,pGpioPsCfg,pGpioPsCfg->BaseAddr);

        The driver will understand the gpio you specified according to the parameter: XPAR_XGPIOPS_0_DEVICE_ID;

        The simplest gpiops application is like this:

    #include "XGpioPs.h"

    XGpioPs_Config* pGpioPsCfg;

    pGpioPsCfg=XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);

    XGpioPs gpiops;

    XGpioPs_CfgInitialize(&gpiopps,pGpioPsCfg,pGpioPsCfg->BaseAddr);

        

    XGpioPs_WritePin(&gpiops,0x7,0x1);

    Build and run the code, LD9 will illumine immediately.

    What happened?

        We have neither set up the direction of gpiops or set the output enabled, but why the code works?

        This is due to the bsp project code have done most of the periphals initialize works at first, and the default is seting gpiops MIO7 ouput direction and output enable, so we need not to init the gpiops once again.

    The absolute code should like this:

    #include "XGpioPs.h"

    XGpioPs_Config* pGpioPsCfg;

    pGpioPsCfg=XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);

    XGpioPs gpiops;

    XGpioPs_CfgInitialize(&gpiopps,pGpioPsCfg,pGpioPsCfg->BaseAddr);

        

    XGpioPs_SetOutputPin(&gpiops,0x7,0x1);

    XGpioPs_SetOutputEnable(&gpiops,0x7,0x1);

    XGpioPs_WritePin(&gpiops,0x7,0x1);

    And now I will write a demo for uart according to the above format:

     

    1. Looking for the struct for xuartps, find in the driver/

        XUartPs_Config* pUartPs_Config;

        pUartPs_Config=XUartPs_LookupConfig(XPAR_XUARTPS_0_DEVICE_ID);

        XUartPs     UartPs;

        XUartPs_CfgInitialize(&UartPs,pUartPs_Config,pUartPs_Config->BaseAddress);

    1. Set the Baud Rate:

        XUartPs_SetBaudRate(&UartPs,9600);

    1. Send string:

        XUartPs_Send(&UartPs,"Hello,world.",12);

    As what we respected, it works.

     

     

    A Problem issued:

    1.     for (LedLoop = 0; LedLoop < LED_MAX_BLINK; LedLoop ++)

      Although you can find the LED_MAX_BLICK micro in other files(Use F3 can trace the micro),but if you not include it ,you should not use it.

  • 相关阅读:
    转】Apache解决高并发和高可用
    Kafka学习(一)配置及简单命令使用
    unity3d教程动态创建简单平面地形
    LeetCode: Unique Binary Search Trees [095]
    德惠也有星巴克
    一个css和js结合的下拉菜单,支持主流浏览器
    【图像处理】人类视觉成像原理
    windows使用nginx+memcached实现负载均衡和session或者缓存共享
    OpenCV基础篇之画图及RNG随机数对象
    在阿里云上布置git server
  • 原文地址:https://www.cnblogs.com/dragen/p/3124040.html
Copyright © 2011-2022 走看看