Advertisement
deisner

IAR-EW 8051 Optimize Issue

Jun 3rd, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. /**
  2. * LED Blinking Example
  3. *
  4. * Blinks LED on SmartRF04EB board with CC1110EM eval module.
  5. *
  6. * Author: David Eisner
  7. */
  8.  
  9. #include "hal_main.h"
  10. #include "hal_mcu.h"
  11.  
  12.  
  13. /**
  14.  * Blink the LED nBlinks times
  15.  */
  16. static void appLedBlink(uint8 nBlinks)
  17. {
  18.     uint8 i;
  19.        
  20.     i = 0;
  21.     while (TRUE) {
  22.         if (i >= nBlinks)
  23.             return;
  24.         LED1 = LED_ON;
  25.         halWait( 200 );  // ms
  26.         LED1 = LED_OFF;
  27.         halWait( 200 );  // ms
  28.         i++;
  29.     }
  30. }
  31.  
  32.  
  33. #define NCHARS (sizeof(digitChars)/sizeof(char));
  34.  
  35. int main( void )
  36. {
  37.     char digitChars[] = {'2', '3', '5', '7'};
  38.     int di = 0;
  39.     char c;
  40.     uint8 nBlink;
  41.    
  42.     INIT_LED1();
  43.  
  44.     while (TRUE) {
  45.         c = digitChars[di];
  46.  
  47.         if (c >= '0' && c <= '9')
  48.             nBlink = c - '0';
  49.         else
  50.             nBlink = 5;      
  51.        
  52.         appLedBlink(nBlink);
  53.         di = (di + 1) % NCHARS;
  54.         halMcuWaitMs(3000);   // wait a few seconds
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement