圈圈.第3章.__UseMouse_流程.html

1、

2、

<!DOCTYPE html>

<html>

<svg width="3000" height="5000" viewBox="0 0 3000 5000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:cge="http://iec.ch/TC57/2005/SVG-schema#" xmlns:hzsvg="http://holleygrid.cn/svg">

    <style type="text/css">
    <![CDATA[
    <!--
    -->
    ]]>
    </style>

<script type="text/javascript">
<![CDATA[
<!--

    // ZC: 起点 的坐标
    var g_iX_Begin = 10;
    var g_iY_Begin = 10;

    // ZC: 每次 X/Y轴的缩进偏移数据
    var g_iOffsetX = 50;
    var g_iOffsetY = 20;

    // ZC: 每个创建的<text/>的Y坐标
    var g_iY_Create = 0;

    // ***

    var g_eleSvg = null;
    var g_strNS = null;

    // ZC: 每个创建的 <text/>对象(指针)保存
    var g_treeNode_Create = null;
    // ZC: <text/>是否需要绘制背景色
    var g_bTextBackground = false;

    window.onload = function()
    {
        g_eleSvg = document.getElementsByTagName("svg")[0];
        g_strNS = g_eleSvg.getAttribute("xmlns");

        g_iY_Create = g_iX_Begin;

        var treeNode_parent = null;
        var treeNode_parent1 = null;
        var treeNode_parent2 = null;
        var treeNode_parent3 = null;
        var treeNode_parent4 = null;
        var treeNode_parent5 = null;
        var treeNode_parent6 = null;
        var treeNode_parent7 = null;
        var treeNode_parent8 = null;
        var treeNode_parent9 = null;
        var treeNode_parent10 = null;


        TextNew(null, "[ 函数D12WriteCommand( uint8 Command ) 和 函数D12WriteByte( uint8 Value ) ] ", "[ 都是 执行6个宏操作,后5个宏一样,只有第1个宏不同 ] ", "[ 前者为D12SetCommandAddr_m( void ), 后者为D12SetDataAddr_m( void ) ]");

        TextNew(null, "", "", "");
        TextNew(null, "", "", "");
        TextNew(null, "", "", "");

        TextNew(null, "[ EA(0xAF) = 1; ] ", "[ 打开中断 (0=Disable all interrupts) ] ", "[ AT89X52.h ]");
        TextNew(null, "InitKeyboard( void ): void ", "[ 初始化按键,各种赋值 ] ", "");    treeNode_parent = g_treeNode_Create;
            TextNew(treeNode_parent, "[ P1 = 0xFF; ] ", "[ 键盘对应的口设置为输入状态 ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "InitTimer0( void ): void ", "[ 定时器0初始化,用来做键盘扫描 ] ", "");    treeNode_parent1 = g_treeNode_Create;
                TextNew(treeNode_parent1, "[ TMOD(0x89) &= 0xF0; ] ", "[  ] ", "[ AT89X52.h ]");
                TextNew(treeNode_parent1, "[ TMOD(0x89) |= 0x01; ] ", "[  ] ", "[ AT89X52.h ]");
                TextNew(treeNode_parent1, "[ ET0(0xA9) = 1; ] ", "[ 1=Enable Timer 0 interrupt ] ", "[ AT89X52.h ]");
                TextNew(treeNode_parent1, "[ TR0(0x8C) = 1; ] ", "[  ] ", "[ AT89X52.h ]");

        TextNew(null, "", "", "");
        TextNew(null, "InitUART( void ): void ", "[ 初始化串口,各种赋值 ] ", "");    treeNode_parent = g_treeNode_Create;
            TextNew(treeNode_parent, "[ EA(0xAF) = 0; ] ", "[ 暂时关闭中断 (0=Disable all interrupts) ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ TMOD(0x89) &= 0x0F; ] ", "[ 定时器1模式控制在高4位 ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ TMOD(0x89) |= 0x20; ] ", "[ 定时器1工作在模式2,自动重装模式 ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ SCON(0x98) = 0x50; ] ", "[ 串口工作在模式1 ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ TH1(0x8D) = 256-Fclk/(BitRate*12*16); ] ", "[ 计算定时器重装值 ] ", "[ AT89X52.h ]");    treeNode_parent1 = g_treeNode_Create;
                TextNew(treeNode_parent1, "[ #define Fclk 22118400UL ] ", "[ 使用22.1184M晶体 ] ", "[  ]");
                TextNew(treeNode_parent1, "[ #define BitRate 9600UL ] ", "[ 波特率定义为9600 ] ", "[  ]");
            TextNew(treeNode_parent, "[ TL1(0x8B) = 256-Fclk/(BitRate*12*16); ] ", "[  ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ PCON(0x87) = 0x80; ] ", "[ 串口波特率加倍 ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ ES(0xAC) = 1; ] ", "[ 串行中断允许 (1=Enable Serial port interrupt) ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ TR1(0x8E) = 1; ] ", "[ 启动定时器1 ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ REN(0x9C) = 1; ] ", "[ 允许接收 ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "[ EA(0xAF) = 1; ] ", "[ 允许中断 ] ", "[ AT89X52.h ]");

        TextNew(null, "", "", "");
        TextNew(null, "D12ReadID( void ): uint16 ", "[ 返回uint16 ] ", "");                    treeNode_parent = g_treeNode_Create;
            TextNew(treeNode_parent, "D12WriteCommand( <uint8>READ_ID[0xFD] ): void ", "[ 写读ID命令 ] ", "[ 6个宏操作. 入口参数:Command: 一字节命令. ] ");        treeNode_parent1 = g_treeNode_Create;
                // 宏(A-1)
                TextNew(treeNode_parent1, "D12SetCommandAddr_m( void[宏] ): void ", "[ 设置为命令地址 ]", "[ pdiusbd12.h ]");        treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_A0(P3_5{0xB5})=D12_COMMAND_ADD(1) ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
                // 宏(A-2)
                TextNew(treeNode_parent1, "D12ClrWr_m( void [宏] ): void ", "[ WR置低 ]", "");            treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_WR(P3_6{0xB6})=0 ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
                // 宏(A-3)
                TextNew(treeNode_parent1, "D12SetPortOut_m( void [空宏] ) ", "[ 将数据口设置为输出状态 ]", "");
                // 宏(A-4)
                TextNew(treeNode_parent1, "D12SetData_m( Command [宏] ): void ", "[ 输出命令到数据口上 ]", "");    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_DATA(P0{0x80})=(Value) ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
                // 宏(A-5)
                TextNew(treeNode_parent1, "D12SetWr_m( void [宏] ): void ", "[ WR置高 ]", "");        treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_WR(P3_6{0xB6})=1 ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
                // 宏(A-6)
                TextNew(treeNode_parent1, "D12SetPortIn_m( void [宏] ): void ", "[ 将数据口设置为输入状态,以备后面输入使用(ZC: 比如 写入 命令后面带的参数) ]", "");    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_DATA(P0{0x80})=0xFF ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");

            TextNew(null, "", "", "");
            TextNew(treeNode_parent, "D12ReadByte( void ): uint8 ", "[ 读回ID号低字节 ] ", "[ 4个宏,返回uint8 ]");        treeNode_parent = g_treeNode_Create;
                // 宏(B-1)
                TextNew(treeNode_parent1, "D12SetDataAddr_m( void[宏] ): void ", "[ 设置为数据地址 ]", "");        treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_A0(P3_5{0xB5})=D12_DATA_ADD(0) ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
                // 宏(B-2)
                TextNew(treeNode_parent1, "D12ClrRd_m( void[宏] ): void ", "[ RD置低 ]", "");        treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_RD(P3_7{0xB7})=0 ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
                // 宏(B-3)
                TextNew(treeNode_parent1, "D12GetData_m( void[宏] ): uint8 ", "[ 读回数据,返回uint8 ]", "");        treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_DATA(P0{0x80}) ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
                // 宏(B-4)
                TextNew(treeNode_parent1, "D12SetRd_m( void[宏] ): void ", "[ RD置高 ]", "");        treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ D12_RD(P3_7{0xB7})=1 ] ", "[ pdiusbd12.h ] ", "[ AT89X52.h ]");
            TextNew(treeNode_parent, "D12ReadByte( void ): uint8 ", "[ 读回ID号高字节 ] ", "[ 4个宏,返回uint8 ]", "");

        TextNew(null, "", "", "");
        TextNew(null, "UsbDisconnect( void ): void ", "[ 断开USB连接 ]", "");                treeNode_parent = g_treeNode_Create;
            TextNew(treeNode_parent, "D12WriteCommand( <uint8>D12_SET_MODE(0xF3) ): void ", "[ 写设置模式命令 ] ", "[ pdiusbd12.h ]");
            TextNew(treeNode_parent, "D12WriteByte( <uint8>0x06 ): void ", "[ 设置模式的第一字节 ] ", "[ 6个宏. 传参:uint8 Value(要写的一字节数据) ]");    treeNode_parent1 = g_treeNode_Create;
                // 宏(C-1)
                TextNew(treeNode_parent1, "D12SetDataAddr_m( void[宏] ): void ", "[ 设置为数据地址 ]", "");
                // 宏(C-2)
                TextNew(treeNode_parent1, "D12ClrWr_m( void[宏] ): void ", "[ WR置低 ]", "");
                // 宏(C-3)
                TextNew(treeNode_parent1, "D12SetPortOut_m( void[空宏] ) ", "[ 将数据口设置为输出状态 ]", "");
                // 宏(C-4)
                TextNew(treeNode_parent1, "D12SetData_m( void[宏] ): void ", "[ 写出数据,输出命令到数据口上 ] ", "[ 1个输入参数 ]");
                // 宏(C-5)
                TextNew(treeNode_parent1, "D12SetWr_m( void[宏] ): void ", "[ WR置高 ]", "");
                // 宏(C-6)
                TextNew(treeNode_parent1, "D12SetPortIn_m( void[宏] ): void ", "[ 将数据口设置为输入状态,以备后面输入使用 ]", "");
            TextNew(treeNode_parent, "D12WriteByte( <uint8>0x47 ): void ", "[ 设置模式的第二字节 ]", "");
            TextNew(treeNode_parent, "DelayXms( <uint16>1000 ) ", "[ 延迟1秒 ] ", "[ ZC: 循环语句,什么都没有执行,只是浪费CPU时间 (∴ 这样腿短的话, 芯片应该也是有CPU的) ]");

        TextNew(null, "", "", "");
        TextNew(null, "UsbConnect( void ): void ", "[ 将USB连接上 ]", "");            treeNode_parent = g_treeNode_Create;
            TextNew(treeNode_parent, "D12WriteCommand( <uint8>D12_SET_MODE(0xF3) ): void ", "[ 写设置模式命令 ] ", "[ 传参D12_SET_MODE(0xF3) ]");
            TextNew(treeNode_parent, "D12WriteByte( <uint8>0x16 ): void ", "[ 设置模式的第一字节 ] ", "[ 传参 (0x16) ]");
            TextNew(treeNode_parent, "D12WriteByte( <uint8>0x47 ): void ", "[ 设置模式的第二字节 ] ", "[ 传参 (0x47) ]");

        TextNew(null, "", "", "");
        TextNew(null, "无限循环 ", "", "");        treeNode_parent = g_treeNode_Create;
            TextNew(treeNode_parent, "D12GetIntPin_m( void宏 ): uint8? ", "[ 获取中断引脚电平状态 ] ", "[ D12_INT(P3_2).判断是否有中断发生,低电平有效,返回值==0说明有中断发生 ]");        treeNode_parent1 = g_treeNode_Create;
                TextNew(treeNode_parent1, "D12WriteCommand( <uint8>READ_INTERRUPT_REGISTER[0xF4] ): void ", "[ 写读中断寄存器的命令 ] ", "[ 6个宏操作 ]");
                TextNew(treeNode_parent1, "D12ReadByte( void ): uint8 ", "[ 读回第一字节的中断寄存器 ] ", "[ 返回到变量InterruptSource中 ]");

                TextNew(null, "", "", "");
                TextNew(treeNode_parent1, "UsbBusSuspend( void ): void ", "[ 总线挂起中断处理 ] ",  "[ InterruptSource & 0x80. 空函数 ]", 0, 10);
                TextNew(treeNode_parent1, "UsbBusReset( void ): void ", "[ 总线复位中断处理 ] ",  "[ InterruptSource & 0x40 ]", 24, 10);    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "g_Ep1InIsBusy = 0; ", "[ 复位后端点1输入缓冲区空闲。 ] ",  "");
                TextNew(treeNode_parent1, "UsbEp0Out( void ): void ", "[ 端点0输出中断处理 ] ", "[ InterruptSource & 0x01 ]", 36);        treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "D12ReadEndpointLastStatus( <uint8>0:端点号 ): uint8 ", "[ 读取端点0输出最后传输状态,该操作清除中断标志,并判断第5位是否为1,如果是,则说明是建立包 否则是 普通包 ] ", "[ 返回值执行操作'&0x20',区分 建立包(true)/普通包(false) ]", 36);    treeNode_parent3 = g_treeNode_Create;
                        TextNew(treeNode_parent3, "D12WriteCommand( <uint8>0x40+端点号 ): void ", "[ 读取端点最后状态的命令 ] ", "[ 入口参数:Command(uint8):一字节命令。 ]");
                        TextNew(treeNode_parent3, "D12ReadByte( void ): uint8 ", "[ 读一字节D12数据 ]", "");
                    TextNew(treeNode_parent2, "[ 建立包 ]", "", "");        treeNode_parent3 = g_treeNode_Create;
                        TextNew(treeNode_parent3, "D12ReadEndpointBuffer( <uint8>端点号, <uint8>需要读取的长度, <uint8*>保存数据的缓冲区 ): uint8", "[ 读取端点缓冲区的内容 ]", "[ 返回: 实际读到的数据长度 ]");    treeNode_parent4 = g_treeNode_Create;
                            TextNew(treeNode_parent4, "D12SelectEndpoint( <uint8>端点号 ) ", "[ 选择端点的函数,选择一个端点后才能对它进行数据操作 ]", "[ 无返回值 ]");        treeNode_parent5 = g_treeNode_Create;
                                TextNew(treeNode_parent5, "D12WriteCommand( <uint8>0x00+端点号 ): void ", "[ 选择端点的命令 ] ", "[ 无返回值 ]");
                            TextNew(treeNode_parent4, "D12WriteCommand( <uint8>D12_READ_BUFFER[0xF0] ): void ", "[ 发送读缓冲区的命令(ZC: 意思是 告诉芯片,我现在要开始读取数据了) ] ", "[ 无返回值 ]");
                            TextNew(treeNode_parent4, "D12ReadByte( void ): unit8", "[ 该字节数据是保留的,不用 ] ", "[ 返回: 读回的一字节 ]");
                            TextNew(treeNode_parent4, "D12ReadByte( void ): uint8", "[ 这里才是实际的接收到的数据长度 ] ", "[ 返回: 读回的一字节 ]");
                            TextNew(treeNode_parent4, "[ 如果要读的字节数比实际接收到的数据长, 则只读指定的长度数据 ]", "", "");

                            TextNew(treeNode_parent4, "", "", "");
                            TextNew(treeNode_parent4, "[ 这里不直接调用读一字节的函数,而直接在这里模拟时序,可以节省时间 ]", "", "");
                            TextNew(treeNode_parent4, "[ ZC: 这里的代码和 D12ReadByte()中的代码相比,就少了 一个函数“D12SetDataAddr_m();//设置为数据地址”的调用 ]", "", "");    treeNode_parent5 = g_treeNode_Create;
                                TextNew(treeNode_parent5, "D12ClrRd_m( void ): void ", "[ RD置低 ] ", "[ D12_RD(P3_7)=0 ]");
                                TextNew(treeNode_parent5, "D12GetData_m( void ): uint8 ", "[ 读一字节数据 ] ", "[ D12_DATA(P0) ]");
                                TextNew(treeNode_parent5, "D12SetRd_m( void ): uint8 ", "[ RD置高 ] ", "[ D12_RD(P3_7)=1 ]");
                        TextNew(treeNode_parent3, "D12AcknowledgeSetup( void ): void", "[ 应答建立包 ]", "");    treeNode_parent4 = g_treeNode_Create;
                            TextNew(treeNode_parent4, "D12SelectEndpoint( <uint8>1:端点号 ): void ", "[ 选择端点0输入 ]", "");
                            TextNew(treeNode_parent4, "D12WriteCommand( <uint8>D12_ACKNOWLEDGE_SETUP[0xF1] ): void ", "[ 发送应答设置到端点0输入 ]", "[ 无返回值 ]");
                            TextNew(treeNode_parent4, "D12SelectEndpoint( <uint8>0:端点号 ): void ", "[ 选择端点0输出 ]", "[ 无返回值 ]");
                            TextNew(treeNode_parent4, "D12WriteCommand( <uint8>D12_ACKNOWLEDGE_SETUP[0xF1] ) ", "[ 发送应答设置到端点0输出 ]", "[ 无返回值 ]");
                        TextNew(treeNode_parent3, "D12ClearBuffer( void ): void ", "[ 清缓冲区(清除接收端点缓冲区) ]", "[ 返回: 无 ]");    treeNode_parent4 = g_treeNode_Create;
                            TextNew(treeNode_parent4, "D12WriteCommand(  <uint8>D12_CLEAR_BUFFER[0xF2] ) ", "[ D12写一字节命令 ]", "[ ZC: 清空所选择的端点的缓冲区,上面选择的是端点0,于是清空的也就是端点0的缓冲区 (是否区分清空的是输入还是输出缓冲区 ? ? ?). 备注:只有使用该函数清除端点缓冲后,该接收端点才能接收新的数据包。(ZC: 由此推断 清空的应该是接收缓冲区) ]");

                        TextNew(treeNode_parent3, "", "", "");
                        TextNew(treeNode_parent3, "[ 将缓冲数据填到设备请求的各字段中 ] ", "[ ZC: 实际上就是 从缓冲区数据中获取相应的字段值 保存到对应的全局变量中 ]", "");    treeNode_parent4 = g_treeNode_Create;
                            TextNew(treeNode_parent4, "[ 输入请求 ]", "[ (g_bmRequestType & 0x80) == 0x80 ]", "");    treeNode_parent5 = g_treeNode_Create;
                                TextNew(treeNode_parent5, "[ 标准请求 ] ", "[ USB标准输入请求 ] ", "[ (g_bmRequestType >> 5) & 0x03 == 0]");    treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "UsbEp0Out_Get_BiaoZhunQingQiu( void ): void ", "[ ZC: 获取 标准请求 ]", "");        treeNode_parent7 = g_treeNode_Create;
                                        TextNew(treeNode_parent7, "[ USB协议定义了几个标准输入请求,我们实现这些标准请求即可 ]", "", "");
                                        TextNew(treeNode_parent7, "[ 请求的代码在g_bRequest中,对不同的请求代码进行散转 ]", "", "");
                                        TextNew(treeNode_parent7, "[ 事实上,我们还需要对接收者进行散转,因为不同的请求接收者 ]", "", "");
                                        TextNew(treeNode_parent7, "[ 是不一样的。接收者在g_bmRequestType的D4~D0位中定义。 ]", "", "");
                                        TextNew(treeNode_parent7, "[ 我们这里为了简化操作,有些就省略了对接收者的判断。 ]", "", "");
                                        TextNew(treeNode_parent7, "[ 例如获取描述符的请求,只根据描述符的类型来区别。 ]", "", "");    treeNode_parent8 = g_treeNode_Create;

                                        TextNew(null, "", "", "");
                                        TextNew(treeNode_parent7, "[ 获取配置 ]", "[ g_bRequest == GET_CONFIGURATION(8) ]", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 获取描述符—— ]", "[ g_bRequest == GET_DESCRIPTOR(6) ]", "");
                                            TextNew(treeNode_parent8, "[ UsbEp0Out_Get_BiaoZhunQingQiu_Descriptor( void ): void ]", "", "");    treeNode_parent9 = g_treeNode_Create;
                                                TextNew(treeNode_parent9, "[ 设备描述符 ]", "", "");
                                                TextNew(treeNode_parent9, "[ 配置描述符 ]", "", "");
                                                TextNew(treeNode_parent9, "[ 字符串描述符 ]", "", "");    treeNode_parent10 = g_treeNode_Create;
                                                    TextNew(treeNode_parent10, "[ 语言ID ]", "[ 获取语言ID ]", "");
                                                    TextNew(treeNode_parent10, "[ 厂商描述 ]", "[ 厂商字符串的索引值为1,所以这里为厂商字符串 ]", "");
                                                    TextNew(treeNode_parent10, "[ 产品描述 ]", "[ 产品字符串的索引值为2,所以这里为产品字符串 ]", "");
                                                    TextNew(treeNode_parent10, "[ 产品序列号 ]", "[ 产品序列号的索引值为3,所以这里为序列号 ]", "");
                                                    TextNew(treeNode_parent10, "[ 未知的索引值 ]", "", "");
                                                TextNew(treeNode_parent9, "[ 报告描述符 ]", "", "");
                                                TextNew(treeNode_parent9, "[ 其它描述符 ]", "", "");
                                                TextNew(treeNode_parent9, "UsbEp0SendData( void ): void ", "[ 将数据通过EP0返回 ]", "");


                                        TextNew(treeNode_parent7, "[ 获取接口 ] ", "", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 获取状态 ] ", "", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 同步帧 ] ", "", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 错误:未定义的标准输入请求 ]", "", "[ ZC: 什么都不做,只打印信息 ]");

                                TextNew(null, "", "", "");
                                TextNew(treeNode_parent5, "[ 类请求 ]", "[ USB类输入请求 ]", "[ (g_bmRequestType >> 5) & 0x03 == 1 ]");        treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "[ ZC: 什么都不做,只打印信息 ]", "", "");
                                TextNew(treeNode_parent5, "[ 厂商请求 ]", "[ USB厂商输入请求 ]", "[ (g_bmRequestType >> 5) & 0x03 == 2 ]");        treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "[ ZC: 什么都不做,只打印信息 ]", "", "");
                                TextNew(treeNode_parent5, "[ 未定义的请求 ]", "[ 错误:未定义的输入请求 ]", "[ (g_bmRequestType >> 5) & 0x03 不为 0和1 的其它情况]");        treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "[ ZC: 什么都不做,只打印信息 ]", "", "");

                            TextNew(null, "", "", "");
                            TextNew(treeNode_parent4, "[ 输出请求 ]", "", "[ (g_bmRequestType & 0x80 != 0x80) ]");    treeNode_parent5 = g_treeNode_Create;
                                TextNew(treeNode_parent5, "[ 标准请求 ]", "[ USB标准输出请求 ]", "");        treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "UsbEp0Out_Set_BiaoZhunQingQiu( void )", "", "");    treeNode_parent7 = g_treeNode_Create;
                                        TextNew(treeNode_parent7, "[ 清除特性 ] ", "", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 设置地址 ]", "", "");        treeNode_parent8 = g_treeNode_Create;
                                            TextNew(treeNode_parent8, "D12SetAddress( <uint8>g_wValue & 0xFF ): void ", "[ 设置地址 ]", "[ wValue中的低字节是设置的地址值 ]");        treeNode_parent9 = g_treeNode_Create;
                                                TextNew(treeNode_parent9, "D12WriteCommand( <uint8>D12_SET_ADDRESS_ENABLE[0xD0] ): void ", "[ 写设置地址命令 ]", "");
                                                TextNew(treeNode_parent9, "D12WriteByte( <uint8>(0x80 | Addr) ): void ", "[ 写一字节数据:使能及地址 ]", "");
                                            TextNew(treeNode_parent8, "UsbEp0SendData( void ): void ", "[ 将数据通过EP0返回 ]", "");
                                        TextNew(treeNode_parent7, "[ 设置配置 ]", "", "");        treeNode_parent8 = g_treeNode_Create;
                                            TextNew(treeNode_parent8, "D12SetEndpointEnable( <uint8>g_ConfigValue ): void ", "[ 使能端点 ]", "[ 入口参数: Enable: 是否使能; 0值为不使能,非0值为使能。返回: 无 ]");        treeNode_parent9 = g_treeNode_Create;
                                                TextNew(treeNode_parent9, "D12WriteCommand( <uint8>D12_SET_ENDPOINT_ENABLE[0xD8] ): void ", "", "");
                                                TextNew(treeNode_parent9, "D12WriteByte( <uint8>0x01 ): void ", "[ D0为1使能端点 ] ", "[ ZC: 在这个操作之前,不需要进行选择端点的操作吗 ? ? ? ]");
                                                TextNew(treeNode_parent9, "D12WriteByte( <uint8>0x00 ): void ", "[ 不使能端点 ]", "");
                                            TextNew(treeNode_parent8, "UsbEp0SendData( void ): void ", "[ 将数据通过EP0返回 ]", "");
                                        TextNew(treeNode_parent7, "[ 设置描述符 ]", "", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 设置特性 ]", "", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 设置接口 ]", "", "[ ZC: 什么都不做,只打印信息 ]");
                                        TextNew(treeNode_parent7, "[ 未定义的标准请求 ]", "[ 错误:未定义的标准输出请求 ]", "[ ZC: 什么都不做,只打印信息 ]");

                                TextNew(treeNode_parent5, "[ 类请求 ]", "[ USB类输出请求 ]", "");        treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "[ 设置空闲 ]", "", "");
                                    TextNew(treeNode_parent6, "[ 未知请求 ]", "", "");
                                TextNew(treeNode_parent5, "[ 厂商请求 ]", "[ USB厂商输出请求 ]", "");        treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "[ ZC: 什么都不做,只打印信息 ]", "", "");
                                TextNew(treeNode_parent5, "[ 未定义的请求 ]", "[ 错误:未定义的输出请求 ]", "");    treeNode_parent6 = g_treeNode_Create;
                                    TextNew(treeNode_parent6, "[ ZC: 什么都不做,只打印信息 ]", "", "");

                    TextNew(treeNode_parent2, "", "", "");
                    TextNew(treeNode_parent2, "[ 普通包 ]", "[ ZC: 普通包 处理过程中,少了 D12AcknowledgeSetup();函数的调用 ]", "");    treeNode_parent3 = g_treeNode_Create;
                        TextNew(treeNode_parent3, "D12ReadEndpointBuffer( <uint8>端点号, <uint8>需要读取的长度, <uint8*>保存数据的缓冲区 ): uint8 ", "", "");
                        TextNew(treeNode_parent3, "D12ClearBuffer( void ): void ", "", "");

                TextNew(treeNode_parent1, "UsbEp0In( void ):void ", "[ 端点0输入中断处理 ] ", "[ InterruptSource & 0x02 ]", 50);    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "D12ReadEndpointLastStatus( <uint8>1:端点号 ): uint8 ", "[ 读最后发送状态,这将清除端点0的中断标志位 ]", "");
                    TextNew(treeNode_parent2, "UsbEp0SendData( void ): void ", "[ 发送剩余的字节数 ]", "[ 根据pData和g_SendLength将数据发送到端点0的函数。// ZC: 应该是 pSendData吧?(g_pSendData) ]");    treeNode_parent3 = g_treeNode_Create;
                        TextNew(treeNode_parent3, "[ 将数据写到端点中去准备发送 ]", "", "");
                        TextNew(treeNode_parent3, "[ 写之前要先判断一下需要发送的数据是否比端点0 ]", "", "");
                        TextNew(treeNode_parent3, "[ 最大长度大,如果超过端点大小,则一次只能发送 ]", "", "");
                        TextNew(treeNode_parent3, "[ 最大包长的数据。端点0的最大包长在DeviceDescriptor[7] ]", "", "");    treeNode_parent4 = g_treeNode_Create;

                            TextNew(treeNode_parent4, "D12WriteEndpointBuffer( <uint8>端点号, <uint8>需要发送的长度, <uint8*>保存数据的缓冲区): uint8 ", "[ 将数据写入端点缓冲区 ] ", "[ 返回: 发送的长度 ]");    treeNode_parent5 = g_treeNode_Create;
                                TextNew(treeNode_parent5, "D12SelectEndpoint( <uint8>端点号 ): void ", "[ 选择端点 ]", "");
                                TextNew(treeNode_parent5, "D12WriteCommand( <uint8>D12_WRITE_BUFFER[0xF0] ) ", "[ 写Write Buffer命令 ]", "");
                                TextNew(treeNode_parent5, "D12WriteByte( <uint8>0 ): void ", "[ 该字节必须写0 ]", "");
                                TextNew(treeNode_parent5, "D12WriteByte( <uint8>_Len ) ", "[ 写需要发送数据的长度 ]", "");
                                TextNew(treeNode_parent5, "D12SetPortOut_m( 空宏 ) ", "[ 将数据口设置为输出状态(注意这里为空宏,移植时可能有用) ]", "");    treeNode_parent6 = g_treeNode_Create;

                                TextNew(treeNode_parent6, "[ ZC: 循环一个字节一个字节的发送 ]", "[ ZC: 这里的代码 和 里面相比,少调用了 宏D12SetDataAddr_m() 和 宏D12SetPortOut_m()[这个是空宏] ]", "");
                                TextNew(treeNode_parent6, "[ 这里不直接调用写一字节的函数,而直接在这里模拟时序,可以节省时间 ]", "[ ZC: 这里说的“节省时间”,难道说的是 节省调用函数的时间(调用函数需要压参数,栈准备等 操作)? ]", "");    treeNode_parent7 = g_treeNode_Create;
                                    TextNew(treeNode_parent7, "D12ClrWr_m( void[宏] ): void", "[ WR置低 ]", "[ D12_WR(P3_6)=0 ]");
                                    TextNew(treeNode_parent7, "D12SetData_m( <uint8>[宏] ): void", "[ 将数据放到数据线上 ]", "[ D12_DATA(P0)=(Value) ]");
                                    TextNew(treeNode_parent7, "D12SetWr_m( void[宏] ): void", "[ WR置高,完成一字节写 ]", "[ D12_WR(P3_6)=1 ]");

                                TextNew(treeNode_parent6, "D12SetPortIn_m( void[宏] ): void ", "[ 数据口切换到输入状态 ] ", "[ D12_DATA(P0)=0xFF ]");
                                TextNew(treeNode_parent6, "D12ValidateBuffer( <uint8>宏 ): void ", "[ 数据口切换到输入状态 ] ", "[ D12_DATA(P0)=0xFF ]");    treeNode_parent7 = g_treeNode_Create;
                                    TextNew(treeNode_parent7, "D12WriteCommand( <uint8>D12_VALIDATE_BUFFER[0xFA] )", "", "");

                TextNew(treeNode_parent1, "", "", "");
                TextNew(treeNode_parent1, "UsbEp1Out(void): void ", "[ 端点1输出中断处理 ] ", "[ InterruptSource & 0x04 ]", 36);    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ 空函数 ]", "", "");

                TextNew(treeNode_parent1, "", "", "");
                TextNew(treeNode_parent1, "UsbEp1In(void): void ", "[ 端点1输入中断处理 ] ", "[ InterruptSource & 0x08 ]", 50);    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "D12ReadEndpointLastStatus( <uint8>3:端点号 ): uint8 ", "[ 读最后发送状态,这将清除端点1输入的中断标志位 ]", "[ 读取D12最后传输状态寄存器的函数. 返回: 端点的最后传输状态。备注: 该操作将清除该端点的中断标志位。 ]");
                    TextNew(treeNode_parent2, "g_Ep1InIsBusy = 0;", "[ 端点1输入处于空闲状态 ]", "");

                TextNew(treeNode_parent1, "", "", "");
                TextNew(treeNode_parent1, "UsbEp2Out(void): void ", "[ 端点2输出中断处理 ] ", "[ InterruptSource & 0x10 ]", 36);    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ 空函数 ]", "", "");

                TextNew(treeNode_parent1, "UsbEp2In(void): void ", "[ 端点2输入中断处理 ] ", "[ InterruptSource & 0x20 ]", 50);    treeNode_parent2 = g_treeNode_Create;
                    TextNew(treeNode_parent2, "[ 空函数 ]", "", "");

            TextNew(treeNode_parent, "", "", "");
            TextNew(treeNode_parent, "[ 按键 ]", "", "");    treeNode_parent1 = g_treeNode_Create;
                TextNew(treeNode_parent1, "SendReport( void ): void ", "[ 根据按键情况返回报告 ] ", "[ 返回:无]");
    };


    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***


    function TextNew(_treenodeParent, _str_funcName, _str_note1, _str_note2,
        _dOffset1, _dOffset2)
    {
        g_iY_Create += g_iOffsetY;
        if (! _treenodeParent)
        {
            TextCreate(g_iX_Begin, g_iY_Create, 0, _str_funcName, _str_note1, _str_note2, _dOffset1, _dOffset2);
        }
        else
        {
            var iIndentCnt = _treenodeParent.indent_z + 1;
            var x = g_iX_Begin + iIndentCnt * g_iOffsetX;
            TextCreate(x, g_iY_Create, iIndentCnt, _str_funcName, _str_note1, _str_note2, _dOffset1, _dOffset2);
        }
    }

    function TextCreate(_dX, _dY, _iIndentZ, _str_funcName, _str_note1, _str_note2,
        _dOffset1, _dOffset2)
    {
        g_bTextBackground = ! g_bTextBackground;
        if (g_bTextBackground)
        {
            var rect = document.createElementNS(g_strNS, "rect");
            g_eleSvg.appendChild(rect);
        }

        var eleText = document.createElementNS(g_strNS, "text");
        g_eleSvg.appendChild(eleText);

        eleText.setAttribute("x", _dX + "");
        eleText.setAttribute("y", _dY + "");

        eleText.indent_z = _iIndentZ;
        g_treeNode_Create = eleText;

        {// tspan 第1个
            var tspan = document.createElementNS(g_strNS, "tspan");
            eleText.appendChild(tspan);
            tspan.setAttribute("fill", "blue");

            var nodeText = document.createTextNode( _str_funcName );
            tspan.appendChild(nodeText);
        }
        {// tspan 第2个
            tspan = document.createElementNS(g_strNS, "tspan");
            eleText.appendChild(tspan);
            if (_dOffset1)
                tspan.setAttribute("dx", _dOffset1+"");

            nodeText = document.createTextNode( _str_note1 );
            tspan.appendChild(nodeText);
        }
        {// tspan 第3个
            tspan = document.createElementNS(g_strNS, "tspan");
            eleText.appendChild(tspan);
            if (_dOffset2)
                tspan.setAttribute("dx", _dOffset2+"");

            nodeText = document.createTextNode( _str_note2 );
            tspan.appendChild(nodeText);
        }
        if (g_bTextBackground)
        {
            //eleText.setAttribute("style", "background-color:#FF9; color:#F00;");
            //eleText.style.backgroundColor = "#FF9";// color:#F00;");
            var rt = eleText.getBBox();
            rect.setAttribute("x", rt.x + "");
            rect.setAttribute("y", rt.y + "");
            rect.setAttribute("width",  rt.width + "");
            rect.setAttribute("height", rt.height + "");
            rect.setAttribute("fill", "gray");
            rect.setAttribute("fill-opacity", "0.2");
        }
    }
-->
]]>
</script>


</svg>

</html>

3、

4、

5、

猜你喜欢

转载自www.cnblogs.com/dpjz/p/9647638.html
今日推荐