📄 mem_task.lst
字号:
if (Card_check_presence() == OK) /* if we detect a medium */
mem_state = MEM_CARD_INIT; /* init this medium */
#endif
C51 COMPILER V7.02a MEM_TASK 09/13/2007 11:53:05 PAGE 6
303 3 break;
304 3 }
305 2
306 2 }
307 1 }
308
309
310 /*F**************************************************************************
311 * NAME: mem_status
312 *----------------------------------------------------------------------------
313 * PARAMS:
314 *
315 * return:
316 * memory status: MEM_BUSY: install in progress
317 * MEM_READY: install done
318 * MEM_FORMAT: install done but memory not formated
319 *----------------------------------------------------------------------------
320 * PURPOSE:
321 * Return memory status
322 *----------------------------------------------------------------------------
323 * EXAMPLE:
324 *----------------------------------------------------------------------------
325 * NOTE:
326 *----------------------------------------------------------------------------
327 * REQUIREMENTS:
328 *****************************************************************************/
329 Byte mem_status (void)
330 {
331 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
343 1
344 1 if ((mem_state == MEM_CHIP_IDLE) ||
345 1 (mem_state == MEM_CARD_IDLE))
346 1 {
347 2 return (MEM_READY);
348 2 }
349 1 if ((mem_state == MEM_CHIP_ERR_FMT) ||
350 1 (mem_state == MEM_CARD_ERR_FMT))
351 1 {
352 2 return (MEM_FORMAT);
353 2 }
354 1 else
355 1 {
356 2 return (MEM_BUSY);
357 2 }
358 1 }
359
360
361 /*F**************************************************************************
362 * NAME: mem_check_card
363 *----------------------------------------------------------------------------
364 * PARAMS:
C51 COMPILER V7.02a MEM_TASK 09/13/2007 11:53:05 PAGE 7
365 *
366 * return:
367 * OK: card present or on-board memory
368 * KO: card not present
369 *----------------------------------------------------------------------------
370 * PURPOSE:
371 * Start card status checking
372 *----------------------------------------------------------------------------
373 * EXAMPLE:
374 *----------------------------------------------------------------------------
375 * NOTE:
376 *----------------------------------------------------------------------------
377 * REQUIREMENTS:
378 *****************************************************************************/
379 bit mem_check_card (void)
380 {
381 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
400 1 return OK;
401 1 #endif
402 1 }
403
404
405 /*F**************************************************************************
406 * NAME: mem_card_select
407 *----------------------------------------------------------------------------
408 * PARAMS:
409 * force: - TRUE: continue selecting MMC1 in case of error
410 * - FALSE: select next device in case of error
411 *
412 * return:
413 *----------------------------------------------------------------------------
414 * PURPOSE:
415 * Mass storage memory selection
416 *----------------------------------------------------------------------------
417 * EXAMPLE:
418 *----------------------------------------------------------------------------
419 * NOTE:
420 * Call from mass storage routines:
421 * - when Test_Unit returns not ready
422 * - when exiting download mode for mounting new FAT
423 *----------------------------------------------------------------------------
424 * REQUIREMENTS:
425 *****************************************************************************/
426 void mem_card_select (bit force)
C51 COMPILER V7.02a MEM_TASK 09/13/2007 11:53:05 PAGE 8
427 {
428 1 #if (MEM_CARD_TYPE != CARD_NONE)
mem_force_mmc = force;
mem_state = MEM_CARD_INIT;
#if CARD_SOCKET_NB == 2
if (Card_get_socket() == MEM_CARD_2)
{
Card_select_next();
}
#endif
#else
439 1 if (force); /* avoid warning message */
440 1 #endif
441 1 }
442
443
444 /*F**************************************************************************
445 * NAME: mem_select_next
446 *----------------------------------------------------------------------------
447 * PARAMS:
448 *
449 * return:
450 *----------------------------------------------------------------------------
451 * PURPOSE:
452 * Select next on-board or card memory
453 *----------------------------------------------------------------------------
454 * EXAMPLE:
455 *----------------------------------------------------------------------------
456 * NOTE:
457 *----------------------------------------------------------------------------
458 * REQUIREMENTS:
459 *****************************************************************************/
460 void mem_select_next (void)
461 {
462 1 switch (mem_state)
463 1 {
464 2 case MEM_CHIP_IDLE:
465 2 case MEM_CHIP_ERR_FMT:
466 2 {
467 3 #if MEM_CARD_TYPE != CARD_NONE
mem_state = MEM_CARD_INIT;
#endif
470 3 break;
471 3 }
472 2 case MEM_CARD_INIT:
473 2 case MEM_CARD_IDLE:
474 2 case MEM_CARD_ERR_FMT:
475 2 {
476 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
{
C51 COMPILER V7.02a MEM_TASK 09/13/2007 11:53:05 PAGE 9
mem_state = MEM_CARD_INIT;
}
Card_select_next(); /* select next card source */
break;
#else
#if MEM_CHIP_TYPE != CHIP_NONE
mem_state = MEM_CHIP_INIT;
#endif
break;
#endif
#endif
500 3 }
501 2 }
502 1 }
503
504
505 /*F**************************************************************************
506 * NAME: mem_select_format
507 *----------------------------------------------------------------------------
508 * PARAMS:
509 *
510 * return:
511 * File system mount status
512 *----------------------------------------------------------------------------
513 * PURPOSE:
514 * Re-mount memory after format or mass storage update
515 *----------------------------------------------------------------------------
516 * EXAMPLE:
517 *----------------------------------------------------------------------------
518 * NOTE:
519 *----------------------------------------------------------------------------
520 * REQUIREMENTS:
521 *****************************************************************************/
522 bit mem_select_format (void)
523 {
524 1 gl_mem_tick = MEM_WRITE_TIME;
525 1
526 1 switch (mem_state)
527 1 {
528 2 case MEM_CHIP_ERR_FMT:
529 2 case MEM_CHIP_IDLE:
530 2 {
531 3 #if (MEM_CHIP_TYPE != CHIP_NONE)
532 3 while (gl_mem_tick != MEM_TIME_OUT)
533 3 {
534 4 if (File_mount() == OK) /* check if format ok */
535 4 {
536 5 mem_state = MEM_CHIP_IDLE;
537 5 return OK;
538 5 }
539 4 }
540 3 #endif
541 3 return KO;
542 3 }
543 2
544 2 case MEM_CARD_ERR_FMT:
545 2 case MEM_CARD_IDLE:
546 2 {
547 3 #if (MEM_CARD_TYPE != CARD_NONE)
while (gl_mem_tick != MEM_TIME_OUT)
{
if (File_mount() == OK) /* check if format ok */
C51 COMPILER V7.02a MEM_TASK 09/13/2007 11:53:05 PAGE 10
{
mem_state = MEM_CARD_IDLE;
return OK;
}
}
#endif
557 3 return KO;
558 3 }
559 2
560 2 default:
561 2 {
562 3 return KO;
563 3 }
564 2 }
565 1 }
566
567
568 /*F**************************************************************************
569 * NAME: mem_load_card
570 *----------------------------------------------------------------------------
571 * PARAMS:
572 *
573 * return:
574 *
575 *----------------------------------------------------------------------------
576 * PURPOSE:
577 * Load a card medium (like Compact disk)
578 *----------------------------------------------------------------------------
579 * EXAMPLE:
580 *----------------------------------------------------------------------------
581 * NOTE:
582 *----------------------------------------------------------------------------
583 * REQUIREMENTS:
584 *****************************************************************************/
585 void mem_load_card(void)
586 {
587 1 #if (MEM_CARD_TYPE != CARD_NONE)
mem_state = MEM_CARD_INIT;
#endif
590 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 143 ----
CONSTANT SIZE = ---- ----
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 + -