00001
00086
00087 #include <avr32/io.h>
00088 #include <stdint.h>
00089 #include <stdbool.h>
00090 #include "compiler.h"
00091 #include "print_funcs.h"
00092 #include "board.h"
00093 #include "power_clocks_lib.h"
00094 #include "gpio.h"
00095 #include "intc.h"
00096 #include "cycle_counter.h"
00097 #include "flashc.h"
00098
00099 #include "rtouch.h"
00100 #include "rtouch_calibrate.h"
00101
00102 #include "et024006dhu.h"
00103 #include "conf_et024006dhu.h"
00104
00105 #ifdef MAX_SPEED
00106 #if BOARD == EVK1105
00107 #define FCPU_HZ 66000000
00108 #define FPBA_HZ 66000000
00109 #else
00110 #define FCPU_HZ 60000000
00111 #define FPBA_HZ 60000000
00112 #endif
00113 #else
00114 #define FCPU_HZ FOSC0
00115 #define FPBA_HZ FOSC0
00116 #endif
00117
00118 #ifdef MAX_SPEED
00119
00122
00123 static pcl_freq_param_t pcl_freq_param =
00124 {
00125 .cpu_f = FCPU_HZ,
00126 .pba_f = FPBA_HZ,
00127 .osc0_f = FOSC0,
00128 .osc0_startup = OSC0_STARTUP
00129 };
00131
00134 static void init_sys_clocks(void)
00135 {
00136
00137 if (pcl_configure_clocks(&pcl_freq_param) != PASS)
00138 return 42;
00139 }
00140 #endif
00141
00142
00143
00144
00145 void init_board(void)
00146 {
00147
00148 #ifdef MAX_SPEED
00149 init_sys_clocks();
00150 #else
00151 pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
00152 #endif
00153 INTC_init_interrupts();
00154
00155 init_dbg_rs232(FPBA_HZ);
00156
00157
00158 gpio_set_gpio_pin(LED0_GPIO);
00159 gpio_set_gpio_pin(LED1_GPIO);
00160 gpio_set_gpio_pin(LED2_GPIO);
00161 gpio_set_gpio_pin(LED3_GPIO);
00162
00163 et024006_Init(FCPU_HZ, FCPU_HZ);
00164 gpio_set_gpio_pin(ET024006DHU_BL_PIN);
00165 et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE);
00166 }
00167
00168
00169
00170
00171
00172 void event_handler(rtouch_event_t const *event)
00173 {
00174
00175 switch(event->type) {
00176 case RTOUCH_MOVE:
00177
00178 et024006_DrawPixel(event->panelX, event->panelY, BLACK);
00179 break;
00180 case RTOUCH_PRESS:
00181
00182 et024006_DrawPixel(event->panelX, event->panelY, BLACK);
00183 break;
00184 default:
00185 break;
00186 }
00187 }
00188
00189
00190
00191
00192
00193
00194 int main(void)
00195 {
00196
00197 init_board();
00198 print_dbg("Resistive touch demo\r\n");
00199
00200 rtouch_init();
00201 rtouch_enable();
00202 rtouch_set_event_handler(event_handler);
00203
00204 gpio_clr_gpio_pin(LED0_GPIO);
00205
00206
00207 while(rtouch_calibrate())
00208 ;
00209
00210
00211 gpio_set_gpio_pin(LED0_GPIO);
00212
00213 while(true)
00214 {
00215 }
00216 }