##############################################################################
#                                                                            #
# 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_event.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_event.c      #
#    List file       =  C:\medusa\Debug\List\zl_event.lst                    #
#    Object file     =  C:\medusa\Debug\Obj\zl_event.r79                     #
#                                                                            #
#                                                                            #
##############################################################################

C:\medusa\zl_event.c
      1          #include "archinc.h"
      2          #include "cli.h"
      3          #include "eventq.h"
      4          #include "strutil.h"
      5          #include "zarlink.h"
      6          
      7          #include <stdio.h>
      8          
      9          #ifdef CONFIG_INCLUDE_ZARLINK
     10          
     11          #include <stdlib.h>
     12          
     13          static unsigned int eventCount = 0;
     14          static unsigned int frameRxEventCount = 0;
     15          
     16          static void handleFrameRxEvent(void);
     17          static int eventCmdHandler(int argc, char *argv[], int flags);
     18          
     19          /*
     20           * this module takes care of interrupt handling and dispatches interrupts
     21           * as events for deferred handling. On the Medusa board, the Zarlink
     22           * interrupt is connected to the LPC2106 EINT2 external input pin
     23           */
     24          
     25          DECLARE_ISR(zarlinkIsr);
     26          
     27          int zarlinkEventInit(void)
     28          {
     29            int retStat = -1;
     30            int i;
     31            lpc210x_reg dummy;
     32          
     33            // register a frame rx event handler
     34            eventqRegisterHandler(SWITCH_FRAME_RX, handleFrameRxEvent);
     35          
     36            // clear DEVICE Mode register bit[1] for negative logic irqs 
     37            zarlinkIndexedWrite(0x60a, 0x00);
     38          
     39            // clear the interrupt 
     40            zarlinkInterruptWrite(0x01);
     41          
     42            // delay for things to happen
     43            for(i=0;i<10;i++)
     44              dummy = EXTWAKE;
     45          
     46            // clear the EINT2 latch at the LPC2106
     47            EXTINT = (lpc210x_reg)0x04;
     48          
     49            // allow a Zarlink interrupt to wake up 2106
     50            EXTWAKE = (lpc210x_reg)0x04;
     51          
     52            // connect the interrupt vector
     53            if ((retStat = armvicIntConnect(LPC210X_IRQVEC_EINT2, zarlinkIsr)) != 0)
     54              return retStat;
     55          
     56            // enable the interrupt at the VIC
     57            if ((retStat = armvicIntEnable(LPC210X_IRQVEC_EINT2)) != 0)
     58              return retStat;
     59          
     60            cliRegisterCommand("event", eventCmdHandler, "event - show info on events received from switch");
     61          
     62            return 0;
     63          }
     64          
     65          static void handleFrameRxEvent(void)
     66          {
     67            int bufLen;
     68            char * pOutBuf;
     69          
     70            frameRxEventCount++;
     71          
     72            pOutBuf = clicharGetOutputBuffer(&bufLen);
     73          
     74            sprintf(pOutBuf, "*** frame received [%u]\r\n",frameRxEventCount);
     75            clicharSendOutputBuffer(pOutBuf, bufLen);    
     76          
     77            // TODO: receive frame when buffer pool is implemented
     78          }
     79          
     80          static unsigned char irqReg;
     81          
     82          ISR_FUNCTION(zarlinkIsr)
     83          {
     84            ISR_ENTER()
     85          
     86            eventCount++;
     87          
     88            // handle the event
     89            irqReg = zarlinkInterruptRead();
     90          
     91            // frame received (bit 0)
     92            if ((irqReg & 0x01) == 0x01) {
     93              eventqPut(SWITCH_FRAME_RX);
     94              zarlinkInterruptWrite(0x01);
     95              }
     96          
     97            // clear the EINT2 latch at the LPC2106
     98            EXTINT = (lpc210x_reg)0x04;
     99          
    100            // acknowledge the interrupt at the VIC
    101            VICIrqDone;
    102          
    103            ISR_LEAVE()
    104          }
    105          
    106          static int eventCmdHandler(int argc, char *argv[], int flags)
    107          {
    108            int bufLen;
    109            char * pOutBuf;
    110          
    111            pOutBuf = clicharGetOutputBuffer(&bufLen);
    112          
    113            sprintf(pOutBuf, "%s: [%u] frame RX events\r\n",argv[0],frameRxEventCount);
    114            clicharSendOutputBuffer(pOutBuf, bufLen);    
    115          
    116            return 0;
    117          }
    118          
    119          #endif
    120          

   Maximum stack usage in bytes:

     Function           CSTACK CSTACK IRQSTACK
     --------           ------ ------ --------
     eventCmdHandler       24      0        0
     handleFrameRxEvent    12      0        0
     zarlinkEventInit      16      0        0
     zarlinkIsr             0     20        0


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     eventCount                        4
     frameRxEventCount                 4
     zarlinkEventInit                224
     handleFrameRxEvent               84
     irqReg                            1
     zarlinkIsr                      168
     eventCmdHandler                  84
     ??DataTable4                      4
     ??DataTable5                      4
     ?<Constant "event">               8
     ?<Constant "event - show info on ...">
                                      52
     ?<Constant "*** frame received [%...">
                                      28
     ?<Constant "%s: [%u] frame RX eve...">
                                      28
      Others                         144

 
 700 bytes in segment CODE
 116 bytes in segment DATA_C
   9 bytes in segment DATA_Z
  12 bytes in segment INITTAB
 
 568 bytes of CODE  memory (+ 144 bytes shared)
 116 bytes of CONST memory
   9 bytes of DATA  memory

Errors: none
Warnings: none
