📄 mem_task.lst
字号:
#endif
298 3 break;
299 3 }
300 2
301 2 }
302 1 }
C51 COMPILER V7.50 MEM_TASK 09/20/2005 21:47:43 PAGE 6
303
304
305 /*F**************************************************************************
306 * NAME: mem_status
307 *----------------------------------------------------------------------------
308 * PARAMS:
309 *
310 * return:
311 * memory status: MEM_BUSY: install in progress
312 * MEM_READY: install done
313 * MEM_FORMAT: install done but memory not formated
314 *----------------------------------------------------------------------------
315 * PURPOSE:
316 * Return memory status
317 *----------------------------------------------------------------------------
318 * EXAMPLE:
319 *----------------------------------------------------------------------------
320 * NOTE:
321 *----------------------------------------------------------------------------
322 * REQUIREMENTS:
323 *****************************************************************************/
324 Byte mem_status (void)
325 {
326 1 #if (MEM_CARD_TYPE != CARD_NONE)
if ((gl_memory == MEM_CARD) && (mem_state != MEM_CARD_INIT) && (mem_state != MEM_CHIP_INIT))
{ /* don't check card presence when mem_state = CARD_INIT. This can modify init sequence */
if (Card_check_presence() == KO) /* if no card present */
{
return MEM_NO_CARD;
}
}
if (mem_state == MEM_CARD_NO_CARD) /* else if we detect a new medium */
return MEM_BUSY;
#endif
338 1
339 1 if ((mem_state == MEM_CHIP_IDLE) ||
340 1 (mem_state == MEM_CARD_IDLE))
341 1 {
342 2 return (MEM_READY);
343 2 }
344 1 if ((mem_state == MEM_CHIP_ERR_FMT) ||
345 1 (mem_state == MEM_CARD_ERR_FMT))
346 1 {
347 2 return (MEM_FORMAT);
348 2 }
349 1 else
350 1 {
351 2 return (MEM_BUSY);
352 2 }
353 1 }
354
355
356 /*F**************************************************************************
357 * NAME: mem_check_card
358 *----------------------------------------------------------------------------
359 * PARAMS:
360 *
361 * return:
362 * OK: card present or on-board memory
363 * KO: card not present
364 *----------------------------------------------------------------------------
C51 COMPILER V7.50 MEM_TASK 09/20/2005 21:47:43 PAGE 7
365 * PURPOSE:
366 * Start card status checking
367 *----------------------------------------------------------------------------
368 * EXAMPLE:
369 *----------------------------------------------------------------------------
370 * NOTE:
371 *----------------------------------------------------------------------------
372 * REQUIREMENTS:
373 *****************************************************************************/
374 bit mem_check_card (void)
375 {
376 1 #if (MEM_CARD_TYPE != CARD_NONE)
switch (mem_state)
{
case MEM_CARD_IDLE:
case MEM_CARD_ERR_FMT:
#if CARD_SOCKET_NB == 1
if (Card_check_presence() == KO)
mem_state = MEM_CARD_NO_CARD;
#endif
case MEM_CARD_NO_CARD:
{
return (Card_check_presence());
}
default:
{
return OK;
}
}
#else
395 1 return OK;
396 1 #endif
397 1 }
398
399
400 /*F**************************************************************************
401 * NAME: mem_card_select
402 *----------------------------------------------------------------------------
403 * PARAMS:
404 * force: - TRUE: continue selecting MMC1 in case of error
405 * - FALSE: select next device in case of error
406 *
407 * return:
408 *----------------------------------------------------------------------------
409 * PURPOSE:
410 * Mass storage memory selection
411 *----------------------------------------------------------------------------
412 * EXAMPLE:
413 *----------------------------------------------------------------------------
414 * NOTE:
415 * Call from mass storage routines:
416 * - when Test_Unit returns not ready
417 * - when exiting download mode for mounting new FAT
418 *----------------------------------------------------------------------------
419 * REQUIREMENTS:
420 *****************************************************************************/
421 void mem_card_select (bit force)
422 {
423 1 #if (MEM_CARD_TYPE != CARD_NONE)
mem_force_mmc = force;
mem_state = MEM_CARD_INIT;
C51 COMPILER V7.50 MEM_TASK 09/20/2005 21:47:43 PAGE 8
#if CARD_SOCKET_NB == 2
if (Card_get_socket() == MEM_CARD_2)
{
Card_select_next();
}
#endif
#else
434 1 if (force); /* avoid warning message */
435 1 #endif
436 1 }
437
438
439 /*F**************************************************************************
440 * NAME: mem_select_next
441 *----------------------------------------------------------------------------
442 * PARAMS:
443 *
444 * return:
445 *----------------------------------------------------------------------------
446 * PURPOSE:
447 * Select next on-board or card memory
448 *----------------------------------------------------------------------------
449 * EXAMPLE:
450 *----------------------------------------------------------------------------
451 * NOTE:
452 *----------------------------------------------------------------------------
453 * REQUIREMENTS:
454 *****************************************************************************/
455 void mem_select_next (void)
456 {
457 1 switch (mem_state)
458 1 {
459 2 case MEM_CHIP_IDLE:
460 2 case MEM_CHIP_ERR_FMT:
461 2 {
462 3 #if MEM_CARD_TYPE != CARD_NONE
mem_state = MEM_CARD_INIT;
#endif
465 3 break;
466 3 }
467 2 case MEM_CARD_INIT:
468 2 case MEM_CARD_IDLE:
469 2 case MEM_CARD_ERR_FMT:
470 2 {
471 3 #if (MEM_CARD_TYPE != CARD_NONE)
#if CARD_SOCKET_NB == 2
if (Card_get_socket() == MEM_CARD_2)
{
#if MEM_CHIP_TYPE != CHIP_NONE
mem_state = MEM_CHIP_INIT;
#else
mem_state = MEM_CARD_INIT;
#endif
}
else
{
mem_state = MEM_CARD_INIT;
}
Card_select_next(); /* select next card source */
break;
#else
C51 COMPILER V7.50 MEM_TASK 09/20/2005 21:47:43 PAGE 9
#if MEM_CHIP_TYPE != CHIP_NONE
mem_state = MEM_CHIP_INIT;
#endif
break;
#endif
#endif
495 3 }
496 2 }
497 1 }
498
499
500 /*F**************************************************************************
501 * NAME: mem_select_format
502 *----------------------------------------------------------------------------
503 * PARAMS:
504 *
505 * return:
506 * File system mount status
507 *----------------------------------------------------------------------------
508 * PURPOSE:
509 * Re-mount memory after format or mass storage update
510 *----------------------------------------------------------------------------
511 * EXAMPLE:
512 *----------------------------------------------------------------------------
513 * NOTE:
514 *----------------------------------------------------------------------------
515 * REQUIREMENTS:
516 *****************************************************************************/
517 bit mem_select_format (void)
518 {
519 1 gl_mem_tick = MEM_WRITE_TIME;
520 1
521 1 switch (mem_state)
522 1 {
523 2 case MEM_CHIP_ERR_FMT:
524 2 case MEM_CHIP_IDLE:
525 2 {
526 3 #if (MEM_CHIP_TYPE != CHIP_NONE)
527 3 while (gl_mem_tick != MEM_TIME_OUT)
528 3 {
529 4 if (File_mount() == OK) /* check if format ok */
530 4 {
531 5 mem_state = MEM_CHIP_IDLE;
532 5 return OK;
533 5 }
534 4 }
535 3 #endif
536 3 return KO;
537 3 }
538 2
539 2 case MEM_CARD_ERR_FMT:
540 2 case MEM_CARD_IDLE:
541 2 {
542 3 #if (MEM_CARD_TYPE != CARD_NONE)
while (gl_mem_tick != MEM_TIME_OUT)
{
if (File_mount() == OK) /* check if format ok */
{
mem_state = MEM_CARD_IDLE;
return OK;
}
}
C51 COMPILER V7.50 MEM_TASK 09/20/2005 21:47:43 PAGE 10
#endif
552 3 return KO;
553 3 }
554 2
555 2 default:
556 2 {
557 3 return KO;
558 3 }
559 2 }
560 1 }
561
562
563 /*F**************************************************************************
564 * NAME: mem_load_card
565 *----------------------------------------------------------------------------
566 * PARAMS:
567 *
568 * return:
569 *
570 *----------------------------------------------------------------------------
571 * PURPOSE:
572 * Load a card medium (like Compact disk)
573 *----------------------------------------------------------------------------
574 * EXAMPLE:
575 *----------------------------------------------------------------------------
576 * NOTE:
577 *----------------------------------------------------------------------------
578 * REQUIREMENTS:
579 *****************************************************************************/
580 void mem_load_card(void)
581 {
582 1 #if (MEM_CARD_TYPE != CARD_NONE)
mem_state = MEM_CARD_INIT;
#endif
585 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 155 ----
CONSTANT SIZE = 32 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 ----
IDATA SIZE = ---- ----
BIT SIZE = 1 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -