Documentation added.
This commit is contained in:
parent
c1fcb4135e
commit
14c16cd9e9
1 changed files with 62 additions and 27 deletions
|
@ -1,42 +1,77 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# usage:
|
||||
#
|
||||
# ./param2HexFrame.pl "frame 1 data" "frame 2 data" ... "frame N data"
|
||||
#
|
||||
# frame X data = delay; layer 1; layer 2; layer 3
|
||||
#
|
||||
# delay = 0 to 31 (multiplied by 8 in firmware and equals to the ISR calls (delay/300 seconds)
|
||||
# 0 equals to a delay of 255/300 seconds.
|
||||
#
|
||||
# layer Y = layer no(1,2,3), bit0, bit1, bit2, ..., bit n (1 to 9)
|
||||
#
|
||||
# Sample usage which generates 5 frames:
|
||||
#
|
||||
# ./param2HexFrame.pl "25;3,2,5,8;" "14;3,3,5,7" "3;3,4,5,6;2,6,5,4" "23;3,1,5,9" "0;2,1,2,3,4,5,6,7,8,9;1,5"
|
||||
# Frame 0 = 0xca480000 = hi:0xca48 = lo:0x0000 = 0b11001010010010000000000000000000
|
||||
# Frame 1 = 0x71500000 = hi:0x7150 = lo:0x0000 = 0b01110001010100000000000000000000
|
||||
# Frame 2 = 0x18e07000 = hi:0x18e0 = lo:0x7000 = 0b00011000111000000111000000000000
|
||||
# Frame 3 = 0xbc440000 = hi:0xbc44 = lo:0x0000 = 0b10111100010001000000000000000000
|
||||
# Frame 4 = 0x0003fe10 = hi:0x0003 = lo:0xfe10 = 0b00000000000000111111111000010000
|
||||
#
|
||||
|
||||
use strict;
|
||||
|
||||
for (my $i=0; $i<=$#ARGV; $i++)
|
||||
{
|
||||
print "Frame $i = ";
|
||||
my @list = split(",", $ARGV[$i]);
|
||||
printf("Frame %02d = ", $i);
|
||||
|
||||
my @list = split(";", $ARGV[$i]);
|
||||
my $frame = 0;
|
||||
my $first = 1;
|
||||
my $ebene = 0;
|
||||
my $bit = 0;
|
||||
if ($#list >= 0 && $#list <= 9)
|
||||
{
|
||||
my $ele = 0;
|
||||
my $status = 1;
|
||||
foreach my $ele (@list)
|
||||
{
|
||||
if ($first == 1)
|
||||
{
|
||||
$ebene = ($ele - 1) * 9;
|
||||
$first = 2;
|
||||
my @list2 = split(",", $ele);
|
||||
|
||||
} elsif ($first == 2) {
|
||||
$first = 0;
|
||||
if ($ele < 32)
|
||||
my $status2 = 1;
|
||||
my $layer = 0;
|
||||
my $bit = 0;
|
||||
if ($status == 1) { # read the delay
|
||||
$status = 0;
|
||||
# minimum delay is 0 (equals to a delay of 255 ISR calls)
|
||||
# maximum delay is 31 (equals to a delay of 31*8 ISR calls)
|
||||
if ($ele > -1 && $ele < 32)
|
||||
{
|
||||
$frame |= $ele << 27;
|
||||
}
|
||||
} else {
|
||||
if ($ele < 10)
|
||||
if ($#list >= 0 && $#list <= 9)
|
||||
{
|
||||
$bit = $ebene + $ele-1;
|
||||
my $ele = 0;
|
||||
foreach my $ele2 (@list2)
|
||||
{
|
||||
if ($status2 == 1) # read the layer
|
||||
{
|
||||
# the layer has to be in range of 1 to 3
|
||||
if ($ele2 > 0 && $ele2 < 4)
|
||||
{
|
||||
$layer = ($ele2 - 1) * 9;
|
||||
$status2 = 0;
|
||||
}
|
||||
} else {
|
||||
if ($ele2 > 0 && $ele2 < 10) # bit 1 to 9 allowed
|
||||
{
|
||||
$bit = $layer + $ele2-1;
|
||||
$frame |= (1 << $bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("0x%08x = ", $frame);
|
||||
printf("hi:0x%04x = ", $frame >> 16);
|
||||
printf("lo:0x%04x = ", $frame & 0xffff);
|
||||
printf("0b%032b\n", $frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue