mirror of
https://github.com/rvtr/twl_wrapsdk.git
synced 2025-10-31 06:11:10 -04:00
small arrange
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@245 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
parent
61cd321aa6
commit
4044247f5c
@ -237,7 +237,7 @@ sub regmap_init {
|
|||||||
while(<IN>) {
|
while(<IN>) {
|
||||||
if (/^\[ADDR_SPACE\]/) {
|
if (/^\[ADDR_SPACE\]/) {
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
last if (/^\[END\]/);
|
last if /^\[END\]/;
|
||||||
if (/^([\w\d]+)\s*=\s*\{MCU, (\d+),/) { # only MCU is supported
|
if (/^([\w\d]+)\s*=\s*\{MCU, (\d+),/) { # only MCU is supported
|
||||||
$mcu{$1} = $2;
|
$mcu{$1} = $2;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ sub regmap_init {
|
|||||||
if (/^\[REGISTERS\]/) {
|
if (/^\[REGISTERS\]/) {
|
||||||
my $lastreg = "";
|
my $lastreg = "";
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
last if (/\[END\]/);
|
last if /\[END\]/;
|
||||||
if (/(^[\w\d]+)\s*=\s*\{(\w+?),\s*([\w\d]+?),/) { # address entry
|
if (/(^[\w\d]+)\s*=\s*\{(\w+?),\s*([\w\d]+?),/) { # address entry
|
||||||
if ($mcu{$3}) { # MCU
|
if ($mcu{$3}) { # MCU
|
||||||
$regmap{$1}{0} = sprintf("0xA%1X%02X", $mcu{$3}, hex($2));
|
$regmap{$1}{0} = sprintf("0xA%1X%02X", $mcu{$3}, hex($2));
|
||||||
@ -267,7 +267,8 @@ sub regmap_init {
|
|||||||
# API名の整形
|
# API名の整形
|
||||||
sub name_conv {
|
sub name_conv {
|
||||||
$_ = $_[0];
|
$_ = $_[0];
|
||||||
s/\<o\>/Option/g;
|
s/\s*\<o\>\s*//g;
|
||||||
|
# s/\<o\>/Option/g;
|
||||||
s/\%/Percent/g;
|
s/\%/Percent/g;
|
||||||
s/\-/Minus/g;
|
s/\-/Minus/g;
|
||||||
s/\+/Plus/g;
|
s/\+/Plus/g;
|
||||||
@ -280,7 +281,7 @@ sub name_conv {
|
|||||||
sub func_conv {
|
sub func_conv {
|
||||||
my($key, $value, $comment) = @_;
|
my($key, $value, $comment) = @_;
|
||||||
my @v = split /\s*\,\s*/, $value; # split value
|
my @v = split /\s*\,\s*/, $value; # split value
|
||||||
$comment = " " . $comment if ($comment); # insert spaces
|
$comment = " " . $comment if $comment; # insert spaces
|
||||||
if ($key eq "LOAD") {
|
if ($key eq "LOAD") {
|
||||||
return sprintf($call_format, name_conv($value), $comment);
|
return sprintf($call_format, name_conv($value), $comment);
|
||||||
}
|
}
|
||||||
@ -337,14 +338,14 @@ sub comp_func {
|
|||||||
#ここからメイン
|
#ここからメイン
|
||||||
|
|
||||||
# 引数チェック
|
# 引数チェック
|
||||||
die "USAGE: $0 INFILE [OUTFILE]\n" if ($#ARGV != 1 and $#ARGV != 0);
|
die "USAGE: $0 INFILE [OUTFILE]\n" if $#ARGV != 1 and $#ARGV != 0;
|
||||||
|
|
||||||
# 各種初期化
|
# 各種初期化
|
||||||
regmap_init($register_sdat);
|
regmap_init($register_sdat);
|
||||||
|
|
||||||
my $infile = $ARGV[0];
|
my $infile = $ARGV[0];
|
||||||
my $outfile = $ARGV[1];
|
my $outfile = $ARGV[1];
|
||||||
($outfile = $infile) =~ s/\.ini$/.autogen.c/ unless ($outfile);
|
($outfile = $infile) =~ s/\.ini$/.autogen.c/ unless $outfile;
|
||||||
|
|
||||||
# 入出力ファイルのオープン (両方オープンしておく)
|
# 入出力ファイルのオープン (両方オープンしておく)
|
||||||
open IN, $infile or die "Cannot open the input file!\n";
|
open IN, $infile or die "Cannot open the input file!\n";
|
||||||
@ -385,14 +386,14 @@ close IN;
|
|||||||
$outfile =~ s/^.*[\\\/]//; # get basename to print
|
$outfile =~ s/^.*[\\\/]//; # get basename to print
|
||||||
printf OUT $file_head_format, $outfile; # ファイルヘッダ出力
|
printf OUT $file_head_format, $outfile; # ファイルヘッダ出力
|
||||||
foreach my $func ( @functions ) { # 検出済みAPIの宣言
|
foreach my $func ( @functions ) { # 検出済みAPIの宣言
|
||||||
printf OUT $declare_format, $$func{name} if ($$func{name});
|
printf OUT $declare_format, $$func{name} if $$func{name};
|
||||||
}
|
}
|
||||||
printf OUT "\r\n";
|
printf OUT "\r\n";
|
||||||
foreach my $func ( @functions ) { # API本体の出力
|
foreach my $func ( @functions ) { # API本体の出力
|
||||||
if ($$func{name}) { # 最初のAPIより前の場合を除く
|
if ($$func{name}) { # 最初のAPIより前の場合を除く
|
||||||
printf OUT $func_head_format, $$func{name}; # API名&開き括弧の出力
|
printf OUT $func_head_format, $$func{name}; # API名&開き括弧の出力
|
||||||
print OUT "#pragma unused(camera)\r\n" unless ($$func{data} =~ /camera/); # warning–hŽ~
|
print OUT "#pragma unused(camera)\r\n" unless $$func{data} =~ /\bcamera\b/; # warning–hŽ~
|
||||||
print OUT $$func{declare}, "\r\n" if ($$func{declare}); # •Ï<E280A2>”<EFBFBD>錾 (if any)
|
print OUT $$func{declare}, "\r\n" if $$func{declare}; # •Ï<E280A2>”<EFBFBD>錾 (if any)
|
||||||
}
|
}
|
||||||
print OUT comp_func($$func{data}); # 本体の後処理+出力
|
print OUT comp_func($$func{data}); # 本体の後処理+出力
|
||||||
if ($$func{name}) { # 最初のAPIより前の場合を除く
|
if ($$func{name}) { # 最初のAPIより前の場合を除く
|
||||||
|
|||||||
@ -72,29 +72,28 @@ $multi_foot_format =~ s/\r?\n/\r\n/g;
|
|||||||
my $row_nums = 8;
|
my $row_nums = 8;
|
||||||
sub sprint_command {
|
sub sprint_command {
|
||||||
my($addr, @value) = @_;
|
my($addr, @value) = @_;
|
||||||
if (@value == 1) { # シングルライトは別枠
|
return sprintf($single_format, $addr, $value[0]) if @value == 1; # シングルライトは別枠
|
||||||
return sprintf($single_format, $addr, $value[0]);
|
|
||||||
}
|
|
||||||
my $result = $multi_head_format; # これ以降はバーストライト
|
my $result = $multi_head_format; # これ以降はバーストライト
|
||||||
for (my $i = 0; $i < @value; $i++)
|
for (my $i = 0; $i < @value; $i++) {
|
||||||
{
|
if ($i % $row_nums == 0) {
|
||||||
if (($i % $row_nums) == 0) {
|
|
||||||
$result .= " " ;
|
$result .= " " ;
|
||||||
} else {
|
} else {
|
||||||
$result .= " " ;
|
$result .= " " ;
|
||||||
}
|
}
|
||||||
$result .= sprintf("0x%02X,", $value[$i]);
|
$result .= sprintf("0x%02X,", $value[$i]);
|
||||||
if (($i % $row_nums) == ($row_nums - 1) ) {
|
if ($i % $row_nums == $row_nums - 1) {
|
||||||
$result .= "\r\n";
|
$result .= "\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((@value % $row_nums) != 0) {
|
if (@value % $row_nums != 0) {
|
||||||
$result .= "\r\n";
|
$result .= "\r\n";
|
||||||
}
|
}
|
||||||
$result .= sprintf($multi_foot_format, $addr, scalar(@value));
|
$result .= sprintf($multi_foot_format, $addr, scalar(@value));
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ここからメイン
|
||||||
|
|
||||||
#
|
#
|
||||||
# データはいったんキャッシュして、連続アドレスをバーストライトに書き換える
|
# データはいったんキャッシュして、連続アドレスをバーストライトに書き換える
|
||||||
#
|
#
|
||||||
@ -103,15 +102,13 @@ my @cache; #
|
|||||||
my $start = -1; # キャッシュの先頭アドレス
|
my $start = -1; # キャッシュの先頭アドレス
|
||||||
my @output; # 出力データ
|
my @output; # 出力データ
|
||||||
|
|
||||||
#ここからメイン
|
|
||||||
|
|
||||||
# 引数チェック
|
# 引数チェック
|
||||||
die "USAGE: $0 INFILE [OUTFILE]\n" if ($#ARGV != 1 and $#ARGV != 0);
|
die "USAGE: $0 INFILE [OUTFILE]\n" if $#ARGV != 1 and $#ARGV != 0;
|
||||||
|
|
||||||
# 各種初期化
|
# 各種初期化
|
||||||
my $infile = $ARGV[0];
|
my $infile = $ARGV[0];
|
||||||
my $outfile = $ARGV[1];
|
my $outfile = $ARGV[1];
|
||||||
($outfile = $infile) =~ s/\.dat$/.autogen.c/ unless ($outfile);
|
($outfile = $infile) =~ s/\.dat$/.autogen.c/ unless $outfile;
|
||||||
|
|
||||||
# 入出力ファイルのオープン (両方オープンしておく)
|
# 入出力ファイルのオープン (両方オープンしておく)
|
||||||
open IN, $infile or die "Cannot open the input file!\n";
|
open IN, $infile or die "Cannot open the input file!\n";
|
||||||
@ -121,15 +118,12 @@ open OUT, ">", $outfile or die "Cannot open the output file!\n";
|
|||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
s/[\r\n]+$//; # delete \r and/or \n
|
s/[\r\n]+$//; # delete \r and/or \n
|
||||||
s|\#|// |g; # change comment sign
|
s|\#|// |g; # change comment sign
|
||||||
if (s|(//.*)||) { # コメント抽出
|
$comment .= " $1\r\n" if s|(//.*)||; # コメント抽出(独立行として出力予定)
|
||||||
$comment .= " $1\r\n"; # 独立行として出力予定
|
|
||||||
}
|
|
||||||
|
|
||||||
if (/\s*([\w\d]{2})\s+([\w\d]{2})/) { # データ抽出
|
if (/\s*([\w\d]{2})\s+([\w\d]{2})/) { # データ抽出
|
||||||
my ($addr, $value) = (hex($1), hex($2));
|
my ($addr, $value) = (hex($1), hex($2));
|
||||||
if ($addr != $start + @cache) # アドレスが連続していないなら
|
if ($addr != $start + @cache) { # アドレスが連続していないなら
|
||||||
{ # 直前までを出力
|
push @output, sprint_command($start, @cache) if (@cache); # 直前までを出力
|
||||||
push @output, sprint_command($start, @cache) if (@cache);
|
|
||||||
@cache = ($value); # 最新の値だけのエントリにする
|
@cache = ($value); # 最新の値だけのエントリにする
|
||||||
$start = $addr;
|
$start = $addr;
|
||||||
} else { # アドレスが連続しているなら
|
} else { # アドレスが連続しているなら
|
||||||
@ -143,14 +137,10 @@ while (<IN>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# 最終行処理
|
# 最終行処理
|
||||||
push @output, sprint_command($start, @cache) if (@cache);
|
push @output, sprint_command($start, @cache) if @cache;
|
||||||
# 入力処理終了
|
# 入力処理終了
|
||||||
close IN;
|
close IN;
|
||||||
|
|
||||||
for (my $i = 0; $i < @output; $i++) {
|
|
||||||
$output[$i] =~ s/\r?\n/\r\n/g;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 出力処理
|
# 出力処理
|
||||||
$outfile =~ s/^.*[\\\/]//; # get basename to print
|
$outfile =~ s/^.*[\\\/]//; # get basename to print
|
||||||
printf OUT $file_head_format, $outfile; # ファイルヘッダ出力
|
printf OUT $file_head_format, $outfile; # ファイルヘッダ出力
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user