中级会员
- 积分
- 254
- 金钱
- 254
- 注册时间
- 2020-10-19
- 在线时间
- 54 小时
|
楼主 |
发表于 2024-3-25 13:42:56
|
显示全部楼层
- /include/ "system-conf.dtsi"
- / {
- model = "CHopes Linux ALINX Zynq Core Board";
- compatible = "xlnx,zynq-zc701","xlnx,zynq-7000";
- chosen{
- bootargs = "console=ttyPS0,115200 earlycon root=/dev/mmcblk0p2 rw rootwait";
- stdout-path = "serial0:115200n8";
- };
- led{
- compatible="zynq,led";
- status="okay";
- default-state="on";
- reg = <0xe000a040 0x4
- 0xe000a204 0x4
- 0xe000a208 0x4
- 0xe000a214 0x4
- 0xf800012c 0x4>;
- };
- };
复制代码
- #include <stdio.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc, char *argv[])
- {
- int fd, ret;
- unsigned char buf[1];
- if(3 != argc) {
- printf("Usage:\n"
- "\t./ledApp /dev/led 1 [url=home.php?mod=space&uid=95564]@[/url] close LED\n"
- "\t./ledApp /dev/led 0 @ open LED\n"
- );
- return -1;
- }
- /* 打开设备 */
- fd = open(argv[1], O_RDWR);
- if(0 > fd) {
- printf("file %s open failed!\r\n", argv[1]);
- return -1;
- }
- /* 将字符串转换为int型数据 */
- buf[0] = atoi(argv[2]);
- /* 向驱动写入数据 */
- ret = write(fd, buf, sizeof(buf));
- if(0 > ret){
- printf("LED Control Failed!\r\n");
- close(fd);
- return -1;
- }
- /* 关闭设备 */
- close(fd);
- return 0;
- }
复制代码 |
|