Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- UNIX
- FPGA
- Vivado
- amba
- verilog
- 정처기
- Zynq
- axi
- vitis
- AMBA BUS
- C++
- Beakjoon
- linux
- boj
- Bus
- Xilinx
- chip2chip
- Backjoon
- 자격증
- baekjoon
- hdl
- SQL
- 정보처리기사
- java
- 리눅스
- 백준
- verilog HDL
- 코딩테스트
- HDLBits
- 실기
Archives
- Today
- Total
Hueestory
07 PS MIO 본문
Vitis C Code
#include <stdio.h>
#include "xgpiops.h"
#include "platform.h"
int main()
{
static XGpioPs psGpioInstancePtr;
XGpioPs_Config * GpioConfigPtr;
int xStatus;
int BtnPinDirection = 0, BtnPinNumber = 50;
int LedPinDirection = 1, LedPinNumber = 7;
int Readstatus = 0, OldReadstatus = 0;
init_platform();
print("Hello World\n\r");
// step 1 : PS GPIO Initialization //
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 2-1 : Push Button Input //
XGpioPs_SetDirectionPin(&psGpioInstancePtr, BtnPinNumber, BtnPinDirection);
XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, BtnPinNumber, 0);
// step 2-2 : LED Output //
XGpioPs_SetDirectionPin(&psGpioInstancePtr, LedPinNumber, LedPinDirection);
XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, LedPinNumber, 1);
xStatus = 0;
while(1)
{
Readstatus = XGpioPs_ReadPin(&psGpioInstancePtr, BtnPinNumber);
if( (Readstatus == 1) && (OldReadstatus == 0))
{
print("BTN8(PB1-MI050) PUSH Button pressed \n\r");
if(xStatus == 1)
{
xStatus = 0;
XGpioPs_WritePin(&psGpioInstancePtr, LedPinNumber, 0);
print("LED(LD9) is OFF\r\n");
}else
{
xStatus = 1;
XGpioPs_WritePin(&psGpioInstancePtr, LedPinNumber, 1);
print("LED(LD9) is ON\r\n");
}
}
OldReadstatus = Readstatus;
}
print("\r\n");
print("***********\r\n");
print("BYE \r\n");
print("***********\r\n");
cleanup_platform();
return 0;
}
'FPGA(중단) > zynq' 카테고리의 다른 글
09 LED toggle (0) | 2023.03.22 |
---|---|
08 PL with AXI (0) | 2023.03.14 |
06 BRAM tutorial (0) | 2023.02.18 |
05 Keypad tutorial (0) | 2023.02.18 |
04 VGA tutorial (0) | 2023.02.18 |
Comments