root/platform/ixus900_sd900/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. shutdown
  2. get_flash_params_count
  3. debug_led
  4. camera_set_led
  5. save_rom_log

   1 #include "platform.h"
   2 
   3 /* led addresses, look in function "taskcreate_LEDCon" ROM:FF82F958 (branch to ROM:FF82FEC8)
   4 #define LED_AF    0xC02200C0   // AF Beam (red, frontside)
   5 #define LED_BLUE  0xC02200C4   // led in print/share button (blue, backside)
   6 #define LED_RED   0xC02200C8   // right state led red (bi-state with green, backside)
   7 #define LED_GRN   0xC02200CC   // right state led green (bi-state with red, backside)
   8 #define LED_YLW   0xC02200D0   // left state led (yellow, backside)
   9 #define LED_PWR   0xC02200D8   // power led (green, on top)
  10 */
  11 
  12 void shutdown() {
  13     volatile long *p = (void*)0xc02200a0;
  14     asm(
  15         "MRS     R1, CPSR\n"
  16         "AND     R0, R1, #0x80\n"
  17         "ORR     R1, R1, #0x80\n"
  18         "MSR     CPSR_cf, R1\n"
  19         :::"r1","r0"
  20     );
  21     *p = 0x44;
  22     while(1);
  23 }
  24 
  25 // ROM:FF9B0820 verified that there are 110 entries for FlashParamsTable
  26 int get_flash_params_count(void) {
  27     return 110;
  28 }
  29 
  30 #define LED_PR    0xC02200C4   // (Direct Print Button, Blue Led)
  31 //#define LED_PR    0xC02200D0   // left state led (yellow, backside)
  32 
  33 void debug_led(int state) {
  34     volatile long *p=(void*)LED_PR;
  35     if(state)
  36         p[0]=0x46;
  37     else
  38         p[0]=0x44;
  39 }
  40 
  41 #define LED_BASE  0xC02200C0   // led base address
  42 
  43 void camera_set_led(int led, int state, int bright) {
  44     int leds[] = {12,16,4,8,4,0,4};
  45     if(led < 4 || led > 10 || led == 6) return;
  46     volatile long *p=(void*)LED_BASE + leds[led-4];
  47     if(state)
  48         p[0]=0x46;
  49     else
  50         p[0]=0x44;
  51 }
  52 
  53 #ifdef CAM_CONSOLE_LOG_ENABLED
  54 void save_rom_log() {
  55     asm volatile(
  56         "MOV R0, #0\n"
  57         "MOV R1, #1\n"
  58         "STMDB SP!, {R0, R1, LR}\n"
  59         "MOV R0, SP\n"
  60         "MOV LR, PC\n"   // ToDo: required ?
  61         "BL _GetLogToFile\n"
  62         "LDMIA SP!, {R0, R1, LR}\n"
  63     );
  64 }
  65 #endif

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