zoukankan      html  css  js  c++  java
  • XILINX GPIO驱动分析

    High Level – level 1 hardware driver api

    Low Level – level 0 hardware driver api

    XGPIO.H

    #include "xil_types.h"

    #include "xil_assert.h"

    #include "xstatus.h"

    #include "xgpio_l.h"

    Define:

    XGpio_CfgInitialize

    XGpio_SetDataDirection

    XGPIO.C

        #include "xgpio.h"

    #include "xstatus.h"

    Implement:

    XGpio_CfgInitialize

    XGpio_SetDataDirection

    <==上面API:

    #include "xgpio_l.h" (xgpio low level)

    XGPIO_L.H:

        #include "xil_types.h"

    #include "xil_assert.h"

    #include "xil_io.h"

    #define XGPIO_DATA_OFFSET    0x0 /**< Data register for 1st channel */

    #define XGPIO_TRI_OFFSET    0x1 /**< I/O direction reg for 1st channel */

    #define XGPIO_DATA2_OFFSET    0x2 /**< Data register for 2nd channel */

    #define XGPIO_TRI2_OFFSET    0x3 /**< I/O direction reg for 2nd channel */

     

    #define XGPIO_GIE_OFFSET    0x47 /**< Global interrupt enable register */

    #define XGPIO_ISR_OFFSET    0x48 /**< Interrupt status register */

    #define XGPIO_IER_OFFSET    0x4A /**< Interrupt enable register */

    #define XGpio_ReadReg     Xil_In32 ==> (xil_io.c)

    XGPIO_L.C文件不存在,因为LOW LEVEL的驱动全是MACRO写的,不需要C文件实现。

    < == 上面API:

    #include "xil_io.h"

    XIL_IO.H:

    #include "xil_types.h"

    #include "xpseudo_asm.h"

    #include "xil_printf.h"

    DEFINE:

        u8 Xil_In8(u32 Addr);

    u16 Xil_In16(u32 Addr);

    u32 Xil_In32(u32 Addr);

    XIL_IO.C

        #include "xil_io.h"

    #include "xil_types.h"

    #include "xil_assert.h"

    #include "xpseudo_asm.h"

    #include "xreg_cortexa9.h"

    Implement:

    u8 Xil_In8(u32 Addr);

    u16 Xil_In16(u32 Addr);

    u32 Xil_In32(u32 Addr);

    <= =上层API:

    H:

    #include "xpseudo_asm.h"

    C:

    #include "xpseudo_asm.h"

    #include "xreg_cortexa9.h"

    XPSEUDO_ASM.H 没有C文件

    #include "xreg_cortexa9.h"

        #include "xpseudo_asm_gcc.h"

    XREG_CORTEXA9.H 没有C文件

        /* GPRs */

    #define XREG_GPR0                r0

    #define XREG_GPR1                r1

    #define XREG_GPR2                r2

    #define XREG_GPR14                r14

    #define XREG_GPR15                r15

    #define XREG_CPSR                cpsr

    XPSEUDO_ASM_GCC.H:没有C文件

    /* pseudo assembler instructions */

    #define mfcpsr()    ({unsigned int rval; \

                 __asm__ __volatile__(\

                 "mrs    %0, cpsr\n"\

                 : "=r" (rval)\

                 );\

                 rval;\

                 })

     

    /* Memory Operations */

    #define ldr(adr)    ({unsigned long rval; \

                 __asm__ __volatile__(\

                 "ldr    %0,[%1]"\

                 : "=r" (rval) : "r" (adr)\

                 );\

                 rval;\

                 })

     

    下图是各个文件与其对应的功能图:

    下图是GPIO模块驱动API的层次结构图:

  • 相关阅读:
    Poj2155Matrix二维线段树
    二维树状数组模板
    PAT-1014 Waiting in Line (30 分) 优先队列
    PAT-1012 The Best Rank (25 分) 查询分数对应排名(包括并列)
    PAT-1003 Emergency (25 分) 最短路最大点权+求相同cost最短路的数量
    PAT-1001 A+B Format (20 分) 注意零的特例
    利用requests和BeautifulSoup爬取菜鸟教程的代码与图片并保存为markdown格式
    菜鸟教程上的设计模式代码合集
    用python将项目中的所有代码(或txt)合并在一个文件中
    POJ 2485 Prim 找最长的边
  • 原文地址:https://www.cnblogs.com/dragen/p/3113642.html
Copyright © 2011-2022 走看看