• 在github上下载Digilent提供的IP核,在路径\ip\Pmods下找到PmodAD1
  • 点进去\drivers\PmodAD1中examples是main主程序
/******************************************************************************/
/*                                                                            */
/* main.c -- PmodAD1 Example Project                                          */
/*                                                                            */
/******************************************************************************/
/* Author: Arthur Brown                                                       */
/* Copyright 2017, Digilent Inc.                                              */
/******************************************************************************/
/* Module Description:                                                        */
/*                                                                            */
/* This file contains code for running a demonstration of the PmodAD1 when    */
/* used with the PmodAD1 IP core. This demo initializes the PmodAD1 IP core   */
/* and then polls its sample register, printing the analog voltage last       */
/* sampled by each of the AD1's two channels over UART.                       */
/*                                                                            */
/* Messages printed by this demo can be received by using a serial terminal   */
/* configured with the appropriate Baud rate. 115200 for Zynq systems, and    */
/* whatever the AXI UARTLITE IP is configured with for MicroBlaze systems,    */
/* typically 9600 or 115200 Baud.                                             */
/*                                                                            */
/******************************************************************************/
/* Revision History:                                                          */
/*                                                                            */
/*    08/15/2017(ArtVVB):   Created                                           */
/*    02/10/2018(atangzwj): Validated for Vivado 2017.4                       */
/*                                                                            */
/******************************************************************************/#include <stdio.h>
#include "PmodAD1.h"
#include "sleep.h"
#include "xil_cache.h"
#include "xil_io.h"
#include "xil_types.h"
#include "xparameters.h"PmodAD1 myDevice;
const float ReferenceVoltage = 3.3;void DemoInitialize();
void DemoRun();
void DemoCleanup();
void EnableCaches();
void DisableCaches();int main() {DemoInitialize();DemoRun();DemoCleanup();return 0;
}void DemoInitialize() {EnableCaches();AD1_begin(&myDevice, XPAR_PMODAD1_0_AXI_LITE_SAMPLE_BASEADDR);// Wait for AD1 to finish powering onusleep(1); // 1 us (minimum)
}void DemoRun() {AD1_RawData RawData;AD1_PhysicalData PhysicalData;while (1) {AD1_GetSample(&myDevice, &RawData); // Capture raw samples// Convert raw samples into floats scaled to 0 - VDDAD1_RawToPhysical(ReferenceVoltage, RawData, &PhysicalData);printf("Input Data 1: %.02f;   ", PhysicalData[0]);printf("Input Data 2: %.02f\r\n", PhysicalData[1]);// Do this 10x per secondusleep(100000);}
}void DemoCleanup() {DisableCaches();
}void EnableCaches() {#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_ICACHEXil_ICacheEnable();
#endif
#ifdef XPAR_MICROBLAZE_USE_DCACHEXil_DCacheEnable();
#endif
#endif
}void DisableCaches() {#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_DCACHEXil_DCacheDisable();
#endif
#ifdef XPAR_MICROBLAZE_USE_ICACHEXil_ICacheDisable();
#endif
#endif
}
  • src里是PmodAD1.c和PmodAD1.h,可以对此进行魔改
/******************************************************************************/
/*                                                                            */
/* PmodAD1.c -- PmodAD1 Driver Source                                         */
/*                                                                            */
/******************************************************************************/
/* Author: Arthur Brown                                                       */
/* Copyright 2017, Digilent Inc.                                              */
/******************************************************************************/
/* Module Description:                                                        */
/*                                                                            */
/* This file contains source code for the PmodAD1 driver                      */
/*                                                                            */
/******************************************************************************/
/* Revision History:                                                          */
/*                                                                            */
/*    08/15/2017(ArtVVB):   Created                                           */
/*    02/10/2018(atangzwj): Validated for Vivado 2017.4                       */
/*                                                                            */
/******************************************************************************//***************************** Include Files *******************************/#include "PmodAD1.h"/************************** Function Definitions ***************************//* ------------------------------------------------------------ */
/*** void AD1_begin(PmodAD1 *InstancePtr, u32 BaseAddress)
**
**   Parameters:
**      InstancePtr: A PmodAD1 object to start
**      BaseAddress: The base address of the PmodAD1 AXI_LITE_SAMPLE interface
**
**   Description:
**      Initialize the PmodAD1 device - note that the AD1 IP is free-running,
**      and this function just prepares the driver for use.
*/
void AD1_begin(PmodAD1 *InstancePtr, u32 BaseAddress) {InstancePtr->BaseAddress = BaseAddress;
}/* ------------------------------------------------------------ */
/*** void AD1_GetSample(PmodAD1 *InstancePtr, AD1_RawData *RawDataPtr)
**
**   Parameters:
**      InstancePtr: A PmodAD1 object to start
**      RawDataPtr:  Pointer to an array of raw data to return values in
**
**   Return:
**      *RawDataPtr: an array of unsigned 16 bit integers to store the ADC data
**         Channel 1's 12 bit data is stored in the RawData array at index 0
**         Channel 2's 12 bit data is stored in the RawData array at index 1
**
**   Description:
**      This function captures the most recently read sample from the PmodAD1 IP
**      core.
*/
void AD1_GetSample(PmodAD1 *InstancePtr, AD1_RawData *RawDataPtr) {u32 data;data = Xil_In32(InstancePtr->BaseAddress);(*RawDataPtr)[0] = data & AD1_DATA_MASK;(*RawDataPtr)[1] = (data >> 16) & AD1_DATA_MASK;
}/* ------------------------------------------------------------ */
/*** void AD1_RawToPhysical(float ReferenceVoltage, AD1_RawData RawData,
**         AD1_PhysicalData *PhysicalDataPtr)
**
**   Parameters:
**      ReferenceVoltage: Floating point representation of the voltage available
**                        to the AD1's VCC pin.
**      RawData:          Array of raw 12 bit sample data received from the
**                        PmodAD1
**      PhysicalDataPtr:  Pointer to an array of floats to return values in
**
**   Return:
**      *PhysicalDataPtr: an array of floats to store the converted data in.
**
**   Description:
**      This function converts an AD1 sample to a human readable value.
*/
void AD1_RawToPhysical(float ReferenceVoltage, AD1_RawData RawData,AD1_PhysicalData *PhysicalDataPtr) {float conversionFactor = ReferenceVoltage / ((1 << AD1_NUM_BITS) - 1);(*PhysicalDataPtr)[0] = ((float) RawData[0]) * conversionFactor;(*PhysicalDataPtr)[1] = ((float) RawData[1]) * conversionFactor;
}
/******************************************************************************/
/*                                                                            */
/* PmodAD1.h -- PmodAD1 Driver Definitions                                    */
/*                                                                            */
/******************************************************************************/
/* Author: Arthur Brown                                                       */
/* Copyright 2017, Digilent Inc.                                              */
/******************************************************************************/
/* Module Description:                                                        */
/*                                                                            */
/* This file contains definitions for the PmodAD1 driver                      */
/*                                                                            */
/******************************************************************************/
/* Revision History:                                                          */
/*                                                                            */
/*    08/15/2017(ArtVVB):   Created                                           */
/*    02/10/2018(atangzwj): Validated for Vivado 2017.4                       */
/*                                                                            */
/******************************************************************************/#ifndef PMODAD1_H
#define PMODAD1_H/****************** Include Files ********************/#include "xil_io.h"
#include "xil_types.h"/* ------------------------------------------------------------ */
/*                  Definitions                                 */
/* ------------------------------------------------------------ */#define AD1_NUM_BITS  12
#define AD1_DATA_MASK 0xFFFtypedef struct PmodAD1 {u32 BaseAddress;
} PmodAD1;typedef u16 AD1_RawData[2];
typedef float AD1_PhysicalData[2];/* ------------------------------------------------------------ */
/*                  Procedure Declarations                      */
/* ------------------------------------------------------------ */void AD1_begin(PmodAD1 *InstancePtr, u32 SPI_Address);
void AD1_GetSample(PmodAD1 *InstancePtr, AD1_RawData *RawDataPtr);
void AD1_RawToPhysical(float ReferenceVoltage, AD1_RawData RawData,AD1_PhysicalData *PhysicalDataPtr);#endif // PMODAD1_H

Digilent提供的Pmod AD1驱动程序相关推荐

  1. Digilent提供的Pmod AD5驱动程序

    examples里的main.c /******************************************************************************/ /* ...

  2. pmod ad2 digilent 提供的pmodad2.c和pmodad2.h

    配合原理图服用 PmodAD2.h /******************************************************************************/ / ...

  3. Digilent提供的PmodOLEDrgb驱动程序

    examples里的main.c /******************************************************************************/ /* ...

  4. 开启Digilent提供的Linux内核的NFS支持

    ZEDBoard上出厂的SD卡中自带了一个较完整的linux系统,虽然是精简版,但是对于开发来说已经足够了,在嵌入式linux开发中,挂载NFS协助调试非常常见,但是Digilent给出的内核中并没有 ...

  5. linux内核配置nfs,【参赛手记】开启Digilent提供的Linux内核的NFS支持

    ZEDBoard上出厂的SD卡中自带了一个较完整的linux系统,虽然是精简版,但是对于开发来说已经足够了,在嵌入式linux开发中,挂载NFS协助调试非常常见,但是Digilent给出的内核中并没有 ...

  6. 下载pyboard的flash中的驱动程序_NVIDIA提供了STUDIO图形驱动程序版本441.12--立即下载...

    NVIDIA提供了一个新的STUDIO图形软件包,该软件包与其多个视频卡兼容,即版本441.12,该软件包支持最新的Adobe MAX,包括与OptiX 7的兼容性,并修复了多个问题. 具体而言,生产 ...

  7. WinUSB - 微软为所有 USB 设备提供的常规驱动程序

    WinUSB - 微软为所有 USB 设备提供的常规驱动程序  [复制链接]     shangdawei 20 主题 0 好友 717 积分 高级会员 莫元 696 发消息 电梯直达 1楼  发表于 ...

  8. ENC28j60以太网芯片驱动程序简介

    转载: 本介绍可分为三块内容: 1.以太网数据帧结构 符合IEEE802.3标准的以太网帧的长度是介于64-1516字节之间.主要由目标MAC地址.源MAC地址.类型/长度字段.数据有效负载.可选填充 ...

  9. WindML相关知识和图形设备驱动程序开发(一)

    1.介绍 WindML即Wind Media Library(媒体库),它支持多媒体程序运行于嵌入式操作系统,风河公司设计它主要是用来提供基本的图形.视频和声频技术以及提供一个设计标准设备驱动程序框架 ...

最新文章

  1. 深入分析几种PHP获取客户端IP的情况
  2. 卷积神经网络(卷积层,激活函数Relu,池化层,计算公式及API解释)
  3. androd之绘制文本(FontMetrics)
  4. 怎么把原来的墙拆掉_家装拆除不是简单的砸砸墙,它也是有技术的
  5. Tcl Tutorial 笔记10 · list
  6. 触发器及其应用实验报告总结_2020年中考总复习: 光现象、透镜及其应用知识点总结...
  7. rgba与十六进制的相互转换,以及rgba的校验
  8. 动手刷LeetCode-转换罗马字符
  9. Bugku杂项——旋转跳跃
  10. Unity3D射击游戏的准心
  11. Python:实现simpson rule辛普森法则算法(附完整源码)
  12. Android增强现实(三)-3D模型展示器
  13. 学计算机毁一生,为什么说学医毁三代学法毁一生
  14. Java图片嵌套图片
  15. linux模拟usb发包,Linux下USB模拟ps2鼠标驱动
  16. 期货换手多换空换(期货交易多换空换是什么意思)
  17. OBS捕捉桌面显示器一直是黑屏怎么办?
  18. 如何通过名字判断一个印度人的种姓
  19. 电脑所有浏览器主页被篡改锁定的常见解决办法
  20. IT小公司管理的几点思考

热门文章

  1. 大工计算机基础在线作业答案,大工1209《计算机应用基础》在线作业123.doc
  2. vue组件内数值做watch监听,首次监听不到的问题
  3. LeetCode 73. 矩阵置零(两个标记变量)
  4. FFmpeg的H.264解码器源代码简单分析:环路滤波(Loop Filter)部分
  5. ffplay.c函数结构简单分析(画图)
  6. 常用编码软件简单使用记录 1 : 自主编码器
  7. Linux动态链接库隔离,Linux下的.so文件是动态链接库
  8. 将数据追加到html 表格中,【HTML】使用Jquery实现将输入数据添加至表格中
  9. spring mvc ajax登录验证,vuejs (前端项目) + spring mvc(后台项目),每次ajax请求都是新的session Id...
  10. 【CSP201312-4】有趣的数(数位DP)