yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #!/usr/bin/perl
|
| 2 | #
|
| 3 | # Copyright Statement:
|
| 4 | # --------------------
|
| 5 | # This software is protected by Copyright and the information contained
|
| 6 | # herein is confidential. The software may not be copied and the information
|
| 7 | # contained herein may not be used or disclosed except with the written
|
| 8 | # permission of MediaTek Inc. (C) 2005
|
| 9 | #
|
| 10 | # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
|
| 11 | # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
|
| 12 | # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
|
| 13 | # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
|
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
|
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
|
| 16 | # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
|
| 17 | # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
|
| 18 | # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
|
| 19 | # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
|
| 20 | # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
|
| 21 | # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
|
| 22 | #
|
| 23 | # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
|
| 24 | # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
|
| 25 | # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
|
| 26 | # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
|
| 27 | # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
|
| 28 | #
|
| 29 | # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
|
| 30 | # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
|
| 31 | # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
|
| 32 | # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
|
| 33 | # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
|
| 34 | #
|
| 35 | #
|
| 36 | #*****************************************************************************
|
| 37 | #*
|
| 38 | #* Filename:
|
| 39 | #* ---------
|
| 40 | #* gps_config2.pl
|
| 41 | #*
|
| 42 | #* Project:
|
| 43 | #* --------
|
| 44 | #* Maui_Software
|
| 45 | #*
|
| 46 | #* Description:
|
| 47 | #* ------------
|
| 48 | #*
|
| 49 | #*------------------------------------------------------------------------------
|
| 50 | #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 51 | #*============================================================================
|
| 52 | #****************************************************************************/
|
| 53 |
|
| 54 | #****************************************************************************
|
| 55 | # parsing command arguments
|
| 56 | #****************************************************************************
|
| 57 |
|
| 58 | #$file2="custom\\drv\\misc_drv\\EVEN6228_DEMO_BB\\codegen\\gpio_var.c"; # Need Modify: Input from @ mcu\custom\drv\misc_drv\EVEN6228_DEMO_BB\codegen\gpio_var.c
|
| 59 | #$gps_ini="build\\EVEN6228_DEMO\\EVEN6228_DEMO_PCB04_gprs_MT6228_S02.MAUI_W07_40.bin\\GPS\\gps.ini"; # Need Modify: Output to @ mcu\build\$EVEN6228_DEMO_BB\$NFB\GPS\gps.ini
|
| 60 |
|
| 61 | $file2=$ARGV[0];
|
| 62 | $gps_ini=$ARGV[1];
|
| 63 |
|
| 64 | @gps_gpio=("gpio_gps_power_pin",
|
| 65 | "gpio_gps_reset_pin",
|
| 66 | "gpio_gps_standby_pin",
|
| 67 | "gpio_gps_32k_pin");
|
| 68 |
|
| 69 | open(GPS_CONFIG, $file2) or die "$file2 cannot be opened!\r\n";
|
| 70 |
|
| 71 | print "Open $file2!\r\n\r\n";
|
| 72 |
|
| 73 | sub GetDefineValue {
|
| 74 | my ($line) = $_[0];
|
| 75 | my ($pattern) = $_[1];
|
| 76 | my ($ret) = 0;
|
| 77 | my ($value) = 0;
|
| 78 | my (@result);
|
| 79 |
|
| 80 | if($line =~ /^*$pattern/i){
|
| 81 | # print $line;
|
| 82 | # print "~~~~~~~~~~~~~>\r\n";
|
| 83 |
|
| 84 | @tokens=split(/\s+/,$line);
|
| 85 |
|
| 86 | if($tokens[4] =~ /(GPIO|GPO)/){
|
| 87 | ($token1,$token2)=split(/;/,$tokens[4]); # e.g, $tokens[4] =GPIO_PORT_1;
|
| 88 | ($gpio_type,$port,$pin)=split(/_/,$token1); # e.g, $token1 =GPIO_PORT_1
|
| 89 |
|
| 90 | if( $gpio_type =~ /GPIO/i ){
|
| 91 | $ret = 1;
|
| 92 | $value = $pin;
|
| 93 | }
|
| 94 | elsif( $gpio_type =~ /GPO/i ){
|
| 95 | $ret = 1;
|
| 96 | $value = $pin+100;
|
| 97 | }
|
| 98 | else {
|
| 99 | print "Unknow GPIO Type: $gps_type !\r\n";
|
| 100 | }
|
| 101 | }
|
| 102 | else{
|
| 103 | print "Cannot find $pattern !\r\n";
|
| 104 | }
|
| 105 |
|
| 106 | # print "<~~~~~~~~~~~~~\r\n";
|
| 107 | }
|
| 108 |
|
| 109 | @result = ($ret, $value);
|
| 110 | return @result;
|
| 111 |
|
| 112 | }
|
| 113 |
|
| 114 | open(GPS_INI, ">$gps_ini") or die "$gps_ini cannot be opened!";
|
| 115 | print GPS_INI "[GPIO]\r\n";
|
| 116 | close ($gps_ini);
|
| 117 |
|
| 118 | while($line = <GPS_CONFIG>) {
|
| 119 |
|
| 120 | foreach $pattern (@gps_gpio){
|
| 121 | # $pattern = $gps_power_pin;
|
| 122 | ($g_ret, $g_value) = GetDefineValue($line, $pattern);
|
| 123 | if($g_ret){
|
| 124 | $output="$pattern=$g_value\r\n";
|
| 125 |
|
| 126 | open(GPS_INI, ">>$gps_ini") or die "$gps_ini cannot be opened!";
|
| 127 | print GPS_INI $output;
|
| 128 | close ($gps_ini);
|
| 129 |
|
| 130 | print $output;
|
| 131 | break;
|
| 132 | }
|
| 133 | }
|
| 134 |
|
| 135 | }
|
| 136 |
|
| 137 |
|
| 138 | close ($file2);
|
| 139 | exit 0;
|
| 140 |
|