• examples里的main.c
/******************************************************************************/
/*                                                                            */
/* main.c -- Demo project for the PmodOLEDrgb IP                              */
/*                                                                            */
/******************************************************************************/
/* Author: Thomas Kappenman                                                   */
/* Copyright 2016, Digilent Inc.                                              */
/******************************************************************************/
/* File Description:                                                          */
/*                                                                            */
/* This demo project initializes and uses the PmodOLEDrgb to display strings  */
/* of different colors and a BMP image.                                       */
/*                                                                            */
/******************************************************************************/
/* Revision History:                                                          */
/*                                                                            */
/*    02/08/2016(TommyK):   Created                                           */
/*    08/25/2017(artvvb):   Added proper cache management functions           */
/*    11/11/2017(atangzwj): Validated for Vivado 2016.4                       */
/*    02/17/2018(atangzwj): Validated for Vivado 2017.4                       */
/*                                                                            */
/******************************************************************************/#include "bitmap.h"
#include "PmodOLEDrgb.h"
#include "sleep.h"
#include "xil_cache.h"
#include "xparameters.h"void DemoInitialize();
void DemoRun();
void DemoCleanup();
void EnableCaches();
void DisableCaches();PmodOLEDrgb oledrgb;u8 rgbUserFont[] = {0x00, 0x04, 0x02, 0x1F, 0x02, 0x04, 0x00, 0x00, // 0x000x0E, 0x1F, 0x15, 0x1F, 0x17, 0x10, 0x1F, 0x0E, // 0x010x00, 0x1F, 0x11, 0x00, 0x00, 0x11, 0x1F, 0x00, // 0x020x00, 0x0A, 0x15, 0x11, 0x0A, 0x04, 0x00, 0x00, // 0x030x07, 0x0C, 0xFA, 0x2F, 0x2F, 0xFA, 0x0C, 0x07  // 0x04
}; // This table defines 5 user characters, although only one is usedint main(void) {DemoInitialize();DemoRun();DemoCleanup();return 0;
}void DemoInitialize() {EnableCaches();OLEDrgb_begin(&oledrgb, XPAR_PMODOLEDRGB_0_AXI_LITE_GPIO_BASEADDR,XPAR_PMODOLEDRGB_0_AXI_LITE_SPI_BASEADDR);
}void DemoRun() {char ch;// Define the user definable charactersfor (ch = 0; ch < 5; ch++) {OLEDrgb_DefUserChar(&oledrgb, ch, &rgbUserFont[ch * 8]);}OLEDrgb_SetCursor(&oledrgb, 2, 1);OLEDrgb_PutString(&oledrgb, "Digilent"); // Default color (green)OLEDrgb_SetCursor(&oledrgb, 4, 4);OLEDrgb_SetFontColor(&oledrgb, OLEDrgb_BuildRGB(0, 0, 255)); // Blue fontOLEDrgb_PutString(&oledrgb, "OledRGB");OLEDrgb_SetFontColor(&oledrgb, OLEDrgb_BuildRGB(200, 200, 44));OLEDrgb_SetCursor(&oledrgb, 1, 6);OLEDrgb_PutChar(&oledrgb, 4);OLEDrgb_SetFontColor(&oledrgb, OLEDrgb_BuildRGB(200, 12, 44));OLEDrgb_SetCursor(&oledrgb, 5, 6);OLEDrgb_PutString(&oledrgb, "Demo");OLEDrgb_PutChar(&oledrgb, 0);sleep(5); // Wait 5 secondsOLEDrgb_DrawBitmap(&oledrgb, 0, 0, 95, 63, (u8*) tommy);
}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里的PmodOLEDrgb.h
/******************************************************************************/
/*                                                                            */
/* PmodOLEDrgb.h -- Interface Declarations for PmodOLEDrgb.c                  */
/*                                                                            */
/******************************************************************************/
/* Author: Cristian Fatu, Thomas Kappenman                                    */
/* Copyright 2015, Digilent Inc.                                              */
/******************************************************************************/
/* File Description:                                                          */
/*                                                                            */
/* This header file contains the object class declarations and other          */
/* interface declarations need to use the PmodOLEDrgb display on any          */
/* MicroBlaze/Zynq design                                                     */
/*                                                                            */
/******************************************************************************/
/* Revision History:                                                          */
/*                                                                            */
/*    07/20/2015(CristianF): created                                          */
/*    04/19/2015(TommyK):    Adapted for use with Microblaze/Zynq .c designs  */
/*    08/25/2017(artvvb):    added OLEDrgb_sleep                              */
/*    11/11/2017(atangzwj):  Validated for Vivado 2016.4                      */
/*    02/17/2018(atangzwj):  Validated for Vivado 2017.4                      */
/*                                                                            */
/******************************************************************************/#ifndef PMODOLEDRGB_H
#define PMODOLEDRGB_H/************ Include Files ************/#include "xil_types.h"
#include "xspi.h"
#include "xspi_l.h"
#include "xstatus.h"/************ Macro Definitions ************/#define OLEDRGB_WIDTH  96
#define OLEDRGB_HEIGHT 64#define OLEDRGB_CHARBYTES    8    // Number of bytes in a glyph
#define OLEDRGB_USERCHAR_MAX 0x20 // Number of character defs in user font// table
#define OLEDRGB_CHARBYTES_USER (OLEDRGB_USERCHAR_MAX*OLEDRGB_CHARBYTES)// Number of bytes in user font table#define CMD_DRAWLINE                 0x21
#define CMD_DRAWRECTANGLE            0x22
#define CMD_COPYWINDOW               0x23
#define CMD_DIMWINDOW                0x24
#define CMD_CLEARWINDOW              0x25
#define CMD_FILLWINDOW               0x26
#define DISABLE_FILL                 0x00
#define ENABLE_FILL                  0x01
#define CMD_CONTINUOUSSCROLLINGSETUP 0x27
#define CMD_DEACTIVESCROLLING        0x2E
#define CMD_ACTIVESCROLLING          0x2F#define CMD_SETCOLUMNADDRESS           0x15
#define CMD_SETROWADDRESS              0x75
#define CMD_SETCONTRASTA               0x81
#define CMD_SETCONTRASTB               0x82
#define CMD_SETCONTRASTC               0x83
#define CMD_MASTERCURRENTCONTROL       0x87
#define CMD_SETPRECHARGESPEEDA         0x8A
#define CMD_SETPRECHARGESPEEDB         0x8B
#define CMD_SETPRECHARGESPEEDC         0x8C
#define CMD_SETREMAP                   0xA0
#define CMD_SETDISPLAYSTARTLINE        0xA1
#define CMD_SETDISPLAYOFFSET           0xA2
#define CMD_NORMALDISPLAY              0xA4
#define CMD_ENTIREDISPLAYON            0xA5
#define CMD_ENTIREDISPLAYOFF           0xA6
#define CMD_INVERSEDISPLAY             0xA7
#define CMD_SETMULTIPLEXRATIO          0xA8
#define CMD_DIMMODESETTING             0xAB
#define CMD_SETMASTERCONFIGURE         0xAD
#define CMD_DIMMODEDISPLAYON           0xAC
#define CMD_DISPLAYOFF                 0xAE
#define CMD_DISPLAYON                  0xAF
#define CMD_POWERSAVEMODE              0xB0
#define CMD_PHASEPERIODADJUSTMENT      0xB1
#define CMD_DISPLAYCLOCKDIV            0xB3
#define CMD_SETGRAySCALETABLE          0xB8
#define CMD_ENABLELINEARGRAYSCALETABLE 0xB9
#define CMD_SETPRECHARGEVOLTAGE        0xBB
#define CMD_SETVVOLTAGE                0xBE/**************************** Type Definitions *****************************/
/**** Write a value to a PMODOLEDRGB register. A 32 bit write is performed.* If the component is implemented in a smaller width, only the least* significant data is written.** @param   BaseAddress is the base address of the PMODOLEDRGBdevice.* @param   RegOffset is the register offset from the base to write to.* @param   Data is the data written to the register.** @return  None.** @note* C-style signature:*     void PMODOLEDRGB_mWriteReg(u32 BaseAddress, unsigned RegOffset, u32 Data)**/
#define PMODOLEDRGB_mWriteReg(BaseAddress, RegOffset, Data) \Xil_Out32((BaseAddress) + (RegOffset), (u32)(Data))/**** Read a value from a PMODOLEDRGB register. A 32 bit read is performed.* If the component is implemented in a smaller width, only the least* significant data is read from the register. The most significant data* will be read as 0.** @param   BaseAddress is the base address of the PMODOLEDRGB device.* @param   RegOffset is the register offset from the base to write to.** @return  Data is the data from the register.** @note* C-style signature:*     u32 PMODOLEDRGB_mReadReg(u32 BaseAddress, unsigned RegOffset)**/
#define PMODOLEDRGB_mReadReg(BaseAddress, RegOffset) \Xil_In32((BaseAddress) + (RegOffset))/************************** Function Prototypes ****************************/
/**** Run a self-test on the driver/device. Note this may be a destructive test if* resets of the device are performed.** If the hardware system is not built correctly, this function may never* return to the caller.** @param   baseaddr_p is the base address of the PMODOLEDRGB instance to be*          worked on.** @return**    - XST_SUCCESS   if all self-test code passed*    - XST_FAILURE   if any self-test code failed** @note    Caching must be turned off for this function to work.* @note    Self test may fail if data memory and device are not on the same bus**/
XStatus PMODOLEDRGB_Reg_SelfTest(void *baseaddr_p);/************ Type Definitions ************/typedef struct {u32 GPIO_addr;XSpi OLEDSpi;u8 *pbOledrgbFontCur;u8 *pbOledrgbFontUser;u8 rgbOledrgbFontUser[OLEDRGB_CHARBYTES_USER];int dxcoOledrgbFontCur;int dycoOledrgbFontCur;uint16_t m_FontColor, m_FontBkColor;int xchOledCur;int ychOledCur;int xchOledrgbMax;int ychOledrgbMax;
} PmodOLEDrgb;/************ Function Prototypes ************/void OLEDrgb_begin(PmodOLEDrgb *InstancePtr, u32 GPIO_Address, u32 SPI_Address);
void OLEDrgb_end(PmodOLEDrgb *InstancePtr);void OLEDrgb_DrawPixel(PmodOLEDrgb *InstancePtr, u8 c, u8 r,uint16_t pixelColor);
void OLEDrgb_DrawLine(PmodOLEDrgb *InstancePtr, u8 c1, u8 r1, u8 c2, u8 r2,uint16_t lineColor);
void OLEDrgb_DrawRectangle(PmodOLEDrgb *InstancePtr, u8 c1, u8 r1, u8 c2, u8 r2,uint16_t lineColor, u8 bFill, uint16_t fillColor);
void OLEDrgb_Clear(PmodOLEDrgb *InstancePtr);
void OLEDrgb_DrawBitmap(PmodOLEDrgb *InstancePtr, u8 c1, u8 r1, u8 c2, u8 r2,u8 *pBmp);void OLEDrgb_SetCursor(PmodOLEDrgb *InstancePtr, int xch, int ych);
void OLEDrgb_GetCursor(PmodOLEDrgb *InstancePtr, int *pxch, int *pych);
int OLEDrgb_DefUserChar(PmodOLEDrgb *InstancePtr, char ch, u8 *pbDef);
void OLEDrgb_DrawGlyph(PmodOLEDrgb *InstancePtr, char ch);
void OLEDrgb_PutChar(PmodOLEDrgb *InstancePtr, char ch);
void OLEDrgb_PutString(PmodOLEDrgb *InstancePtr, char *sz);
void OLEDrgb_SetFontColor(PmodOLEDrgb *InstancePtr, uint16_t fontColor);
void OLEDrgb_SetFontBkColor(PmodOLEDrgb *InstancePtr, uint16_t fontBkColor);
void OLEDrgb_SetCurrentFontTable(PmodOLEDrgb *InstancePtr, u8 *pbFont);
void OLEDrgb_SetCurrentUserFontTable(PmodOLEDrgb *InstancePtr, u8 *pbUserFont);
void OLEDrgb_AdvanceCursor(PmodOLEDrgb *InstancePtr);
void OLEDrgb_SetScrolling(PmodOLEDrgb *InstancePtr, u8 scrollH, u8 scrollV,u8 rowAddr, u8 rowNum, u8 timeInterval);
void OLEDrgb_EnableScrolling(PmodOLEDrgb *InstancePtr, u8 fEnable);
void OLEDrgb_EnablePmod(PmodOLEDrgb *InstancePtr, u8 fEnable);
void OLEDrgb_EnableBackLight(PmodOLEDrgb *InstancePtr, u8 fEnable);
void OLEDrgb_Copy(PmodOLEDrgb *InstancePtr, u8 c1, u8 r1, u8 c2, u8 r2, u8 c3,u8 r3);
void OLEDrgb_Dim(PmodOLEDrgb *InstancePtr, u8 c1, u8 r1, u8 c2, u8 r2);
void OLEDrgb_HostInit(PmodOLEDrgb *InstancePtr);
void OLEDrgb_HostTerm(PmodOLEDrgb *InstancePtr);
void OLEDrgb_DevInit(PmodOLEDrgb *InstancePtr);
void OLEDrgb_DevTerm(PmodOLEDrgb *InstancePtr);int OLEDrgb_SPIInit(XSpi *SpiInstancePtr);
void OLEDrgb_WriteSPICommand(PmodOLEDrgb *InstancePtr, u8 cmd);
void OLEDrgb_WriteSPI(PmodOLEDrgb *InstancePtr, u8 *pCmd, int nCmd, u8 *pData,int nData);
uint16_t OLEDrgb_BuildHSV(u8 hue, u8 sat, u8 val);
uint16_t OLEDrgb_BuildRGB(u8 R, u8 G, u8 B);u8 OLEDrgb_ExtractRFromRGB(uint16_t wRGB);
u8 OLEDrgb_ExtractGFromRGB(uint16_t wRGB);
u8 OLEDrgb_ExtractBFromRGB(uint16_t wRGB);#endif // PMODOLEDRGB_H

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

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

    在github上下载Digilent提供的IP核,在路径\ip\Pmods下找到PmodAD1 点进去\drivers\PmodAD1中examples是main主程序 /************** ...

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

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

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

    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. pmod ad2 digilent 提供的pmodad2.c和pmodad2.h

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

  7. 【学习笔记】JDBC:java提供的专门操纵数据库的API JDBC驱动程序的类型 JDBC常用的类与接口

    JDBC技术 JDBC的全称是Java DataBase Connectivity,是一套面向对象的应用程序接口,指定了统一的访问各种关系型数据库的标准接口,JDBC是一种底层的API,因此访问数据库 ...

  8. java加载驱动没有异常显示_java – Tomcat没有加载MSSQL驱动程序

    我正在尝试将我的webapp部署到Tomcat容器,但是我得到一个例外,说明找不到我的数据库的驱动程序.在本地我测试Jetty上的应用程序,驱动程序jar由Maven提供.我将驱动程序jar复制到To ...

  9. 用WDM开发USB驱动程序

    摘要:本文简单介绍了WDM和USB的一些基本概念,给出了开发USB驱动程序的流程和基本步骤,同时对开发USB设备的接口软件结构和驱动程序作了介绍.最后给出了PC机对USB设备的应用程序实现 关键词:W ...

最新文章

  1. 最大子序列、最长递增子序列、最长公共子串、最长公共子序列、字符串编辑距离
  2. 传统I/O 数据拷贝
  3. [html] 你认为Html的术难点在哪?
  4. 三元函数的几何图形一般是_多元函数微分学_高等数学习题与答案_doc_大学课件预览_高等教育资讯网...
  5. PE 文件格式 详解 一
  6. php 类似百度分页,写了一个仿百度贴吧分页效果的分页类,有人要么?
  7. EEGLAB教程-1.2通道定位
  8. Delphi 10.3.3 安装DevExpress VCL 19 教程
  9. 华为mt2c00 android7.0,mate9安卓7.0哪个版本最好用
  10. EChart如何实现中国地图和省份下钻
  11. [HTML5-SVG]SVG是什么?SVG有什么用途?
  12. unity中射线碰撞检测总结
  13. SEO整站优化方案制作
  14. 评论《献给每天想辞职的人》
  15. 谷歌浏览器不能同步功能,chrome不能登录解决办法
  16. 解读IPD流程体系的“三驾马车”
  17. 最新最酷Android手机游戏灵活的球球代码
  18. 大学物理实验试卷1到8_一大学物理实验考试卷
  19. 传统医学师承和确有专长人员医师资格考核考试办法在全国全面实施
  20. Matlab编写二叉树定价公式,美式期权二叉树定价及MATLAB程序

热门文章

  1. php使用jasperreport,用PHP访问JasperReport | 学步园
  2. c 与java性能测试_JNI只C性能测试
  3. 小明利用计算机软件绘制函数,辽宁省大连市2014年高二学业水平模拟考试 信息技术试题(三)...
  4. python rpy2时间序列_当从多线程使用rpy2调用r函数时,模型作为r函数的参数
  5. Python pip install修改默认下载路径
  6. layUI数据表格可编辑扩展日期框
  7. logback为日志配置颜色
  8. C++STL优先队列小根堆大根堆自定义的应用
  9. 【51nod】最大子段和
  10. Hibernate→HQL、query.list()返回数据类型、查询相关语句、分页、原生SQL、@注解、持久化对象状态及生命周期、一多关系、继承映射关系、逆向工程