This source file includes following definitions.
- shutdown
- led_on
- led_off
- debug_led
- camera_set_led
- get_flash_params_count
1 #include "platform.h"
2 #include "lolevel.h"
3
4 #define LED_PR 0xC02200D4
5
6 void shutdown()
7 {
8 volatile long *p = (void*)LED_PR;
9
10 asm(
11 "MRS R1, CPSR\n"
12 "AND R0, R1, #0x80\n"
13 "ORR R1, R1, #0x80\n"
14 "MSR CPSR_cf, R1\n"
15 :::"r1","r0");
16
17 *p = 0x44;
18
19 while(1);
20 }
21
22
23 #define LED_AF 0xC02200E0
24
25 #define LED_BRIGHTNESS 200
26 #define LED_GREEN 0
27 #define LED_ORANGE 1
28 #define LED_YELLOW 2
29 #define LED_RED 3
30 #define LED_BLUE 4
31 #define LED_AF_BEAM 5
32 #define LED_TIMER 6
33
34 static void led_on(const int led, const int brightness)
35 {
36 if (led < 0 || led > 6 || led == LED_YELLOW) return;
37 static void* addr;
38 if(led == LED_AF_BEAM) {
39 *((long *) LED_AF) = 0x46;
40 } else {
41 addr = led_table + (led * 0x40) + 0x100;
42 _UniqueLedOn(addr,brightness);
43 }
44 }
45
46 static void led_off(const int led)
47 {
48 if (led < 0 || led > 6 || led == LED_YELLOW) return;
49 static void* addr;
50 if(led == LED_AF_BEAM) {
51 *((long *) LED_AF) = 0x44;
52 } else {
53 addr = led_table + (led * 0x40) + 0x100;
54 _UniqueLedOff(addr);
55 }
56 }
57
58 void debug_led(int state)
59 {
60 if (state)
61 led_on(LED_BLUE, LED_BRIGHTNESS);
62 else
63 led_off(LED_BLUE);
64 }
65
66 void camera_set_led(int led, int state, int bright)
67 {
68 if (state) {
69 if (bright > LED_BRIGHTNESS) bright = LED_BRIGHTNESS;
70 if (led == LED_YELLOW) {
71 led_on(LED_GREEN, bright);
72 led_on(LED_ORANGE, bright);
73 } else {
74 led_on(led, bright);
75 }
76 } else {
77 if (led == LED_YELLOW) {
78 led_off(LED_GREEN);
79 led_off(LED_ORANGE);
80 } else {
81 led_off(led);
82 }
83 }
84 }
85
86 int get_flash_params_count(void){
87 return 111;
88 }