'(3:0)' heißt in dem Zusammenhang Bit Nummer 0 bis Bit Nummer 3,
zusammen also 4 Bit. Bei IRUN ist das noch trivial, die 4 Bit des IRUN
Parameters stehen in den oberen 4 Bit des 5. Byte (Byte 4) des
SetMotorParam command.
Also z.B. so
1 | uint8_t cmdparam[9];
|
2 | uint8_t irun = 3; // 0x0 ... 0xf
|
3 | uint8_t ihold = 4; // 0x0 ... 0xf
|
4 |
|
5 | cmdparam[4] = ( irun << 4 ) | ( ihold & 0x0f );
|
Interessanter ist der Parameter SecPos[10:0], der hat insgesamt 11 Bit
(mit den Nummern 0...10) und ist im SetMotorParam command daher über
zwei Byte verteilt. Die untersten 8 Bit stehen im Byte 7 ('[7:0]') die
oberen 3 ('[10:8]') in den oberen 3 Bit vom Byte 6.1 | uint8_t cmdparam[9];
|
2 | uint16_t secpos = 1000; // 0x000 ... 0x7ff
|
3 |
|
4 | cmdparam[6] = ( cmdparam[6] & 0x1f ) | ( ( secpos & 0x700 ) >> 3 );
|
5 | cmdparam[7] = secpos & 0xff;
|