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.

  • 相关阅读:
    如何优化软件测试成本?——转译
    Pytest(下篇)
    人与机器人如何协同来测试软件——译
    Appium自动化测试遇到的chromedriver/chrome坑
    Pytest(上篇)
    【selenium】利用selenium进行爬虫时,防止js检测驱动的方法
    【python】python分词和识别图像中的文字
    【python】Python获取QQ截图热键(ctrl+alt+a)截取的内容
    【python】pyinstaller如何将自己写的模块一并打包到exe中
    【python】python启动线程查看线程的名称和id;python杀掉进程的方法
  • 原文地址:https://www.cnblogs.com/dragen/p/3124040.html
Copyright © 2011-2022 走看看