{"id":2691,"date":"2023-01-23T14:34:32","date_gmt":"2023-01-23T06:34:32","guid":{"rendered":"http:\/\/www.hellofpga.com\/?p=2691"},"modified":"2023-01-23T14:34:57","modified_gmt":"2023-01-23T06:34:57","slug":"smart-zynq_gpio_interrupt","status":"publish","type":"post","link":"http:\/\/www.hellofpga.com\/index.php\/2023\/01\/23\/smart-zynq_gpio_interrupt\/","title":{"rendered":"Smart ZYNQ\u677f \u5de5\u7a0b\u4e8c\u5341\u00a0 \u57fa\u4e8ePS\u7aef\u7684 \u5916\u90e8\u4e2d\u65ad\u6d4b\u8bd5"},"content":{"rendered":"\n<p>\u524d\u4e00\u8282\u7684\u6309\u952e\u7684\u4ee3\u7801\uff0c\u662f\u5728\u4e3b\u7a0b\u5e8f\u4e2d\u4e0d\u505c\u7684\u8f6e\u56de\u53bb\u626b\u63cfIO\u7684\u72b6\u6001\u6765\u8fbe\u5230\u6309\u952e\u68c0\u6d4b\u7684\u76ee\u7684\uff0c\u5bf9\u4e8e\u5c0f\u578b\u7684\u7cfb\u7edf\u6765\u8bf4\u6ca1\u4ec0\u4e48\u95ee\u9898\uff0c\u4f46\u662f\u5bf9\u4e8e\u5927\u578b\u590d\u6742\u7684\u7cfb\u7edf\u7a0b\u5e8f\u6765\u8bf4\uff0c\u5982\u679cmain\u7684\u4e3b\u5faa\u73af\u4e2d\u8981\u5904\u7406\u5f88\u591a\u4e8b\u52a1\uff0c\u5bf9\u4e8eIO\u7684\u68c0\u6d4b\u6216\u8005\u8bf4\u5bf9\u4e8e\u5916\u90e8\u4e8b\u4ef6\u7684\u89e6\u53d1\u5c31\u4e0d\u80fd\u53ca\u65f6\u7684\u8fdb\u884c\u54cd\u5e94\u4e86\uff0c\u5e76\u4e14\u6309\u952e\u5faa\u73af\u672c\u8eab\u4e5f\u5360\u7528\u4e86\u7cfb\u7edf\u8d44\u6e90\uff0c\u8fd9\u4e2a\u65f6\u5019\u5916\u90e8\u4e2d\u65ad\u7684\u91cd\u8981\u6027\u5c31\u51f8\u663e\u51fa\u6765\u4e86\u3002<\/p>\n\n\n\n<p>\u5916\u90e8\u4e2d\u65ad\u53ef\u4ee5\u8ba9MCU\u5b9e\u65f6\u5730\u5904\u7406\u5916\u90e8\u4e8b\u4ef6\uff0c\u5f53\u5916\u90e8\u4e8b\u4ef6\u53d1\u751f\u65f6\uff0c\u7cfb\u7edf\u7684\u4e2d\u65ad\u673a\u5236\u5c06\u8feb\u4f7fCPU\u6682\u505c\u6b63\u5728\u6267\u884c\u7684\u7a0b\u5e8f\uff0c\u8f6c\u800c\u53bb\u8fdb\u884c\u4e2d\u65ad\u4e8b\u4ef6\u7684\u5904\u7406\uff1b\u4e2d\u65ad\u5904\u7406\u5b8c\u6bd5\u540e\uff0e\u53c8\u8fd4\u56de\u88ab\u4e2d\u65ad\u7684\u7a0b\u5e8f\u5904\uff0c\u7ee7\u7eed\u6267\u884c\u4e0b\u53bb\u3002<\/p>\n\n\n\n<p>\u672c\u6587\u5728 vivado2018.3\u7248\u672c\u4e0a \u6f14\u793a\uff0c \u5176\u4ed6\u7248\u672c\u8bf7\u81ea\u884c\u7814\u7a76<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u786c\u4ef6\u4ecb\u7ecd<\/h2>\n\n\n\n<p>\u672c\u5b9e\u9a8c\u4ecd\u7136\u91c7\u7528\u6309\u952e\u70b9\u706f\u7684\u65b9\u5f0f\u8fdb\u884c \u5916\u90e8\u4e2d\u65ad\u7684\u6f14\u793a\uff0c\u8ba9\u6309\u952e\u53bb\u89e6\u53d1\u5916\u90e8\u4e2d\u65ad\u7684\u529f\u80fd\uff0c\u5e76\u4e14\u5728\u4e2d\u65ad\u51fd\u6570\u4e2d\u589e\u52a0\u6539\u53d8\u706f\u72b6\u6001\u7684\u547d\u4ee4\u3002<\/p>\n\n\n\n<p>\u7531\u539f\u7406\u56fe\u53ef\u4ee5\u770b\u51fa\u677f\u5b50\u4e0a\u63a5\u4e86\u4e24\u4e2a\u6309\u952e\uff0c\u5e76\u4e14\u9ed8\u8ba4\u662f\u901a\u8fc7\u4e0a\u62c9\u7535\u963b\u4e0a\u62c9\u52303.3V\u7684\uff0c\u4e5f\u5c31\u662f\u5f53\u6309\u952e\u6ca1\u6709\u6309\u4e0b\u7684\u65f6\u5019 \u6309\u952eKEY \u7684\u4fe1\u53f7\u811a\u662f3.3V \uff0c\u5f53\u6309\u952e\u6309\u4e0b\u540e\uff0c\u8be5\u4fe1\u53f7\u811a\u88ab\u62c9\u4f4e\u5230GND\u4e5f\u5c31\u662f0V \u540c\u6837\u4e5f\u80fd\u770b\u51fa \u4e24\u4e2a\u6309\u952e\u5206\u522b\u8fde\u63a5\u5230\u4e86 FPGA\u82af\u7247\u7684 G17\u548cG18\u7ba1\u811a\u4e0a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"838\" height=\"554\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95.png\" alt=\"\" class=\"wp-image-2681\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95.png 838w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95-300x198.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-95-768x508.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u4e3a\u4e86\u6f14\u793a\u4e24\u4e2a\u6309\u952e\u7684\u529f\u80fd\uff0c\u8fd9\u91cc\u518d\u5f15\u5165\u4e24\u4e2a\u6307\u793a\u706f\uff0c\u5c06LED\u7684\u9a71\u52a8\u811a\u62c9\u9ad8\uff0c\u6307\u793a\u706f\u4eae\uff0c\u62c9\u4f4e\u6307\u793a\u706f\u7184\u706d\uff0c\u6307\u793a\u706f\u5206\u522b\u63a5\u5728\u4e3b\u82af\u7247\u7684 K16\u548cJ16\u811a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"549\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96.png\" alt=\"\" class=\"wp-image-2682\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96.png 550w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96-300x300.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96-150x150.png 150w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-96-100x100.png 100w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5de5\u7a0b\u521b\u5efa<\/h2>\n\n\n\n<p>\u5de5\u7a0b\u51e0\u4e4e\u548c\u4e0a\u4e00\u4e2a\u5b9e\u9a8c\u5b8c\u5168\u4e00\u81f4\uff0c\u4ec5\u7b80\u5355\u4ecb\u7ecd\u3002<\/p>\n\n\n\n<p>\u5b8c\u6574\u7684\u5de5\u7a0b\u521b\u5efa\u56fe\u6587\u6559\u7a0b\u524d\u9762\u5df2\u7ecf\u8be6\u7ec6\u56fe\u6587\u63cf\u5199\u4e86\uff0c\u53ef\u4ee5\u53c2\u8003\u524d\u9762\u7684\u5de5\u7a0b\uff0c\u8fd9\u91cc\u4ec5\u4ec5\u589e\u52a0\u5173\u952e\u6b65\u9aa4\u3002 \u8be6\u7ec6\u8fc7\u7a0b\u53ef\u4ee5\u53c2\u8003<a rel=\"noreferrer noopener\" href=\"http:\/\/www.hellofpga.com\/index.php\/2023\/01\/18\/smart-zynq_emil_test\/\" target=\"_blank\">Smart ZYNQ\u677f \u5de5\u7a0b\u4e03 \u7528ZYNQ\u7684PS\u70b9\u4eae\u8fde\u63a5\u5230PL\u7aef\u7684LED\u706fEMIO \u65b9\u5f0f<\/a><\/p>\n\n\n\n<p>\u5668\u4ef6\u540d\u79f0\u9009\u62e9 xc7z010clg400-1 \u6216 xc7z020clg400-1\uff08xa7z020\uff09 \u4ee5\u5b9e\u9645\u677f\u5b50\u4e0a\u7684\u82af\u7247\u4e3a\u51c6<\/p>\n\n\n\n<p>\u5728BLOCK DESIGN \u4e2d\u6dfb\u52a0\u4e00\u4e2aZYNQ\u6a21\u5757<\/p>\n\n\n\n<p>\u5728ZYNQ \u8bbe\u7f6e\u754c\u9762\uff0c\u8bbe\u7f6e DDR MT41K256M16RE-125\u7684\u578b\u53f7 \u548c\u4f4d\u5bbd16bit<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"442\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92.png\" alt=\"\" class=\"wp-image-2668\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92-300x173.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u6dfb\u52a04\u4e2aEMIO \uff0c\u5176\u4e2d\u4e24\u4e2a\u7528\u6765\u9a71\u52a8LED\u706f\uff0c\u53e6\u4e24\u4e2a\u7528\u6765\u8bfb\u53d6\u6309\u952eKEY\u7684\u4fe1\u606f<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"292\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-19.png\" alt=\"\" class=\"wp-image-1509\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-19.png 699w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-19-300x125.png 300w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/figure>\n\n\n\n<p>\u5bf9GPIO make external\uff0c\u5e76\u4e14\u8fde\u63a5AXI\u7684\u65f6\u949f\uff08AXI\u9ed8\u8ba4\u5f00\u542f\u7684\uff0c\u8fd9\u91cc\u7528\u4e0d\u5230AXI\uff0c\u4e5f\u53ef\u4ee5\u53bb\u8bbe\u7f6e\u91cc\u5173\u95edAXI\u529f\u80fd\uff0c\u5c31\u4e0d\u9700\u8981\u8fde\u63a5\u4e86\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"606\" height=\"267\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21.png\" alt=\"\" class=\"wp-image-1512\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21.png 606w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21-300x132.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/figure>\n\n\n\n<p>\u4e4b\u540e \u70b9\u9009Create HDL Wrapper<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"397\" height=\"165\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22.png\" alt=\"\" class=\"wp-image-1513\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22.png 397w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22-300x125.png 300w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/figure>\n\n\n\n<p>\u4e4b\u540e\u521b\u5efa\u548c\u6dfb\u52a0\u7ea6\u675f\u6587\u4ef6\uff1a<\/p>\n\n\n\n<p>\u53ef\u4ee5\u5728\u56fe\u6587\u754c\u9762\u91cc\u8bbe\u7f6e\u7ba1\u811a\u5b9a\u4e49<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"566\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-98.png\" alt=\"\" class=\"wp-image-2693\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-98.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-98-300x166.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-98-768x425.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u5728\u7ea6\u675f\u6587\u4ef6\u91cc\u6dfb\u52a0\u7ba1\u811a\u5b9a\u4e49\u7684\u63cf\u8ff0<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">set_property PACKAGE_PIN K16 [get_ports {GPIO_0_0_tri_io[3]}]\nset_property PACKAGE_PIN J16 [get_ports {GPIO_0_0_tri_io[2]}]\nset_property PACKAGE_PIN G18 [get_ports {GPIO_0_0_tri_io[1]}]\nset_property PACKAGE_PIN G17 [get_ports {GPIO_0_0_tri_io[0]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[3]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[2]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[1]}]\nset_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[0]}]<\/pre>\n\n\n\n<p>\u4e4b\u540e\u5bf9\u7a0b\u5e8f\u8fdb\u884c\u6b63\u5e38\u7684\u7f16\u8bd1\u7efc\u5408\uff0c\u5e76\u4e14\u5bfc\u51fa Export Hardware (\u52fe\u9009 include bitstream)\u4f9bSDK\u52a0\u8f7d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"460\" height=\"92\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24.png\" alt=\"\" class=\"wp-image-1515\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24.png 460w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24-300x60.png 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"318\" height=\"239\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25.png\" alt=\"\" class=\"wp-image-1516\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25.png 318w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25-300x225.png 300w\" sizes=\"auto, (max-width: 318px) 100vw, 318px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u7a0b\u5e8f\u8bbe\u8ba1\uff1a<\/h2>\n\n\n\n<p>\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3aGPIO_INTERRUPT\u7a7a\u7684\u5de5\u7a0b\uff0c\u5e76\u4e14\u6dfb\u52a0main.c \u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include \"xparameters.h\"\n#include \"xgpiops.h\"\n#include \"xscugic.h\"\n#include \"xil_exception.h\"\n#include \"xplatform_info.h\"\n#include &lt;xil_printf.h&gt;\n\n#define LED2    \t57\n#define LED1    \t56\n#define KEY2    \t55\n#define KEY1    \t54\n\n#define GPIO_DEVICE_ID  \tXPAR_XGPIOPS_0_DEVICE_ID\nXGpioPs Gpio;\n#define GPIO_BANK\tXGPIOPS_BANK0  \/* Bank 0 of the GPIO Device *\/\n\n#define GPIO_DEVICE_ID\t\tXPAR_XGPIOPS_0_DEVICE_ID\n#define INTC_DEVICE_ID\t\tXPAR_SCUGIC_SINGLE_DEVICE_ID\n#define GPIO_INTERRUPT_ID\tXPAR_XGPIOPS_0_INTR\n\nstatic XScuGic Intc; \/* The Instance of the Interrupt Controller Driver *\/\n\n\nstatic void IntrHandler(void *CallBackRef, u32 Bank, u32 Status)\n{\n\tXGpioPs *Gpio_cb = (XGpioPs *)CallBackRef;\n\tif (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY1)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 1);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 0);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY1);\n\t}\n\telse if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY2)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 0);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 1);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY2);\n\t}\n}\n\n\n\nvoid SetupInterruptSystem(XScuGic *GicInstancePtr, XGpioPs *Gpio,\n\t\t\t\tu16 GpioIntrId){\n\n\tXScuGic_Config *IntcConfig;\n\tXil_ExceptionInit();\n\n\tIntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);\n\n\tXScuGic_CfgInitialize(GicInstancePtr, IntcConfig,\n\t\t\t\t\tIntcConfig-&gt;CpuBaseAddress);\n\n\tXil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,\n\t\t\t\t(Xil_ExceptionHandler)XScuGic_InterruptHandler,\n\t\t\t\tGicInstancePtr);\n\tXScuGic_Connect(GicInstancePtr, GpioIntrId,\n\t\t\t\t(Xil_ExceptionHandler)IntrHandler,\n\t\t\t\t(void *)Gpio);\n\n\n\tXScuGic_Enable(GicInstancePtr, GpioIntrId);\n\n\tXGpioPs_SetIntrTypePin(Gpio, KEY1,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);\n\tXGpioPs_SetIntrTypePin(Gpio, KEY2,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);\n\t\n\tXGpioPs_IntrEnablePin(Gpio, KEY1);\n\tXGpioPs_IntrEnablePin(Gpio, KEY2);\n\n\tXil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);\n}\n\n\nvoid Gpio_Init(void){\n\tXGpioPs_Config *ConfigPtr;\n\n\tConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);\n\tXGpioPs_CfgInitialize(&amp;Gpio, ConfigPtr,ConfigPtr-&gt;BaseAddr);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, LED1, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, LED1, 1);\n\tXGpioPs_WritePin(&amp;Gpio, LED1, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, LED2, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, LED2, 1);\n\tXGpioPs_WritePin(&amp;Gpio, LED2, 1);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, KEY1, 0);\n\tXGpioPs_SetDirectionPin(&amp;Gpio, KEY2, 0);\n\n\tSetupInterruptSystem(&amp;Intc, &amp;Gpio, GPIO_INTERRUPT_ID);\n}\n\n\n\n\nint main(void)\n{\n\tGpio_Init();\n\n\twhile(1){\n\n\t}\n\n\treturn 0;\n}\n<\/pre>\n\n\n\n<p>\u7a0b\u5e8f\u5f88\u7b80\u5355\uff0c Gpio_Init\u662f\u5bf94\u4e2aGPIO\u8fdb\u884c\u521d\u59cb\u5316\uff0c \u56e0\u4e3aEMIO \u662f\u4ece54\u7684\u7ba1\u811a\u53f7\u5f00\u59cb\u7684\uff0c\u6240\u4ee5\u6839\u636e\u539f\u5148VIVADO \u7684\u7ba1\u811a\u7ea6\u675f\u6765\u770b\uff0c\u4e24\u4e2a\u6309\u952e\u5e94\u8be5\u5bf9\u5e9454\u548c55\uff0c\u4e24\u4e2aLED\u706f\u5bf9\u5e9456\u548c57<\/p>\n\n\n\n<p>SetupInterruptSystem(&amp;Intc, &amp;Gpio, GPIO_INTERRUPT_ID); \u662f\u5bf9\u4e2d\u65ad\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u8fd9\u91cc\u6211\u4eec\u5206\u522b\u5bf9KEY1\u548cKEY2\u90fd\u589e\u52a0\u4e86\u4e2d\u65ad\u521d\u59cb\u5316\uff0c\u8fd9\u4e24\u4e24\u4e2a\u6309\u952e\u4e2d\u4efb\u4f55\u4e00\u4e2a\u6309\u952e\u88ab\u6309\u4e0b \u90fd\u4f1a\u8c03\u7528\u4e2d\u65adXGpioPs_SetIntrTypePin(Gpio, KEY1, XGPIOPS_IRQ_TYPE_EDGE_FALLING);\u4ee3\u8868\u5bf9KEY1\u8bbe\u7f6e\u4e0b\u964d\u6cbf\u4e2d\u65ad\u3002<\/p>\n\n\n\n<p>IntrHandler \u662f\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\uff0c\u5728\u4e2d\u65ad\u4e8b\u4ef6\u4ea7\u751f\u540e\u5bf9\u4e2d\u65ad\u8fdb\u884c\u54cd\u5e94\uff0c\u4e00\u822c\u6211\u4eec\u4e2d\u65ad\u540e\u9700\u8981\u7684\u52a8\u4f5c\u4ee3\u7801\u90fd\u653e\u5728\u8fd9\u4e2a\u51fd\u6570\u91cc\u9762\u3002 \uff08\u56e0\u4e3a\u6211\u4eec\u540c\u65f6\u589e\u52a0\u4e86\u4e24\u4e2a\u5916\u90e8\u4e2d\u65ad\uff0c\u6240\u4ee5\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u8fdb\u6765\u7b2c\u4e00\u4ef6\u4e8b\u662f\u533a\u5206\u54ea\u4e2aGPIO\u4ea7\u751f\u4e86\u4e2d\u65ad\uff0c\u6240\u4ee5\u8fd9\u91cc\u7528XGpioPs_IntrGetStatusPin\u547d\u4ee4\u53bb\u8bfb\u53d6CallBackRef\u7684\u503c\uff0c\u6765\u5224\u65ad\u54ea\u4e2a\u6309\u952e\u4ea7\u751f\u4e86\u4e2d\u65ad\uff0c\u5e76\u6839\u636e\u7ed3\u679c\u70b9\u4eae\u4e0d\u540c\u7684LED\u706f\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">static void IntrHandler(void *CallBackRef, u32 Bank, u32 Status)\n{\n\tXGpioPs *Gpio_cb = (XGpioPs *)CallBackRef;\n\tif (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY1)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 1);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 0);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY1);\n\t}\n\telse if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY2)){\n\t\tXGpioPs_WritePin(&amp;Gpio, LED1, 0);\n\t\tXGpioPs_WritePin(&amp;Gpio, LED2, 1);\n\t\tXGpioPs_IntrClearPin(Gpio_cb, KEY2);\n\t}\n}\n<\/pre>\n\n\n\n<p>\u5bf9\u4e8e\u4e3b\u51fd\u6570main\u51fd\u6570\u6765\u8bf4\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5b8c\u6210GPIO\u521d\u59cb\u5316\uff08\u91cc\u9762\u5305\u62ec\u4e2d\u65ad\u521d\u59cb\u5316\uff09\uff0c\u4e4b\u540e\u5c31\u76f4\u63a5\u4e0d\u4f5c\u4efb\u4f55\u64cd\u4f5c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int main(void)\n{\n\tGpio_Init();\n\twhile(1){\n\n\t}\n\n\treturn 0;\n}<\/pre>\n\n\n\n<p>\u6211\u4eec\u5c06\u7a0b\u5e8f\u4e0b\u8f7d\u8fdb\u677f\u5b50\u8fdb\u884cDEBUG\uff0c\u53d1\u73b0\u4e24\u4e2a\u6309\u952e\u4efb\u610f\u4e00\u4e2a\u88ab\u6309\u4e0b\u5bf9\u5e94\u7684\u706f\u88ab\u70b9\u4eae\uff0c\u8bc1\u660e\u6211\u4eec\u7684\u5916\u90e8\u4e2d\u65ad\u5df2\u6210\u529f\u8fd0\u884c\uff08\u56e0\u4e3a\u4e3b\u7a0b\u5e8f\u4e2d\u5e76\u4e0d\u8d1f\u8d23\u70b9\u706f\uff0c\u53ea\u6709\u5728\u4e2d\u65ad\u4e2d\u624d\u8d1f\u8d23\u6539\u53d8\u706f\u7684\u72b6\u6001\uff09<\/p>\n\n\n\n<p>\u4e2d\u65ad\u6bd4\u8f83\u7b80\u5355\uff0c\u4f46\u662f\u5bf9\u5e94\u7cfb\u7edf\u6027\u7684\u7a0b\u5e8f\u8bbe\u8ba1\u6765\u8bf4\u53c8\u5fc5\u4e0d\u53ef\u5c11\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u5b8c\u6574\u4ee3\u7801\uff08\u4ec5\u4f9b\u53c2\u8003\uff09\uff1a<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-d5590ebf-2331-4b3e-b744-505179f16fdb\" href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/20_PS_GPIO_INTERRUPT_XC7Z010_1.zip\">20_PS_GPIO_INTERRUPT_XC7Z010_1<\/a><a href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/20_PS_GPIO_INTERRUPT_XC7Z010_1.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-d5590ebf-2331-4b3e-b744-505179f16fdb\">\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-b5dc9ea2-2e39-45eb-9fcf-199d0360b2c0\" href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/20_PS_GPIO_INTERRUPT_XC7Z020_1.zip\">20_PS_GPIO_INTERRUPT_XC7Z020_1<\/a><a href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/20_PS_GPIO_INTERRUPT_XC7Z020_1.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-b5dc9ea2-2e39-45eb-9fcf-199d0360b2c0\">\u4e0b\u8f7d<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u5b9e\u9a8c\u4ecd\u7136\u91c7\u7528\u6309\u952e\u70b9\u706f\u7684\u65b9\u5f0f\u8fdb\u884c \u5916\u90e8\u4e2d\u65ad\u7684\u6f14\u793a\uff0c\u8ba9\u6309\u952e\u53bb\u89e6\u53d1\u5916\u90e8\u4e2d\u65ad\u7684\u529f\u80fd\uff0c\u5e76\u4e14\u5728\u4e2d\u65ad\u51fd\u6570\u4e2d\u589e\u52a0\u6539\u53d8\u706f\u72b6\u6001\u7684\u547d<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-2691","post","type-post","status-publish","format-standard","hentry","category-smart-zynq-board"],"views":633,"_links":{"self":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/2691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/comments?post=2691"}],"version-history":[{"count":2,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/2691\/revisions"}],"predecessor-version":[{"id":2698,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/2691\/revisions\/2698"}],"wp:attachment":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/media?parent=2691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/categories?post=2691"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/tags?post=2691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}