This file manages the USB device mass-storage task.
Definition in file mmi_task.h.
Go to the source code of this file.
Functions | |
void | mmi_task (void) |
Entry point of the MMI task management. | |
void | mmi_task_init (U32 fcpu, U32 fpba) |
This function initializes the hardware/software resources required for the MMI task. |
void mmi_task | ( | void | ) |
Entry point of the MMI task management.
Definition at line 158 of file mmi_task.c.
References avr32_logo, display_box(), display_perf(), MMI_MASS_STORAGE, MMI_MASS_STORAGE_START, mmi_ms_display(), mmi_state, MMI_TOP_MENU, MMI_TOP_MENU_START, ms_activity_timer, ms_clear_timer, ms_cnt_read, ms_cnt_screen, ms_cnt_write, ms_key_logo, MS_N_PROGRESS_BAR, ms_old_cnt_read, ms_old_cnt_write, ms_progress_bar_level, ms_progress_bar_type, perf_read, perf_write, pm_freq_param, TIMER_MS_PROGRESS_BAR_CLEAR, and TIMER_MS_PROGRESS_BAR_UPDATE.
Referenced by main().
00159 { 00160 U32 i; 00161 switch( mmi_state ) 00162 { 00163 case MMI_TOP_MENU_START: 00164 // Draw the background AVR32 logo. 00165 et024006_PutPixmap(avr32_logo, 320, 0, 0, 0, 0, 320, 240); 00166 00167 // Display welcome string. 00168 et024006_PrintString("EVK1104 Demo", (const unsigned char *)&FONT8x8, 110, 220, BLACK, -1); 00169 00170 mmi_state = MMI_TOP_MENU; 00171 break; 00172 00173 case MMI_TOP_MENU: 00174 if( Is_usb_vbus_high() ) 00175 { 00176 mmi_state = MMI_MASS_STORAGE_START; 00177 } 00178 break; 00179 00180 case MMI_MASS_STORAGE_START: 00181 // Draw the background AVR32 logo. 00182 et024006_PutPixmap(avr32_logo, 320, 0, 0, 0, 0, 320, 240); 00183 00184 // Display USB key logo. 00185 et024006_DrawFilledRect(220-1, 20-1, 80+2, 42+2, BLACK ); 00186 et024006_PutPixmap(ms_key_logo, 80, 0, 0, 220, 20, 80, 42); 00187 00188 // Display title. 00189 et024006_PrintString("U-Disk", (const unsigned char *)&FONT6x8, 240, 65, BLACK, -1); 00190 00191 // Display Activity window. 00192 display_box(80, 180, 156, 16, WHITE, BLACK); 00193 00194 // Display performances box. 00195 display_perf(120, 201, TRUE, 0, 0); 00196 00197 ms_old_cnt_read = ms_cnt_read =0; 00198 ms_old_cnt_write = ms_cnt_write =0; 00199 mmi_state = MMI_MASS_STORAGE; 00200 ms_cnt_screen = 0; 00201 for( i=0 ; i<MS_N_PROGRESS_BAR ; i++ ) 00202 { 00203 ms_progress_bar_level[i] = 1; 00204 ms_progress_bar_type[i] = BLACK; 00205 } 00206 mmi_ms_display(); 00207 00208 cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_UPDATE, pm_freq_param.cpu_f), &ms_activity_timer); 00209 cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_CLEAR, pm_freq_param.cpu_f), &ms_clear_timer); 00210 break; 00211 00212 case MMI_MASS_STORAGE: 00213 // Manage progress-bar shading. 00214 // 00215 if( cpu_is_timeout(&ms_clear_timer) ) 00216 { 00217 cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_CLEAR, pm_freq_param.cpu_f), &ms_clear_timer); 00218 mmi_ms_display(); 00219 } 00220 00221 // Manage progress-bar box moving. 00222 // 00223 if( cpu_is_timeout(&ms_activity_timer) ) 00224 { 00225 cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_UPDATE, pm_freq_param.cpu_f), &ms_activity_timer); 00226 if( ms_old_cnt_write != ms_cnt_write ) 00227 { 00228 ms_cnt_screen = (unsigned char)(ms_cnt_screen-1)%MS_N_PROGRESS_BAR; 00229 ms_progress_bar_type[ms_cnt_screen] = RED; 00230 00231 // Compute performances 00232 // 00233 perf_write = (U64)(ms_cnt_write - ms_old_cnt_write)*SD_MMC_SECTOR_SIZE/TIMER_MS_PROGRESS_BAR_UPDATE; 00234 display_perf(120, 201, FALSE, perf_write, RED); 00235 ms_old_cnt_write = ms_cnt_write; 00236 ms_progress_bar_level[ms_cnt_screen] = (perf_write>10000) ? 31 : 00237 (perf_write> 7500) ? 29 : 00238 (perf_write> 5000) ? 27 : 25 ; 00239 } 00240 else if( ms_old_cnt_read != ms_cnt_read ) 00241 { 00242 ms_cnt_screen = (unsigned char)(ms_cnt_screen+1)%MS_N_PROGRESS_BAR; 00243 ms_progress_bar_type[ms_cnt_screen] = BLUE; 00244 00245 // Compute performances 00246 // 00247 perf_read = (U64)(ms_cnt_read - ms_old_cnt_read)*SD_MMC_SECTOR_SIZE/TIMER_MS_PROGRESS_BAR_UPDATE; 00248 display_perf(120, 201, FALSE, perf_read, BLUE); 00249 ms_old_cnt_read = ms_cnt_read; 00250 ms_progress_bar_level[ms_cnt_screen] = (perf_read>10000) ? 31 : 00251 (perf_read> 7500) ? 29 : 00252 (perf_read> 5000) ? 27 : 25 ; 00253 } 00254 else 00255 { 00256 display_perf(120, 201, TRUE, 0, 0); 00257 } 00258 } 00259 00260 // Detect USB unplug. 00261 // 00262 if( Is_usb_vbus_low() ) 00263 { 00264 mmi_state = MMI_TOP_MENU_START; 00265 } 00266 break; 00267 00268 default: 00269 break; 00270 } 00271 00272 }
void mmi_task_init | ( | U32 | fcpu, | |
U32 | fpba | |||
) |
This function initializes the hardware/software resources required for the MMI task.
Definition at line 84 of file mmi_task.c.
References mmi_state, and MMI_TOP_MENU_START.
Referenced by main().
00085 { 00086 // Initialize the LCD. 00087 et024006_Init( cpu_f, cpu_f /*HSB*/); 00088 00089 // Clear the display i.e. make it black 00090 et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK ); 00091 00092 // Set the backlight. 00093 gpio_set_gpio_pin(ET024006DHU_BL_PIN); 00094 00095 mmi_state = MMI_TOP_MENU_START; 00096 }