I tried to make it customizable, understandable and self documenting
rather than quick and dirty.
I am sure that you will be able to wrap it to nice script (in bash):
text="A,SDMMC0_CK,I/O,1B,QSPI0_SCK,O,1F,D0,I/O,2A,SDMMC0_DAT3,I/O,1B,QS
PI0_IO3,I/O,1F,D5,I/O,2A,SDMMC0_DAT4,I/O,1B,QSPI1_SCK,O,1D,TIOA5,I/O,1E
,FLEXCOM2_IO0,I/O,1F,D6,I/O,2"function row2col () {cat - | \  awk -v
FS=, '    function initRow (      col, colName, i) {      # initialize
rowArr      for (col=1;col<=colCount;++col)
{        colName=colArr[col];        for (i=0;i<fieldsPerCol;++i)
{          if (i==0) {            rowArr[colName]="";          } else
{            rowArr[colName]=","
rowArr[colName];          }        }      }    }    function
printHeader (     col, i) {      # prints table header      for
(col=1;col<=colCount;++col) {        for (i=1;i<=fieldsPerCol;++i)
{          if (col==1 && i==1) {            printf("%s%d", colArr[col],
i);          } else {            printf(",%s%d", colArr[col],
i);          }        }      }      print "";    }    function printRow
(     col, colName) {      # prints rowArr in order stored in
colArr      for (col=1;col<=colCount;++col)
{        colName=colArr[col];        if (col==1)
{          printf("%s",rowArr[colName]);        } else {          if
(col==colCount)
{            printf(",%s\n",rowArr[colName]);          } else
{            printf(",%s",rowArr[colName]);          }        }      } 
   }    BEGIN {      # list columns and their
order      colLst="A,B,C,D,E,F";      # How many fields per column A B
...)      fieldsPerCol=3;      # this is useful for easy, in order
iterations over
colLst      colCount=split(colLst,colArr,",");      initRow();    }    
$1 == "A" {      # A always starts new row      if (rowCount != 0)
{        # print output row        printRow();        initRow();      }
else {        printHeader();      }      ++rowCount;    }    $0 !~ /^[
\t]*$/ {      # collect row data from i+1 cols (first col is a b
...)      colName=$1      rowArr[colName]=$2;      for
(i=2;i<=fieldsPerCol;++i) {        rowArr[colName]=rowArr[colName] ","
$(i+1);      }    }    END {      # print last
row      printRow();    }'}
echo "$text" | row2col
A1,A2,A3,B1,B2,B3,C1,C2,C3,D1,D2,D3,E1,E2,E3,F1,F2,F3SDMMC0_CK,I/O,1,QS
PI0_SCK,O,1,,,,,,,,,,D0,I/O,2SDMMC0_DAT3,I/O,1,QSPI0_IO3,I/O,1,,,,,,,,,
,D5,I/O,2SDMMC0_DAT4,I/O,1,QSPI1_SCK,O,1,,,,TIOA5,I/O,1,FLEXCOM2_IO0,I/
O,1,D6,I/O,2

you could also:echo "$text" | row2col | column -s , -t
A1           A2   A3  B1         B2   B3  C1  C2  C3  D1     D2   D3
 E1            E2   E3  F1  F2   F3

SDMMC0_CK    I/O  1   QSPI0_SCK  O    1
                                                     D0  I/O  2

SDMMC0_DAT3  I/O  1   QSPI0_IO3  I/O  1
                                                     D5  I/O  2

SDMMC0_DAT4  I/O  1   QSPI1_SCK  O    1               TIOA5  I/O  1
  FLEXCOM2_IO0  I/O  1   D6  I/O  2

Have fun,Tomas

> import it into a spreadsheet.  The data looks like this:
> A,SDMMC0_CK,I/O,1
> B,QSPI0_SCK,O,1
> F,D0,I/O,2
> A,SDMMC0_DAT3,I/O,1
> B,QSPI0_IO3,I/O,1
> F,D5,I/O,2
> A,SDMMC0_DAT4,I/O,1
> B,QSPI1_SCK,O,1
> D,TIOA5,I/O,1
> E,FLEXCOM2_IO0,I/O,1
> F,D6,I/O,2
> 
> This data represents the available functionality of three GPIO pins. 
> Think pin mux'ing.  Each leading letter represents a possible
> function 
> for a pin.  In the above example, the first pin has functions A, B,
> and 
> F.  Each pin could have 6 possible functions (A through F), but 
> typically has fewer.  Thus the missing letters in the
> sequence.  Note 
> that not every pin has an 'A' function.  The goal is to put the
> function 
> info in the appropriate columns based on the leading letter.  There 
> should be one line per pin.  For the above data, the end result
> should 
> look something like this:
> 
> SDMMC0_CK,I/O,1,QSPI0_SCK,O,1,,,,,,,,,,D0,I/O,2
> SDMMC0_DAT3,I/O,1,QSPI0_IO3,I/O,1,,,,,,,,,,D5,I/O,2
> SDMMC0_DAT4,I/O,1,QSPI1_SCK,O,1,TIOA5,I/O,1,FLEXCOM2_IO0,I/O,1,D6,I/O
> ,2
> 
> I did this by hand, so the comma count may be off, but hopefully it
> gets 
> the point across.  Note that any of the functions A-F may be
> missing, 
> but there will always be at least one function per pin.
> 
> Suggestions on how to best accomplish this?
> 
> If you're really bored, here's the datasheet that I'm scraping.  Look
> at 
> Table 6-2 beginning on page 13.  I've already got most of the data
> from 
> this table through outside channels, but I'm missing the data from
> the 
> PIO Peripheral Signal column.
> 
> <http://ww1.microchip.com/downloads/en/DeviceDoc/SAMA5D2-Plus-DDR2-LP
> DDR2-System-in-Package-(SIP)-60001484b.pdf>
> 
> 
> thanks,
> galen
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to