Skip to content
This repository
Browse code

[grifo,wiki] fix software power off

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information...
commit be8e6806744921c9d565dea0454b59621fc0a7c8 1 parent aefa62e
Christopher Hall hxw authored
12 samo-lib/grifo/src/button.c
@@ -61,15 +61,17 @@ void Button_initialise(void)
61 61
62 62 REG_KINTSEL_SPPK01 = 0x04; // use P60..P62
63 63
64   - REG_INT_PP01L = 0x06; // P0 prority (for power button)
  64 + REG_INT_PP23L |= 0x60; // P03 prority (for power button)
65 65
66   - REG_PINTSEL_SPT03 = 0x00; // select P03 interrupt (the power button
  66 + REG_PINTSEL_SPT03 = 0x00; // select P03 interrupt (the power button)
67 67
68   - REG_PINTPOL_SPP07 = SPPT3; // P03 active high
  68 + REG_PINTPOL_SPP07 &= ~SPPT3; // P03 active low
69 69
70   - REG_PINTEL_SEPT07 = SEPT3; // P03 edge trigered
  70 + REG_PINTEL_SEPT07 |= SEPT3; // P03 edge trigered
71 71
72   - REG_INT_EK01_EP03 = EK0 | EP3; // enable KINT0 and Port0
  72 +
  73 + REG_INT_FK01_FP03 = FK0 | FK1 | FP3; // clear all flags
  74 + REG_INT_EK01_EP03 = EK0 | EP3; // enable KINT0 and P03
73 75
74 76 Vector_set(VECTOR_Port_input_interrupt_3, Button_PowerInterrupt);
75 77 Vector_set(VECTOR_Key_input_interrupt_0, Button_KeyInterrupt);
31 samo-lib/grifo/src/vector.c
@@ -109,6 +109,37 @@ void Vector_initialise(void)
109 109 (void)Vector_set(VECTOR_Software_exception_2, panic_Software_exception_2);
110 110 (void)Vector_set(VECTOR_Software_exception_3, panic_Software_exception_3);
111 111
  112 +
  113 + // set all interrupt controller registers to defined state
  114 + REG_INT_PI2S = 0;
  115 + REG_INT_EI2S = 0;
  116 +
  117 + REG_INT_EK01_EP03 = 0;
  118 + REG_INT_EP47_ERTC_EAD = 0;
  119 + REG_INT_EP815 = 0;
  120 +
  121 + REG_INT_PP01L = 0;
  122 + REG_INT_PP23L = 0;
  123 + REG_INT_PP45L = 0;
  124 + REG_INT_PP67L = 0;
  125 + REG_INT_PP89L = 0;
  126 + REG_INT_PP1011L = 0;
  127 + REG_INT_PP1213L = 0;
  128 + REG_INT_PP1415L = 0;
  129 +
  130 + REG_PINTSEL_SPT03 = 0;
  131 + REG_PINTSEL_SPT47 = 0;
  132 + REG_PINTSEL_SPT811 = 0;
  133 + REG_PINTSEL_SPT1215 = 0;
  134 +
  135 + REG_PINTPOL_SPP07 = ~0; // all 1s
  136 + REG_PINTPOL_SPP815 = ~0; // all 1s
  137 +
  138 + REG_PINTEL_SEPT07 = ~0; // all 1s
  139 + REG_PINTEL_SEPT815 = ~0; // all 1s
  140 +
  141 + REG_INT_FK01_FP03 = ~0; // clear all flags (1=>reset)
  142 +
112 143 Interrupt_enable(state);
113 144 }
114 145 }
7 wiki/wikilib.c
@@ -468,10 +468,9 @@ static void handle_button_release(button_t keycode)
468 468 keyboard_key_reset_invert(KEYBOARD_RESET_INVERT_NOW, 0); // reset invert immediately
469 469 mode = keyboard_get_mode();
470 470 if (keycode == BUTTON_POWER) {
471   - if (history_list_save(HISTORY_SAVE_POWER_OFF))
472   - {
473   - delay_us(200000);
474   - }
  471 + history_list_save(HISTORY_SAVE_POWER_OFF);
  472 + delay_us(250000);
  473 + power_off();
475 474 } else if (keycode == BUTTON_SEARCH) {
476 475 article_buf_pointer = NULL;
477 476 /* back to search */

0 comments on commit be8e680

Please sign in to comment.
Something went wrong with that request. Please try again.