root/platform/ixus130_sd1400/sub/100a/led.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. busy_wait
  2. led_on
  3. led_off
  4. led_flash2_helper
  5. led_flash2
  6. led_flashx
  7. led_binx
  8. led_dumpx

   1 /* note, this is unused debug code, left in case someone finds it useful*/
   2 #include "led.h"
   3 
   4 long * LED_GREEN = (long*)0xC0220130,
   5      * LED_RED   = (long*)0xC0220134,
   6      * LED_AF    = (long*)0xC0223030;
   7 
   8 void busy_wait(ulong time) {
   9   BUSY_WAIT(time);
  10 }
  11 #undef  BUSY_WAIT
  12 #define BUSY_WAIT busy_wait
  13 
  14 void led_on(long * led) {
  15   LED_ON(led);
  16 }
  17 
  18 void led_off(long * led) {
  19   LED_OFF(led);
  20 }
  21 
  22 void led_flash2_helper() {
  23 #define d (1024*1024*3)
  24   BUSY_WAIT(d);
  25   LED_ON(LED_GREEN);
  26   BUSY_WAIT(d);
  27   LED_ON(LED_RED);
  28   BUSY_WAIT(2*d);
  29   LED_OFF(LED_GREEN);
  30   BUSY_WAIT(d);
  31   LED_OFF(LED_RED);
  32   BUSY_WAIT(d);
  33 #undef d
  34 }
  35 
  36 void __attribute__((naked,noinline)) led_flash2() {
  37   asm volatile(
  38     "push {r0-r11,lr}\n"
  39     "bl   led_flash2_helper\n"
  40     "pop  {r0-r11,pc}\n"
  41     );
  42 }
  43 
  44 void led_flashx(long * led, ulong times, ulong delay) {
  45   LED_FLASHX(led, times, delay);
  46 }
  47 
  48 void led_binx(long val, ulong delay) {
  49   long i = 0;
  50   led_flashx(val & 0x80000000 ? LED_RED : LED_GREEN, 1, delay);
  51   for (i = 1; i < 32; ++i) {
  52     if (i%4 == 0) busy_wait(delay);
  53     if (i%8 == 0) busy_wait(delay);
  54     if (i%16 == 0) busy_wait(delay);
  55     val <<= 1;
  56     led_flashx(val & 0x80000000 ? LED_RED : LED_GREEN, 1, delay);
  57   }
  58   led_flashx(LED_AF, 1, 2*delay);
  59 }
  60 
  61 void led_dumpx(long * mem, ulong len, ulong delay) {
  62   long i = 0;
  63   led_flashx(LED_AF, 1, 2*delay);
  64   for (i = 0; i < len; ++i) {
  65     led_binx(mem[i], delay);
  66   }
  67 }

/* [<][>][^][v][top][bottom][index][help] */