Changeset 456
- Timestamp:
- 02/19/07 01:32:09 (2 years ago)
- Files:
-
- trunk/hal/lpc2106-cmucam3/cc3.c (modified) (1 diff)
- trunk/hal/lpc2106-cmucam3/cc3_hal.c (modified) (2 diffs)
- trunk/hal/lpc2106-cmucam3/cc3_pin_defines.h (modified) (1 diff)
- trunk/hal/lpc2106-cmucam3/interrupt.c (modified) (5 diffs)
- trunk/hal/lpc2106-cmucam3/interrupt.h (modified) (1 diff)
- trunk/hal/virtual-cam/cc3.c (modified) (1 diff)
- trunk/include/cc3.h (modified) (1 diff)
- trunk/projects/cmucam2/cmucam2.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/hal/lpc2106-cmucam3/cc3.c
r455 r456 742 742 bool cc3_button_get_state (void) 743 743 { 744 bool result = !(REG (GPIO_IOPIN) & _CC3_BUTTON); 744 if (!_cc3_button_trigger) { 745 // button has not been pressed 746 return false; 747 } 748 749 // otherwise, it has been pressed, but it's in GPIO mode 750 return !(REG (GPIO_IOPIN) & _CC3_BUTTON); 751 } 752 753 bool cc3_button_get_and_reset_trigger (void) 754 { 755 bool result = _cc3_button_trigger; 756 _cc3_button_trigger = false; 757 758 // reset interrupt 759 if (result) { 760 enable_button_interrupt(); 761 } 762 745 763 return result; 746 764 } trunk/hal/lpc2106-cmucam3/cc3_hal.c
r455 r456 19 19 #include "cc3_hal.h" 20 20 #include "cc3_pin_defines.h" 21 #include "interrupt.h" 21 22 #include "serial.h" 22 23 #include <stdio.h> … … 59 60 60 61 //REG(PCB_PINSEL1) = 0x1; // External interrupt 0 62 63 enable_button_interrupt (); 61 64 62 65 // Setup timer0 to count by milliseconds starting from 0 trunk/hal/lpc2106-cmucam3/cc3_pin_defines.h
r372 r456 69 69 #define _CC3_LED_2 _CC3_SERVO_3 70 70 71 // button 71 72 #define _CC3_BUTTON 0x00004000 73 #define _CC3_BUTTON_PINSEL_MASK 0x30000000 74 #define _CC3_BUTTON_PINSEL 0x20000000 72 75 73 76 // SPI trunk/hal/lpc2106-cmucam3/interrupt.c
r444 r456 28 28 #include "cc3_hal.h" 29 29 30 volatile bool _cc3_button_trigger; 31 30 32 void disable_ext_interrupt (void) 31 33 { 32 // Enable bit 14, which is the external interrupt 0...34 // Disable bit 14, which is the external interrupt 0... 33 35 REG (VICIntEnClr) = 0x4000; 34 REG (PCB_PINSEL1) = 0x0; // Switch from EINT0 mode to GPIO 35 36 // Switch from EINT0 mode to GPIO 37 REG (PCB_PINSEL1) = 0x0; 38 // Clear the interrupt 39 REG (SYSCON_EXTINT) = 0x1; 36 40 } 37 41 … … 39 43 void enable_ext_interrupt (void) 40 44 { 41 REG (SYSCON_EXTINT) = 0x1; 45 // Switch from GPIO to EINT0 mode 46 REG (PCB_PINSEL1) = 0x1; 42 47 // Enable bit 14, which is the external interrupt 0... 43 48 REG (VICIntEnable) = 0x4000; 44 // Clear the interrupt status flag...45 REG (PCB_PINSEL1) = 0x1; // Switch from GPIO to EIN0 mode46 49 } 47 50 48 51 void enable_servo_interrupt (void) 49 52 { 50 //uart0_write("Enable Servo Int\r\n" );53 //uart0_write("Enable Servo Int\r\n" ); 51 54 REG (VICIntEnable) = 0x20; 52 53 55 } 54 56 … … 56 58 { 57 59 REG (VICIntEnClr) = 0x20; 58 59 60 } 60 61 62 void enable_button_interrupt (void) 63 { 64 //uart0_write("button int enable\r\n"); 65 // pin select 66 REG(PCB_PINSEL0) = (REG(PCB_PINSEL0) & 67 ~_CC3_BUTTON_PINSEL_MASK) | _CC3_BUTTON_PINSEL; 68 69 // vic bit 15: EINT1 70 REG (VICIntEnable) = 0x8000; 71 } 72 73 void disable_button_interrupt (void) 74 { 75 //uart0_write("button int disable\r\n"); 76 77 // vic bit 15: EINT1 78 REG (VICIntEnClr) = 0x8000; 79 80 // pin select back to GPIO 81 REG(PCB_PINSEL0) = (REG(PCB_PINSEL0) & ~_CC3_BUTTON_PINSEL_MASK); 82 83 // clear the interrupt 84 REG (SYSCON_EXTINT) = 0x2; 85 } 61 86 62 87 void interrupt (void) … … 64 89 //asm volatile ( "msr cpsr_c,0x1F" ); // MODE_SYS 65 90 91 //uart0_write_hex(REG(VICRawIntr)); 66 92 //printf( "Got interrupt: %d\r\n",REG(VICRawIntr) ); 67 93 if (REG (VICRawIntr) & 0x4000) { 94 //uart0_write("vref interrupt\r\n"); 68 95 // Triggered on VREF telling when a frame is complete. 69 96 // Simply disable the FIFO once the frame has been captured. … … 73 100 _cc3_pixbuf_write_rewind (); 74 101 disable_ext_interrupt (); 102 } 103 104 if (REG (VICRawIntr) & 0x8000) { 105 // button press 106 //uart0_write("button int\r\n"); 107 _cc3_button_trigger = true; 108 disable_button_interrupt (); 75 109 } 76 110 trunk/hal/lpc2106-cmucam3/interrupt.h
r302 r456 20 20 #define INTERRUPT_H 21 21 22 #include <stdbool.h> 23 24 extern volatile bool _cc3_button_trigger; 25 22 26 void enable_ext_interrupt (void); 23 27 void disable_ext_interrupt (void); 24 28 void enable_servo_interrupt (void); 25 29 void disable_servo_interrupt (void); 30 void enable_button_interrupt (void); 31 void disable_button_interrupt (void); 32 26 33 void interrupt (void); 27 34 trunk/hal/virtual-cam/cc3.c
r455 r456 760 760 } 761 761 762 bool cc3_button_get_and_reset_trigger (void) 763 { 764 return 1; 765 } 766 762 767 void cc3_filesystem_init (void) 763 768 { trunk/include/cc3.h
r455 r456 415 415 bool cc3_button_get_state (void); 416 416 417 /** 418 * Get and reset the trigger functionality of the button. 419 * 420 * @return \a true if the button has been pressed since the 421 * last time this function was called. 422 */ 423 bool cc3_button_get_and_reset_trigger (void); 417 424 418 425 /** trunk/projects/cmucam2/cmucam2.c
r455 r456 74 74 PACKET_FILTER, 75 75 CONF_HISTOGRAM, 76 GET_BUTTON, 76 77 CMUCAM2_CMD_END // Must be last entry so array sizes are correct 77 78 } cmucam2_command_t; … … 134 135 cmucam2_cmds[GET_INPUT] = "GI"; 135 136 cmucam2_cmds[SET_INPUT] = "SI"; // new for cmucam3 136 // GB get button137 cmucam2_cmds[GET_BUTTON] = "GB"; 137 138 cmucam2_cmds[LED_0] = "L0"; 138 139 // L1 LED control … … 774 775 printf("%d\r", cc3_gpio_get_servo_position(arg_list[0])); 775 776 break; 776 777 777 778 case GET_INPUT: 778 779 if (n != 0) { … … 797 798 cc3_gpio_set_mode (arg_list[0], CC3_GPIO_MODE_INPUT); 798 799 800 break; 801 802 case GET_BUTTON: 803 if (n != 0) { 804 error = true; 805 break; 806 } 807 print_ACK (); 808 if (cc3_button_get_and_reset_trigger()) { 809 printf("1\r"); 810 } else { 811 printf("0\r"); 812 } 799 813 break; 800 814
