projects
/
my-code
/
arm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
basic interrupt approach succeded, buttons (extint) working perfectly from
[my-code/arm.git]
/
betty
/
betty.c
diff --git
a/betty/betty.c
b/betty/betty.c
index
2cd287f
..
bac6614
100644
(file)
--- a/
betty/betty.c
+++ b/
betty/betty.c
@@
-16,6
+16,7
@@
const char announce[]="betty - live from flash at 0x80000000! ;)\r\n";
const char d1_txt[]="betty";
const char d2_txt[]="- alphablend -";
u8 contrast;
const char d1_txt[]="betty";
const char d2_txt[]="- alphablend -";
u8 contrast;
+t_button button;
/*
* functions
/*
* functions
@@
-36,9
+37,11
@@
void display_string_page(u8 x,u8 p,u8 *s,u8 f,u8 o,u8 sp) {
}
}
}
}
-void input_event(void) {
+void
__attribute__ ((interrupt("IRQ")))
input_event(void) {
- /* button test! */
+ u8 noret,tries;
+
+ /* button scan */
if(button_get_event(&button)) {
switch(button.key[0]) {
case BUTTON_POWER:
if(button_get_event(&button)) {
switch(button.key[0]) {
case BUTTON_POWER:
@@
-108,6
+111,20
@@
void input_event(void) {
break;
}
}
break;
}
}
+
+ /* resume the interrupt at button release */
+ noret=1;
+ while(noret) {
+ tries=0xff;
+ noret=1;
+ while(tries--) {
+ noret=IOPIN0&(1<<30)?0:1;
+ if(noret)
+ break;
+ }
+ }
+ interrupt_ack();
+ interrupt_ext_ir_set(INTERRUPT_EXT3);
}
/*
}
/*
@@
-117,7
+134,6
@@
void input_event(void) {
int main() {
/* variables */
int main() {
/* variables */
- t_button button;
/* system init */
pll_init();
/* system init */
pll_init();
@@
-139,7
+155,7
@@
int main() {
/* button init */
button.mode=BUTTON_INT;
button_init(&button);
/* button init */
button.mode=BUTTON_INT;
button_init(&button);
- button_set_retries(&button,0);
+ button_set_retries(&button,
3
0);
/* flash init */
flash_init();
/* flash init */
flash_init();
@@
-153,7
+169,9
@@
int main() {
interrupt_ext_ir_config(INTERRUPT_EXT3,INTERRUPT_EXT_NOWAKE,
INTERRUPT_EXT_MODE_EDGE,
INTERRUPT_EXT_POLAR_LOW);
interrupt_ext_ir_config(INTERRUPT_EXT3,INTERRUPT_EXT_NOWAKE,
INTERRUPT_EXT_MODE_EDGE,
INTERRUPT_EXT_POLAR_LOW);
- interrupt_enable(INTERRUPT_EINT3,INTERRUPT_MODE_VIRQ,0,input_event);
+ interrupt_ext_ir_set(INTERRUPT_EXT3);
+ interrupt_enable(INTERRUPT_EINT3,INTERRUPT_MODE_VIRQ,
+ 0,(u32)input_event);
/*
* start it ...
/*
* start it ...
@@
-167,6
+185,8
@@
int main() {
while(1) {
while(1) {
+ pause(0xffffff);
+ uart0_send_string((char *)announce);
}
return 0;
}
return 0;