00001
00094 #include "compiler.h"
00095 #include "gpio.h"
00096 #include "board.h"
00097
00098
00101
00102 #define GPIO_PIN_EXAMPLE_1 LED0_GPIO
00103 #define GPIO_PIN_EXAMPLE_2 LED1_GPIO
00104 #if BOARD == EVK1100 || BOARD == EVK1101 || BOARD == UC3C_EK
00105 #define GPIO_PIN_EXAMPLE_3 GPIO_PUSH_BUTTON_0
00106 #elif BOARD == EVK1104 || BOARD == STK600_RCUC3L0
00107 #define GPIO_PIN_EXAMPLE_3 GPIO_PUSH_BUTTON_SW2
00108 #elif BOARD == EVK1105
00109 #define GPIO_PIN_EXAMPLE_3 QT1081_TOUCH_SENSOR_ENTER
00110 #elif BOARD == UC3L_EK
00111 #define GPIO_PIN_EXAMPLE_3 GPIO_WAKE_BUTTON
00112 #endif
00113
00114 #if !defined(GPIO_PIN_EXAMPLE_1) || \
00115 !defined(GPIO_PIN_EXAMPLE_2) || \
00116 !defined(GPIO_PIN_EXAMPLE_3)
00117 #error The pin configuration to use in this example is missing.
00118 #endif
00120
00121
00124 int main(void)
00125 {
00126 U32 state = 0;
00127 U32 i;
00128
00129 while (1)
00130 {
00131 switch (state)
00132 {
00133 case 0:
00134
00135 gpio_clr_gpio_pin(GPIO_PIN_EXAMPLE_1);
00136 state++;
00137 break;
00138
00139 case 1:
00140 gpio_set_gpio_pin(GPIO_PIN_EXAMPLE_1);
00141 state++;
00142 break;
00143
00144 case 2:
00145
00146 gpio_tgl_gpio_pin(GPIO_PIN_EXAMPLE_1);
00147 state++;
00148 break;
00149
00150 case 3:
00151 default:
00152 gpio_tgl_gpio_pin(GPIO_PIN_EXAMPLE_1);
00153 state = 0;
00154 break;
00155 }
00156
00157
00158 for (i = 0; i < 1000; i += 4)
00159 {
00160 if (gpio_get_pin_value(GPIO_PIN_EXAMPLE_3) == 0)
00161 gpio_clr_gpio_pin(GPIO_PIN_EXAMPLE_2);
00162 else
00163 gpio_set_gpio_pin(GPIO_PIN_EXAMPLE_2);
00164 }
00165
00166 }
00167 }