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>) {
|
||||
if (/^\[ADDR_SPACE\]/) {
|
||||
while (<IN>) {
|
||||
last if (/^\[END\]/);
|
||||
last if /^\[END\]/;
|
||||
if (/^([\w\d]+)\s*=\s*\{MCU, (\d+),/) { # only MCU is supported
|
||||
$mcu{$1} = $2;
|
||||
}
|
||||
@ -246,7 +246,7 @@ sub regmap_init {
|
||||
if (/^\[REGISTERS\]/) {
|
||||
my $lastreg = "";
|
||||
while (<IN>) {
|
||||
last if (/\[END\]/);
|
||||
last if /\[END\]/;
|
||||
if (/(^[\w\d]+)\s*=\s*\{(\w+?),\s*([\w\d]+?),/) { # address entry
|
||||
if ($mcu{$3}) { # MCU
|
||||
$regmap{$1}{0} = sprintf("0xA%1X%02X", $mcu{$3}, hex($2));
|
||||
@ -267,7 +267,8 @@ sub regmap_init {
|
||||
# API名の整形
|
||||
sub name_conv {
|
||||
$_ = $_[0];
|
||||
s/\<o\>/Option/g;
|
||||
s/\s*\<o\>\s*//g;
|
||||
# s/\<o\>/Option/g;
|
||||
s/\%/Percent/g;
|
||||
s/\-/Minus/g;
|
||||
s/\+/Plus/g;
|
||||
@ -280,7 +281,7 @@ sub name_conv {
|
||||
sub func_conv {
|
||||
my($key, $value, $comment) = @_;
|
||||
my @v = split /\s*\,\s*/, $value; # split value
|
||||
$comment = " " . $comment if ($comment); # insert spaces
|
||||
$comment = " " . $comment if $comment; # insert spaces
|
||||
if ($key eq "LOAD") {
|
||||
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);
|
||||
|
||||
my $infile = $ARGV[0];
|
||||
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";
|
||||
@ -385,14 +386,14 @@ close IN;
|
||||
$outfile =~ s/^.*[\\\/]//; # get basename to print
|
||||
printf OUT $file_head_format, $outfile; # ファイルヘッダ出力
|
||||
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";
|
||||
foreach my $func ( @functions ) { # API本体の出力
|
||||
if ($$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 $$func{declare}, "\r\n" if ($$func{declare}); # •Ï<E280A2>”<EFBFBD>錾 (if any)
|
||||
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 comp_func($$func{data}); # 本体の後処理+出力
|
||||
if ($$func{name}) { # 最初のAPIより前の場合を除く
|
||||
|
||||
@ -72,29 +72,28 @@ $multi_foot_format =~ s/\r?\n/\r\n/g;
|
||||
my $row_nums = 8;
|
||||
sub sprint_command {
|
||||
my($addr, @value) = @_;
|
||||
if (@value == 1) { # シングルライトは別枠
|
||||
return sprintf($single_format, $addr, $value[0]);
|
||||
}
|
||||
return sprintf($single_format, $addr, $value[0]) if @value == 1; # シングルライトは別枠
|
||||
my $result = $multi_head_format; # これ以降はバーストライト
|
||||
for (my $i = 0; $i < @value; $i++)
|
||||
{
|
||||
if (($i % $row_nums) == 0) {
|
||||
for (my $i = 0; $i < @value; $i++) {
|
||||
if ($i % $row_nums == 0) {
|
||||
$result .= " " ;
|
||||
} else {
|
||||
$result .= " " ;
|
||||
}
|
||||
$result .= sprintf("0x%02X,", $value[$i]);
|
||||
if (($i % $row_nums) == ($row_nums - 1) ) {
|
||||
if ($i % $row_nums == $row_nums - 1) {
|
||||
$result .= "\r\n";
|
||||
}
|
||||
}
|
||||
if ((@value % $row_nums) != 0) {
|
||||
if (@value % $row_nums != 0) {
|
||||
$result .= "\r\n";
|
||||
}
|
||||
$result .= sprintf($multi_foot_format, $addr, scalar(@value));
|
||||
return $result;
|
||||
}
|
||||
|
||||
#ここからメイン
|
||||
|
||||
#
|
||||
# データはいったんキャッシュして、連続アドレスをバーストライトに書き換える
|
||||
#
|
||||
@ -103,15 +102,13 @@ my @cache; #
|
||||
my $start = -1; # キャッシュの先頭アドレス
|
||||
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 $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";
|
||||
@ -121,15 +118,12 @@ open OUT, ">", $outfile or die "Cannot open the output file!\n";
|
||||
while (<IN>) {
|
||||
s/[\r\n]+$//; # delete \r and/or \n
|
||||
s|\#|// |g; # change comment sign
|
||||
if (s|(//.*)||) { # コメント抽出
|
||||
$comment .= " $1\r\n"; # 独立行として出力予定
|
||||
}
|
||||
$comment .= " $1\r\n" if s|(//.*)||; # コメント抽出(独立行として出力予定)
|
||||
|
||||
if (/\s*([\w\d]{2})\s+([\w\d]{2})/) { # データ抽出
|
||||
my ($addr, $value) = (hex($1), hex($2));
|
||||
if ($addr != $start + @cache) # アドレスが連続していないなら
|
||||
{ # 直前までを出力
|
||||
push @output, sprint_command($start, @cache) if (@cache);
|
||||
if ($addr != $start + @cache) { # アドレスが連続していないなら
|
||||
push @output, sprint_command($start, @cache) if (@cache); # 直前までを出力
|
||||
@cache = ($value); # 最新の値だけのエントリにする
|
||||
$start = $addr;
|
||||
} 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;
|
||||
|
||||
for (my $i = 0; $i < @output; $i++) {
|
||||
$output[$i] =~ s/\r?\n/\r\n/g;
|
||||
}
|
||||
|
||||
# 出力処理
|
||||
$outfile =~ s/^.*[\\\/]//; # get basename to print
|
||||
printf OUT $file_head_format, $outfile; # ファイルヘッダ出力
|
||||
|
||||
Loading…
Reference in New Issue
Block a user