DLP控制中的字节解析过程详解(解析0x78指令发送过程)

15 篇文章 0 订阅
4 篇文章 0 订阅
  计算过程:



0 trigType

0 patNum

8 bitDepth

7 ledSelect

0 invertPat

0 insertBlack

1 bufSwap

0 trigOutPrev



unsigned long int lutWord = 0;



1        lutWord = TrigType & 3;



 解析:

 4字节: 0000 0000  ;  0000 0000 ; 0000 0000; 0000 0000;

 TeigType & 3 =>0001 & 0011 => 0001  =>  LutWord = 1;



2        if(PatNum > 24)

return -1;

lutWord |= ((PatNum & 0x3F) << 2);



解析:

0x3F: 0011 1111;

patNum:有三个数值:0 1 2=>0000  ;0001 ; 0010

假设patNum = 1

patNum & 0x3F => 0000 0001 & 0011 1111 => 0000 0001;

(patNum & 0x3F)<<2 => 0000 0100 => 4;

lutWord | ((patNum & 0x3F)<<2)  => 0001 | 0100 => 0101?



3        if( (BitDepth > 8) || (BitDepth <= 0))

return -1;

lutWord |= ((BitDepth & 0xF) << 8);



解析:

0xF: 0000 1111;

bitDepth拥有:0 1 2 3 4 5 6 7 8; 假设其为8

bitDepth & 0xF => 1000 & 1111 => 1000;

((BitDepth & 0xF) << 8) => 1000 0000 0000 : 800

lutWord | ((BitDepth & 0xF) << 8) =>

0000 0000 0000 0101 | 0000 1000 0000 0000 => 0000 1000 0000 0101





4        if(LEDSelect > 7)

return -1;

lutWord |= ((LEDSelect & 0x7) << 12);



解析:

0x7:0111

LEDSelect:0-8选择.假设当前选择7,Red?

7:0111;

LEDSelect & 0x7 =>0111 & 0111 =>0111;

(LEDSelect & 0x7) << 12 => 0111 0000 0000 0000

lutWord | ((LEDSelect & 0x7) << 12) => 0000 1000 0000 0101 | 0111 0000 0000 0000

                                    => 0111 1000 0000 0101



if(InvertPat)

lutWord |= BIT16;



BIT16: 0x00010000 : 0001 0000 0000 0000 0000

BIT17: 0x00020000 : 0010 0000 0000 0000 0000

BIT18: 0x00040000 : 0100 0000 0000 0000 0000

BIT19: 0x00080000 : 1000 0000 0000 0000 0000



以上:LutWord | BiT16 =>0000  0111 1000 0000 0101 |  0001 0000 0000 0000 0000

 =>0001  0111 1000 0000 0101

 |BIT17  =>0011  0111 1000 0000 0101

 |BIT18         =>0101  0111 1000 0000 0101

 |BIT19         =>1111  0111 1000 0000 0101

5        if(InsertBlack)

lutWord |= BIT17;



6        if(BufSwap)

lutWord |= BIT18;



7        if(trigOutPrev)

lutWord |= BIT19;



g_PatLut[g_PatLutIndex++] = lutWord;





*/

// unsigned long int : 4 byte;

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值