##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.11A/W32               20/Jul/2004  18:58:48 #
# Copyright 1999-2004 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  arm                                                  #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  C:\medusa\watchdog.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\watchdog.c      #
#    List file       =  C:\medusa\Debug\List\watchdog.lst                    #
#    Object file     =  C:\medusa\Debug\Obj\watchdog.r79                     #
#                                                                            #
#                                                                            #
##############################################################################

C:\medusa\watchdog.c
      1          #include "archinc.h"
      2          #include "eventq.h"
      3          #include "watchdog.h"
      4          #include "cli.h"
      5          
      6          #define WDEN    0x01
      7          #define WDRESET 0x02
      8          #define WDTOF   0x04
      9          #define WDINT   0x08
     10          
     11          // TODO: implement real watchdog functionality by using timer or eventq
     12          
     13          static void handleEvent(void);
     14          
     15          /* ISR declaration */
     16          DECLARE_ISR(watchdogIsr);
     17          
     18          #ifdef CONFIG_TOOLCHAIN_IAR
     19          #pragma inline
     20          #endif
     21          static INLINE_KEYWORD void watchdogReset(void)
     22          {
     23            // do watchdog feed sequence with interrupts disabled
     24            IRQ_DISABLE();
     25            WDFEED = (lpc210x_reg)0xAA;
     26            WDFEED = (lpc210x_reg)0x55;
     27            IRQ_ENABLE();
     28          }
     29          
     30          void watchdogKick(void)
     31          {
     32            eventqPut(WATCHDOG_KICK);
     33          }
     34          
     35          ISR_FUNCTION(watchdogIsr)
     36          {
     37          }
     38          
     39          static int resetHandler(int argc, char * argv[], int flags)
     40          {
     41            watchdogReset();
     42            while(1); // wait for reset
     43            return 0; // should never get here
                   ^
Warning[Pe111]: statement is unreachable

  ISR_FUNCTION(watchdogIsr)
  ^
"C:\medusa\watchdog.c",35  Warning[Pe177]: function "watchdogIsr" was declared
          but never referenced
     44          }
     45          
     46          static void handleEvent(void)
     47          {
     48            watchdogReset();
     49          }
     50          
     51          int watchdogInit(void) 
     52          {
     53            cliRegisterCommand("reset", resetHandler, "reset - resets the processor via watchdog");
     54          
     55            // enable us to kick the 'dog
     56            eventqRegisterHandler(WATCHDOG_KICK, handleEvent);
     57          
     58            // initialize watchdog counter to 1/2 max value
     59            WDTC  = (lpc210x_reg)0x80000000;
     60          
     61            // set mode to reset
     62            WDMOD = (lpc210x_reg)(WDEN | WDRESET);
     63          
     64            // enable watchdog timer!
     65            watchdogReset();
     66          
     67            return 0;
     68          }

   Maximum stack usage in bytes:

     Function      CSTACK CSTACK IRQSTACK
     --------      ------ ------ --------
     handleEvent       4      0        0
     resetHandler     16      0        0
     watchdogInit      4      0        0
     watchdogIsr       0      0        0
     watchdogKick      4      0        0
     watchdogReset     4      0        0


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     watchdogReset                    40
     watchdogKick                     16
     watchdogIsr                      56
     resetHandler                     24
     handleEvent                      12
     watchdogInit                     84
     ?<Constant "reset">               8
     ?<Constant "reset - resets the pr...">
                                      44
      Others                          60

 
 292 bytes in segment CODE
  52 bytes in segment DATA_C
 
 232 bytes of CODE  memory (+ 60 bytes shared)
  52 bytes of CONST memory

Errors: none
Warnings: 2
