00001
00077 #include "string.h"
00078 #include "board.h"
00079 #include "sdramc.h"
00080 #include "intc.h"
00081 #include "gpio.h"
00082 #include "print_funcs.h"
00083 #include "usart.h"
00084 #include "et024006dhu.h"
00085 #include "power_clocks_lib.h"
00086 #include "delay.h"
00087 #include "jpeg_decoder.h"
00088 #include "jpegfile.h"
00089
00090
00093
00094 #if BOARD==EVK1104
00095 # define EXAMPLE_TC_CHANNEL_PIN AVR32_TC0_A0_0_0_PIN
00096 # define EXAMPLE_TC_CHANNEL_FUNCTION AVR32_TC0_A0_0_0_FUNCTION
00097 #elif BOARD==EVK1105
00098 #endif
00100
00101
00102
00103 const U8 * stream_jpeg_src_ptr;
00104 U16 stream_src_size;
00105
00106 pcl_freq_param_t pcl_freq_param=
00107 {
00108 .cpu_f = 60000000
00109 , .pba_f = 60000000
00110 , .osc0_f = FOSC0
00111 , .osc0_startup = OSC0_STARTUP
00112 };
00113
00114 #if __GNUC__ && __AVR32__
00115 int _init_startup(void)
00116 #elif __ICCAVR32__
00117 int __low_level_init(void)
00118 #endif
00119 {
00120
00121 Enable_global_exception();
00122
00123
00124 INTC_init_interrupts();
00125
00126
00127 #ifndef AVR32_PM_VERSION_RESETVALUE // UC3A, UC3A3, UC3B parts.
00128 pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);
00129 #else // Implementation for UC3C, UC3L parts.
00130
00131 scif_configure_osc_crystalmode(SCIF_OSC0, FOSC0);
00132 scif_enable_osc(SCIF_OSC0, OSC0_STARTUP, true);
00133 pm_set_mclk_source(PM_CLK_SRC_OSC0);
00134 #endif
00135
00136
00137 sdramc_init(66000000);
00138
00139
00140
00141
00142
00143
00144 return 1;
00145 }
00146
00147 #if BOARD == EVK1105
00148 #include "pwm.h"
00149 avr32_pwm_channel_t pwm_channel6 = {
00150
00151
00152
00153
00154
00155
00156
00157 .cdty = 0,
00158 .cprd = 100
00159 };
00160
00161 static void tft_bl_init(void)
00162 {
00163
00164 pwm_opt_t opt = {
00165 .diva = 0,
00166 .divb = 0,
00167 .prea = 0,
00168 .preb = 0
00169 };
00170
00171
00172
00173
00174
00175
00176
00177 pwm_init(&opt);
00178 pwm_channel6.CMR.calg = PWM_MODE_LEFT_ALIGNED;
00179 pwm_channel6.CMR.cpol = PWM_POLARITY_HIGH;
00180 pwm_channel6.CMR.cpd = PWM_UPDATE_DUTY;
00181 pwm_channel6.CMR.cpre = AVR32_PWM_CMR_CPRE_MCK_DIV_2;
00182
00183 pwm_channel_init(6, &pwm_channel6);
00184 pwm_start_channels(AVR32_PWM_ENA_CHID6_MASK);
00185
00186 }
00187 #endif
00188
00189
00190
00191
00192 int main(void)
00193 {
00194 et024006_color_t const *picture_ptr;
00195
00196
00197
00198 pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
00199
00200
00201
00202 delay_init(pcl_freq_param.cpu_f);
00203
00204 init_dbg_rs232(pcl_freq_param.pba_f);
00205
00206 et024006_Init( FOSC0, FOSC0 );
00207
00208
00209
00210 #if BOARD == EVK1105
00211
00212
00213
00214 tft_bl_init();
00215
00216 while(pwm_channel6.cdty < pwm_channel6.cprd)
00217 {
00218 pwm_channel6.cdty++;
00219 pwm_channel6.cupd = pwm_channel6.cdty;
00220
00221 pwm_async_update_channel(AVR32_PWM_ENA_CHID6, &pwm_channel6);
00222 delay_ms(10);
00223 }
00224 #elif BOARD == EVK1104 || BOARD == UC3C_EK
00225 gpio_set_gpio_pin(ET024006DHU_BL_PIN);
00226 #endif
00227
00228
00229 et024006_DrawFilledRect(0,0,ET024006_WIDTH,ET024006_HEIGHT,0x2458 );
00230
00231 print_dbg("\x1B[2J\x1B[HDecoding JPEG image...\n");
00232
00233 if (!jpeg_lib_init())
00234 {
00235 print_dbg("\n\r Decoder Initialization failed");
00236 while (1);
00237 }
00238
00239 stream_jpeg_src_ptr = jpegdata;
00240 stream_src_size = sizeof jpegdata/sizeof jpegdata[0];
00241
00242
00243 U16 width;
00244 U16 height;
00245
00246 while(1)
00247 {
00248 width= 320;
00249 height= 240;
00250 picture_ptr = (et024006_color_t const *)jpeg_lib_decode_ex(0, &width, &height);
00251 et024006_PutPixmap( picture_ptr, 320, 0, 0, 0, 0, 320, 240 );
00252 delay_ms(2000);
00253 width= 160;
00254 height= 120;
00255 picture_ptr = (et024006_color_t const *)jpeg_lib_decode_ex(0, &width, &height);
00256 et024006_PutPixmap( picture_ptr, 160, 0, 0, 0, 0, 160,120 );
00257 et024006_PutPixmap( picture_ptr, 160, 0, 0, 160, 0, 160, 120 );
00258 et024006_PutPixmap( picture_ptr, 160, 0, 0, 0, 120, 160, 120 );
00259 et024006_PutPixmap( picture_ptr, 160, 0, 0, 160, 120, 160, 120 );
00260 delay_ms(500);
00261 et024006_PutPixmap( picture_ptr, 160, 0, 0, 80, 60, 160, 120 );
00262 delay_ms(2000);
00263 }
00264 jpeg_lib_exit();
00265 }