dev.c

来自「⑴ 提供简单命令 A、通过串口加载程序到指定内存 B、将程序烧写到 NA」· C语言 代码 · 共 55 行

C
55
字号
/*这个文件负责把建立设备树*/


#include "struct.h"
#include "uart.h"
static d_dev * dev_head;



void add_dev_tree(d_dev *p)            /*添加设备到设备树中*/
{if(p->parent)
{p->brother=p->parent->child;
p->parent->child=p;
}else{
      
p->brother=dev_head;
dev_head=p;
}
}


static void dev_visit(d_dev * tail)   //递归算法//
{d_dev *p;
if(tail!=NULL)
{p=tail->parent;
uart_send(tail->name);
while(p)
{
uart_send("--");
uart_send(p->name);
p=p->parent;
}
uart_send("\r\n");
dev_visit(tail->child);

dev_visit(tail->brother);
}
}


void ls_dev_tree(int argc, char ** argv)                     /*遍历设备树*/
{d_dev *tail;
tail=dev_head;
dev_visit(tail);
}





void init_dev_tree()
{dev_head=NULL;
}
                

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?