首页 » 技术分享 » NuBridge功能解析

NuBridge功能解析

 

版本是:NuBridgeFW 对应0508_NuBridge_SW

  1. spi模式设置
/**
  * @brief  Initial SPI0 to be SPI master.
  *              Set PC5/PC4 as MOSI01/MISO01 of SPI0. PC5=MOSI01,PC4=MISO01
  *              Set PC0 as SS of SPI0.
  *              Set PC1 as CLK of SPI0.
  * @param  setting: the setting of SPI
  *                 bit 0~1 (SPI_TRANS_TYPE)
  *                     -00: Type0
  *                     -01: Type1
  *                     -10: Type2
  *                     -11: Type3
  *                 bit 2
  *                     -0: Least Significant Bit first
  *                     -1: Most Significant Bit first
  *                 bit 3
  *                     -0: SS active Low
  *                     -1: SS active High
  *                 bit  4~7 (clock rate)
  *                     -0000: 1 MHz
  *                     -0001: 2 MHz
  *                     -0010: 3 MHz
  *                     -0011: 4 MHz
  *                     -0100: 4.5 MHz
  *                     -0101: 6 MHz
  *                     -0111: 7.2 MHz
  *                     -1001: 9 MHz
  *                     -1111: 12 MHz
  *                     -others: Reserved
  * @retval None.
  */

  /**
  * @brief  Initial SPI0 to be SPI master with default setting 0xF4.
  * @param  None.
  * @retval None.
  */
void SPI0_Master_Init(void)
{
    // 12 MHz, SS Active Low, Order MSB first, Type 2
    SPI0_Master_ReInit(0xF4);
}

定义的宏:

#define      WM_REINIT_SPI0       0x46
#define      CMD_GET_PARAM        0xC0

得到参数:

Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------
  23.0  CTL    c0 00 00 00  00 00 40 00                            VENDOR            3.4sc         1.1.0        unknown       
  23.0  IN     00 f4 00 00  00 00 00 00  00 04 00 00  00 04 00 00  ................  1.1ms         1.2.0                      
               00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................                1.2.16                     
               00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................                1.2.32                     
               00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................                1.2.48                         

设置参数:

Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------                   
  23.0  CTL    46 f4 00 00  00 00 00 00                            VENDOR             22sc         2.1.0        unknown       

2.牛桥闪灯:

这里写图片描述

#define         WM_LED                  0x40

实际发送的命令为:


Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------    
  23.0  CTL    40 00 00 00  00 00 00 00                            VENDOR             22sc         2.1.0        unknown    

3.牛桥切换模式:
这里写图片描述

#define         WM_SWITCH_MODE          0x42
#define         MODE_SPI0_MASTER        0x01
#define         WM_SET_DISABLE          0x44

实际命令是:
点击按钮 Start 发送下面的命令

Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------
  23.0  CTL    42 01 00 00  00 00 00 00                            VENDOR             34sc         1.1.0        unknown       

点击按钮 Stop 发送下面的命令:

Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------   
  23.0  CTL    44 01 00 00  00 00 00 00                            VENDOR            5.8mn         2.1.0        unknown  

执行一条指令:

Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------
  23.5  OUT    01 01 53 01  00 00 08 06  90 00 00 00  00 00 50     ..S...........P   3.8sc         1.1.0        unknown       
  23.5  OUT    00 01                                               ..                2.3ms         2.1.0        unknown       
  23.4  IN     01 00 06 00  ff ff ff ff  51 14                     ........Q.        999us         3.1.0        ntoskrnl                      

同时执行两条指令:

Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------    
  23.5  OUT    01 02 53 01  00 00 08 06  90 00 00 00  00 00 50 53  ..S...........PS   36sc         4.1.0        unknown       
               01 00 00 08  06 90 00 00  00 00 00 50               ...........P                    4.1.16                     
  23.5  OUT    00 01                                               ..                3.6ms         5.1.0        unknown       
  23.4  IN     01 02 0c 00  51 14 ff ff  ff ff 51 14  ff ff ff ff  ....Q.....Q.....  998us         6.1.0        ntoskrnl      
               51 14                                               Q.                              6.1.16                     

执行一条命令的时候,有可能出现如下情况:

Device  Phase  Data                                                Description       Delta  Cmd.Phase.Ofs(rep)  Driver      
------  -----  --------------------------------------------------  ----------------  -----  ------------------  ------------                    
  23.5  OUT    01 01 53 01  00 00 08 06  90 00 00 00  00 00 50     ..S...........P    20mn         7.1.0        unknown       
  23.5  OUT    00 01                                               ..                5.7ms         8.1.0        unknown       
  23.4  IN     01 02 06 00  51 14 ff ff  ff ff 51 14               ....Q.....Q.       89us         9.1.0        ntoskrnl      

OUT命令格式解析:

01 — 命令类型:#define MODE_SPI0_MASTER 0x01
01 — 执行命令的条数
53 — ‘S’的ASCII码
01 — Repeat的次数
00 00 — Idle Time
08 — Bit Length
06 — command bytes cnt
90 00 00 00 00 00 — command
50 — ‘P’的ASCII码

IN 命令格式解析:
01 — 命令类型:#define MODE_SPI0_MASTER 0x01
00 — 偏移offset ,内容的第几个内容开发是正确的有效内容
06 00 —- 长度
ff ff ff ff 51 14 —–内容

IN 命令格式解析:
01 — 命令类型:#define MODE_SPI0_MASTER 0x01
02 — 偏移offset ,从内容的第几个字节开始是正确的有效内容
06 00 —- 长度
51 14 ff ff ff ff 51 14 —–内容
后面的“ ff ff ff ff 51 14”是有效的内容

转载自原文链接, 如需删除请联系管理员。

原文链接:NuBridge功能解析,转载请注明来源!

0