##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.11A/W32               20/Jul/2004  18:58:50 #
# Copyright 1999-2004 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  arm                                                  #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  C:\medusa\zl_bus.c                                   #
#    Command line    =  -I "C:\Program Files\IAR Systems\Embedded Workbench  #
#                       4.0\ARM\INC\" -lc C:\medusa\Debug\List\ -la          #
#                       C:\medusa\Debug\List\ -o C:\medusa\Debug\Obj\ -s2    #
#                       --no_cse --no_unroll --no_inline --no_code_motion    #
#                       --no_tbaa --no_clustering --no_scheduling --debug    #
#                       --cpu_mode arm --endian little --cpu ARM7TDMI-S      #
#                       --stack_align 4 -e --fpu None                        #
#                       "-D_DLIB_CONFIG_FILE=C:\Program Files\IAR            #
#                       Systems\Embedded Workbench                           #
#                       4.0\ARM\LIB\dl4tpannl8n.h" C:\medusa\zl_bus.c        #
#    List file       =  C:\medusa\Debug\List\zl_bus.lst                      #
#    Object file     =  C:\medusa\Debug\Obj\zl_bus.r79                       #
#                                                                            #
#                                                                            #
##############################################################################

C:\medusa\zl_bus.c
      1          #include "archinc.h"
      2          #include "cli.h"
      3          #include "strutil.h"
      4          #include "zarlink.h"
      5          
      6          #ifdef CONFIG_INCLUDE_ZARLINK
      7          
      8          #include <stdlib.h>
      9          
     10          
     11          /*
     12           * SSI (clocked serial) interface
     13           */
     14          
     15          static void ssiDelay(void)
     16          {
     17            volatile int i;
     18            lpc210x_reg dummy;
     19          
     20            for(i=0;i<128;i++) 
     21              dummy = CTIME0;
     22          }
     23          
     24          /*
     25           *
     26           * Parallel (bus) Interface
     27           *
     28           */
     29          
     30          #ifdef CONFIG_TOOLCHAIN_IAR
     31          #pragma inline
     32          #endif
     33          static void INLINE_KEYWORD busWriteNegate(void) { IOSET = (lpc210x_reg)0x0200; }
     34          
     35          #ifdef CONFIG_TOOLCHAIN_IAR
     36          #pragma inline
     37          #endif
     38          static void INLINE_KEYWORD busWriteAssert(void) { IOCLR = (lpc210x_reg)0x0200; }
     39          
     40          #ifdef CONFIG_TOOLCHAIN_IAR
     41          #pragma inline
     42          #endif
     43          static void INLINE_KEYWORD busReadNegate(void) { IOSET = (lpc210x_reg)0x0400; }
     44          
     45          #ifdef CONFIG_TOOLCHAIN_IAR
     46          #pragma inline
     47          #endif
     48          static void INLINE_KEYWORD busReadAssert(void) { IOCLR = (lpc210x_reg)0x0400; }
     49          
     50          #ifdef CONFIG_TOOLCHAIN_IAR
     51          #pragma inline
     52          #endif
     53          static void INLINE_KEYWORD busCsNegate(void) { IOSET = (lpc210x_reg)0x0800; }
     54          
     55          #ifdef CONFIG_TOOLCHAIN_IAR
     56          #pragma inline
     57          #endif
     58          static void INLINE_KEYWORD busCsAssert(void) { IOCLR = (lpc210x_reg)0x0800; }
     59          
     60          #ifdef CONFIG_TOOLCHAIN_IAR
     61          #pragma inline
     62          #endif
     63          static void INLINE_KEYWORD busNegateAll(void) { IOSET = (lpc210x_reg)0x0e00; }
                                            ^
Warning[Pe177]: function "busNegateAll" was declared but never referenced
     64          
     65          
     66          // only drive the bus when writing to save power
     67          static void busWrite(unsigned char writeAddr, unsigned char writeData)
     68          {
     69            lpc210x_reg iopinMask;
     70            lpc210x_reg iodirSave;
     71          
     72            iopinMask  = (lpc210x_reg)((writeData << 16) & 0x00ff0000);
     73            iopinMask |= (lpc210x_reg)((writeAddr << 24) & 0x07000000);
     74          
     75            // drive the data and address bits
     76            iodirSave = IODIR;
     77            IODIR = (iodirSave | 0x07ff0000);
     78            IOSET = iopinMask;
     79            IOCLR = ((~iopinMask) & 0x07ff0000);
     80          
     81            ssiDelay(); // let the data settle
     82            ssiDelay(); // let the data settle
     83          
     84          
     85            // assert CS_N, then WE_N
     86            busCsAssert();
     87            ssiDelay();
     88          
     89            busWriteAssert();
     90            ssiDelay();
     91            ssiDelay();
     92          
     93          
     94            busWriteNegate();
     95            ssiDelay(); // let the data settle 
     96            
     97            busCsNegate();
     98            ssiDelay(); // let the data settle 
     99          
    100          
    101            // stop driving the data bits
    102            IODIR = iodirSave;
    103          }
    104          
    105          static unsigned char busRead(unsigned char readAddr)
    106          {
    107            lpc210x_reg iopinMask;
    108            lpc210x_reg iopinState;
    109            lpc210x_reg iodirSave = IODIR;
    110          
    111            // drive address, not data
    112            IODIR = ((iodirSave | 0x07000000) & 0xff00ffff);
    113          
    114            iopinMask = (lpc210x_reg)((readAddr << 24) & 0x07000000);
    115          
    116            // drive the address bits
    117            IOSET = iopinMask;
    118            IOCLR = ((~iopinMask) & 0x07000000);
    119          
    120            ssiDelay();
    121            ssiDelay();
    122          
    123            // assert CS_N, then RD_N
    124            busCsAssert();
    125            ssiDelay();
    126          
    127            busReadAssert();
    128            ssiDelay();
    129            ssiDelay();
    130          
    131            // grab the data
    132            iopinState = IOPIN;
    133          
    134            // negate read
    135            busReadNegate();
    136            ssiDelay(); // let the data settle 
    137            busCsNegate();
    138            ssiDelay(); // let the data settle 
    139          
    140            // restore GPIO direction
    141            IODIR = iodirSave;
    142          
    143            return ((unsigned char)((iopinState >> 16) & 0xff));
    144          }
    145          
    146          void zarlinkIndexedWrite(unsigned short writeIndex, unsigned char writeData)
    147          {
    148            busWrite(0x00, (unsigned char)(writeIndex & 0x00ff));
    149            busWrite(0x01, (unsigned char)((writeIndex >> 8) & 0x00ff));
    150            busWrite(0x02, writeData);
    151            return;
    152          }
    153          
    154          unsigned char zarlinkIndexedRead(unsigned short readIndex)
    155          {
    156            busWrite(0x00, (unsigned char)(readIndex & 0x00ff));
    157            busWrite(0x01, (unsigned char)((readIndex >> 8) & 0x00ff));
    158            return busRead(0x02);
    159          }
    160          
    161          void zarlinkCommandWrite(unsigned char cmdData)
    162          {
    163            busWrite(0x04, cmdData);
    164          }
    165          
    166          unsigned char zarlinkStatusRead(void)
    167          {
    168            return busRead(0x04);
    169          }
    170          
    171          void zarlinkFrameWrite(unsigned short frameData16)
    172          {
    173          #if 0
    174            // big endian
    175            busWrite(0x03, ((frameData16 >> 8) & 0xff));
    176            busWrite(0x03, ( frameData16       & 0xff));
    177          #else
    178            // little endian
    179            busWrite(0x03, ( frameData16       & 0xff));
    180            busWrite(0x03, ((frameData16 >> 8) & 0xff));
    181          #endif
    182          
    183          }
    184          
    185          unsigned short zarlinkFrameRead(void)
    186          {
    187            union {
    188              unsigned short u16;
    189              unsigned char u8[2];
    190              } u;
    191          
    192          #if 0
    193            // big endian
    194            u.u8[1] = busRead(0x03);
    195            u.u8[0] = busRead(0x03);
    196          #else
    197            // little endian
    198            u.u8[0] = busRead(0x03);
    199            u.u8[1] = busRead(0x03);
    200          #endif
    201            return u.u16;
    202          }
    203          
    204          void zarlinkCtrlBuffer1Write(unsigned short ctrlData16)
    205          {
    206          #if 0
    207            // big endian
    208            busWrite(0x06, ((ctrlData16 >> 8) & 0xff));
    209            busWrite(0x06, ( ctrlData16       & 0xff));
    210          #else
    211            // little endian
    212            busWrite(0x06, ( ctrlData16       & 0xff));
    213            busWrite(0x06, ((ctrlData16 >> 8) & 0xff));
    214          #endif
    215          }
    216          
    217          unsigned short zarlinkCtrlBuffer1Read(void)
    218          {
    219            union {
    220              unsigned short u16;
    221              unsigned char u8[2];
    222              } u;
    223          
    224          #if 0
    225            u.u8[1] = busRead(0x06);
    226            u.u8[0] = busRead(0x06);
    227          #else
    228            u.u8[0] = busRead(0x06);
    229            u.u8[1] = busRead(0x06);
    230          #endif
    231          
    232            return u.u16;
    233          }
    234          
    235          unsigned short zarlinkCtrlBuffer2Read(void)
    236          {
    237            union {
    238              unsigned short u16;
    239              unsigned char u8[2];
    240              } u;
    241          
    242          #if 0
    243            u.u8[1] = busRead(0x07);
    244            u.u8[0] = busRead(0x07);
    245          #else
    246            u.u8[0] = busRead(0x07);
    247            u.u8[1] = busRead(0x07);
    248          #endif
    249            
    250            return u.u16;
    251          }
    252          
    253          void zarlinkInterruptWrite(unsigned char intData)
    254          {
    255            busWrite(0x05, (intData & 0x07));
    256          }
    257          
    258          unsigned char zarlinkInterruptRead(void)
    259          {
    260            return busRead(0x05);
    261          }
    262          
    263          #endif
    264          

   Maximum stack usage in bytes:

     Function                CSTACK
     --------                ------
     busCsAssert                 0
     busCsNegate                 0
     busRead                    20
     busReadAssert               0
     busReadNegate               0
     busWrite                   20
     busWriteAssert              0
     busWriteNegate              0
     ssiDelay                    8
     zarlinkCommandWrite         8
     zarlinkCtrlBuffer1Read      8
     zarlinkCtrlBuffer1Write     8
     zarlinkCtrlBuffer2Read      8
     zarlinkFrameRead            8
     zarlinkFrameWrite           8
     zarlinkIndexedRead          8
     zarlinkIndexedWrite        12
     zarlinkInterruptRead        4
     zarlinkInterruptWrite       8
     zarlinkStatusRead           4


   Segment part sizes:

     Function/Label          Bytes
     --------------          -----
     ssiDelay                  64
     busWriteNegate            20
     busWriteAssert            20
     busReadNegate             20
     busReadAssert             20
     busCsNegate               20
     busCsAssert               20
     busWrite                 220
     busRead                  208
     zarlinkIndexedWrite       72
     zarlinkIndexedRead        60
     zarlinkCommandWrite       28
     zarlinkStatusRead         16
     zarlinkFrameWrite         52
     zarlinkFrameRead          44
     zarlinkCtrlBuffer1Write   52
     zarlinkCtrlBuffer1Read    44
     zarlinkCtrlBuffer2Read    44
     zarlinkInterruptWrite     36
     zarlinkInterruptRead      16

 
 1 076 bytes in segment CODE
 
 1 076 bytes of CODE memory

Errors: none
Warnings: 1
