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.

  • 相关阅读:
    [No0000139]轻量级文本编辑器,Notepad最佳替代品:Notepad++
    [No0000138]软件开发基础知识
    [No0000137]字符编码详解
    [No0000144]深入浅出图解C#堆与栈 C# Heap(ing) VS Stack(ing)理解堆与栈1/4
    [No0000136]6个重要的.NET概念:栈,堆,值类型,引用类型,装箱,拆箱
    [No0000135]程序员修炼之道 Tips
    phpstorm 调试时浏览器显示The requested resource / was not found on this server
    php注解
    phpStorm 配置PHP_CodeSniffer自动检查代码
    php
  • 原文地址:https://www.cnblogs.com/dragen/p/3124040.html
Copyright © 2011-2022 走看看