zedboard中OLED源码
#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源码的更多相关文章
- 【原】Spark中Client源码分析(二)
继续前一篇的内容.前一篇内容为: Spark中Client源码分析(一)http://www.cnblogs.com/yourarebest/p/5313006.html DriverClient中的 ...
- 【原】Spark中Master源码分析(二)
继续上一篇的内容.上一篇的内容为: Spark中Master源码分析(一) http://www.cnblogs.com/yourarebest/p/5312965.html 4.receive方法, ...
- 【原】 Spark中Worker源码分析(二)
继续前一篇的内容.前一篇内容为: Spark中Worker源码分析(一)http://www.cnblogs.com/yourarebest/p/5300202.html 4.receive方法, r ...
- Django缓存机制--rest_framework中节流源码使用的就是django提供的缓存api
一.配置缓存 https://www.jb51.net/article/124434.htm 二.缓存全站.页面.局部 三.自我控制的简单缓存API API 接口为:django.core.c ...
- 深入理解 Node.js 中 EventEmitter源码分析(3.0.0版本)
events模块对外提供了一个 EventEmitter 对象,即:events.EventEmitter. EventEmitter 是NodeJS的核心模块events中的类,用于对NodeJS中 ...
- php中foreach源码分析(编译原理)
php中foreach源码分析(编译原理) 一.总结 编译原理(lex and yacc)的知识 二.php中foreach源码分析 foreach是PHP中很常用的一个用作数组循环的控制语句.因为它 ...
- vue打包时,assets目录 和static目录下文件的处理区别(nodeModule中插件源码修改后,打包后的文件应放在static目录)
为了回答这个问题,我们首先需要了解Webpack如何处理静态资产.在 *.vue 组件中,所有模板和CSS都会被 vue-html-loader 及 css-loader 解析,并查找资源URL.例如 ...
- 从 sourcemap 中获取源码
使用 paazmaya/shuji: Reverse engineering JavaScript and CSS sources from sourcemaps 可以从 sourcemap 中获取源 ...
- 手把手教你实现栈以及C#中Stack源码分析
定义 栈又名堆栈,是一种操作受限的线性表,仅能在表尾进行插入和删除操作. 它的特点是先进后出,就好比我们往桶里面放盘子,放的时候都是从下往上一个一个放(入栈),取的时候只能从上往下一个一个取(出栈), ...
随机推荐
- solr DIH 设置定时索引
1 web.xml中加入 web.xml所在目录 /opt/solr-7.7.1/server/solr-webapp/webapp/WEB-INF <listener> <list ...
- PAT Basic 1037
1037 在霍格沃茨找零钱 如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 —— 就如海格告诉哈利的:“十七个银西可(Sickle)兑一个加隆(Galleon),二十九个纳特(Knut)兑一 ...
- 1 producer — n consumers 模型 实现
#include<stdio.h> #include<string.h> #include<pthread.h> #include<stdlib.h> ...
- java 协程框架quasar gradle配置
https://github.com/puniverse/quasar-gradle-template/blob/master/gradle/agent.gradle 1.将其中的"-jav ...
- [uiautomator篇][11]wifi
package com.softwinner.network.wifi; import android.content.Context; import android.content.Intent; ...
- Git升级迁移
1 原有机器进行升级和备份: https://about.gitlab.com/update/#centos-6 1. Make a backup (Optional) If you would li ...
- MHA 高可用集群搭建(二)
MHA 高可用集群搭建安装scp远程控制http://www.cnblogs.com/kevingrace/p/5662839.html yum install openssh-clients mys ...
- shell的until循环
until 循环执行一系列命令直至条件为 true 时停止.until 循环与 while 循环在处理方式上刚好相反.一般while循环优于until循环,但在某些时候,也只是极少数情况下,until ...
- 创建mavenweb项目
1.创建maven项目 2.创建maven-web项目 3.将webapp文件夹复制到maven项目下,src路径下
- kubernetes---CentOS7安装kubernetes1.11.2图文完整版
转载请注明出处:kubernetes-CentOS7安装kubernetes1.11.2图文完整版 架构规划 k8s至少需要一个master和一个node才能组成一个可用集群. 本章我们搭建一个mas ...