#include <stdio.h>
#include "platform.h"
#include "xil_types.h"
#include "xgpio.h"
#include "xparameters.h"
#include "xgpiops.h"
#include "xil_io.h"
#include "oled.h"
//extern char inbyte(void);//调用inbyte接收一个字节输入函数
extern XGpioPs_Config XGpioPs_ConfigTable[XPAR_XGPIOPS_NUM_INSTANCES];
//int
main()
{
static XGpioPs psGpioInstancePtr;
XGpioPs_Config*GpioConfigPtr;
static XGpio GPIOInstance_Ptr; int xStatus,start,end;
u32 Readstatus1,Readstatus2;
int iPinNumberld9 = 7; /*Ld9 is connected to MIO pin 7*/
int iPinNumberbtn8 = 50;/*Btn8 is connected to MIO pin 50*/
int iPinNumberbtn9 = 51;/*Btn9 is connected to MIO pin 51*/
int iPinNumberBTNU = 54;/*BTNU is connected to EMIO pin 54*/
init_platform();
print("##### Application Starts #####\n\r"); print("\r\n"); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Step-1 :AXI GPIO Initialization //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define XPAR_AXI_GPIO_0_DEVICE_ID 0//由于没有报错的错误,自己加入的define
xStatus = XGpio_Initialize(&GPIOInstance_Ptr,XPAR_AXI_GPIO_0_DEVICE_ID); if(XST_SUCCESS != xStatus) print("GPIO INIT FAILED\n\r"); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Step-2 :AXI GPIO Set the Direction //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XGpio_SetDataDirection(&GPIOInstance_Ptr, 1, 1);//input //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Step-3 :PS GPIO Intialization //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GpioConfigPtr = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID); if(GpioConfigPtr == NULL) return XST_FAILURE; xStatus = XGpioPs_CfgInitialize(&psGpioInstancePtr, GpioConfigPtr, GpioConfigPtr->BaseAddr); if(XST_SUCCESS != xStatus) print(" PS GPIO INIT FAILED \n\r"); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Step-4 :PS GPIO pin setting to Output //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XGpioPs_SetDirectionPin(&psGpioInstancePtr, iPinNumberld9,1); XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, iPinNumberld9,1); XGpioPs_SetDirectionPin(&psGpioInstancePtr, iPinNumberbtn8,0); XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, iPinNumberbtn8,1); XGpioPs_SetDirectionPin(&psGpioInstancePtr, iPinNumberbtn9,0); XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, iPinNumberbtn9,1); XGpioPs_SetDirectionPin(&psGpioInstancePtr, iPinNumberBTNU,0); XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, iPinNumberBTNU,1); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Step-5 :OLED Intialization //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OLED_Init(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Step-6 :press btn8 to start Demo //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OLED_ShowString(0,0, "BTN8 to start"); OLED_Refresh_Gram(); while (1){ start=XGpioPs_ReadPin(&psGpioInstancePtr, iPinNumberbtn8); if(start){ XGpioPs_WritePin(&psGpioInstancePtr,iPinNumberld9,1); print("###################### Demo Starts ########################\r\n"); OLED_ShowString(0,0, "DALE I LOVE U"); OLED_ShowString(0,16, "BTNR to go on"); OLED_Refresh_Gram(); break; } end=XGpioPs_ReadPin(&psGpioInstancePtr, iPinNumberbtn9); if(end){ XGpioPs_WritePin(&psGpioInstancePtr,iPinNumberld9,0); OLED_Clear(); break; } } while(1){ Readstatus1 = XGpio_DiscreteRead(&GPIOInstance_Ptr, 1) ;//读BTNR if(Readstatus1){ OLED_ShowString(0,0, "DO U LOVE ME ? "); OLED_ShowString(0,16, "BTNU to go on"); OLED_Refresh_Gram(); break; } } while(1){ Readstatus2 = XGpioPs_ReadPin(&psGpioInstancePtr, iPinNumberBTNU) ;//读BTNU if(Readstatus2){ OLED_Clear(); OLED_ShowString(0,0, "HAHA BYE"); OLED_ShowString(0,16, "BTN9 to end"); OLED_Refresh_Gram(); } end=XGpioPs_ReadPin(&psGpioInstancePtr, iPinNumberbtn9); if(end){ XGpioPs_WritePin(&psGpioInstancePtr,iPinNumberld9,0); OLED_Clear(); break; } } print("\r\n"); print("***********\r\n"); print("BYE \r\n"); print("***********\r\n"); cleanup_platform(); return 0; }

zedboard中OLED源码的更多相关文章

  1. 【原】Spark中Client源码分析(二)

    继续前一篇的内容.前一篇内容为: Spark中Client源码分析(一)http://www.cnblogs.com/yourarebest/p/5313006.html DriverClient中的 ...

  2. 【原】Spark中Master源码分析(二)

    继续上一篇的内容.上一篇的内容为: Spark中Master源码分析(一) http://www.cnblogs.com/yourarebest/p/5312965.html 4.receive方法, ...

  3. 【原】 Spark中Worker源码分析(二)

    继续前一篇的内容.前一篇内容为: Spark中Worker源码分析(一)http://www.cnblogs.com/yourarebest/p/5300202.html 4.receive方法, r ...

  4. Django缓存机制--rest_framework中节流源码使用的就是django提供的缓存api

    一.配置缓存   https://www.jb51.net/article/124434.htm 二.缓存全站.页面.局部   三.自我控制的简单缓存API API 接口为:django.core.c ...

  5. 深入理解 Node.js 中 EventEmitter源码分析(3.0.0版本)

    events模块对外提供了一个 EventEmitter 对象,即:events.EventEmitter. EventEmitter 是NodeJS的核心模块events中的类,用于对NodeJS中 ...

  6. php中foreach源码分析(编译原理)

    php中foreach源码分析(编译原理) 一.总结 编译原理(lex and yacc)的知识 二.php中foreach源码分析 foreach是PHP中很常用的一个用作数组循环的控制语句.因为它 ...

  7. vue打包时,assets目录 和static目录下文件的处理区别(nodeModule中插件源码修改后,打包后的文件应放在static目录)

    为了回答这个问题,我们首先需要了解Webpack如何处理静态资产.在 *.vue 组件中,所有模板和CSS都会被 vue-html-loader 及 css-loader 解析,并查找资源URL.例如 ...

  8. 从 sourcemap 中获取源码

    使用 paazmaya/shuji: Reverse engineering JavaScript and CSS sources from sourcemaps 可以从 sourcemap 中获取源 ...

  9. 手把手教你实现栈以及C#中Stack源码分析

    定义 栈又名堆栈,是一种操作受限的线性表,仅能在表尾进行插入和删除操作. 它的特点是先进后出,就好比我们往桶里面放盘子,放的时候都是从下往上一个一个放(入栈),取的时候只能从上往下一个一个取(出栈), ...

随机推荐

  1. (转)Objective-C语言--属性和实例变量

    本文转自http://blog.csdn.net/addychen/article/details/39525681 使用Objective-C一段时间了,一直没有弄清楚在Objective-C中属性 ...

  2. LeetCode(92) Reverse Linked List II

    题目 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1- ...

  3. Codeforces Round #439 (Div. 2) A. The Artful Expedient

    A. The Artful Expedient 题目链接http://codeforces.com/contest/869/problem/A 解题心得:就是一个水题,读懂题就好,题意是,(i,j)a ...

  4. Python中的socket网络编程(TCP/IP,UDP)讲解

    在网络编程中的一个基本组件就是套接字(socket).套接字基本上是两个端点的程序之间的"信息通道".程序可能分布在不同的计算机上,通过套接字互相发送信息.套接字包括两个:服务器套 ...

  5. RHEL6.5上升级OpenSSH7.4p1

    由于升级OpenSSH涉及到安全性问题,为保险起见,在升级前最好安装telnet服务作为备用方案,然后在升级成功后再停止telnet即可. 一.OpenSSH升级相关源码包下载地址 zlib  htt ...

  6. 2017 Multi-University Training Contest - Team 4

    日常绝望系列 Questionnaire HDU - 6075 In order to get better results in official ACM/ICPC contests, the te ...

  7. (绝对有用)iOS获取UUID,并使用keychain存储

    原文链接 http://blog.sina.com.cn/s/blog_5971cdd00102vqgy.html UDID被弃用,使用UUID来作为设备的唯一标识.获取到UUID后,如果用NSUse ...

  8. 【单调队列优化dp】HDU 3401 Trade

    http://acm.hdu.edu.cn/showproblem.php?pid=3401 [题意] 知道之后n天的股票买卖价格(api,bpi),以及每天股票买卖数量上限(asi,bsi),问他最 ...

  9. LightOJ1125 Divisible Group Sums

    Divisible Group Sums Given a list of N numbers you will be allowed to choose any M of them. So you c ...

  10. android开发里跳过的坑——camera调用setDisplayOrientation设置预览显示旋转无效

    问题原因,在surfaceview没有设置给camera之前调用了,所以,这个方法一定要在camera.setPreviewDisplay(surfaceHolder)这个之后,启动相机预览之前调用.