⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cf_example.c

📁 含t h r e a d x,u c o s 的b s p
💻 C
字号:
/***********************************************************************
 * $Workfile:   cf_example.c  $
 * $Revision:   1.1  $
 * $Author:   WellsK  $
 * $Date:   Apr 15 2004 14:31:10  $
 *
 * Project: CF driver example
 *
 * Description:
 *     A simple CF driver example.
 *
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a404/bsps/sdk7a404/examples/cf_polled/cf_example.c-arc  $
 * 
 *    Rev 1.1   Apr 15 2004 14:31:10   WellsK
 * Updated example as per changes to the CF driver.
 * 
 *    Rev 1.0   Jul 18 2003 11:46:58   WellsK
 * Initial revision.
 * 
 *
 ***********************************************************************
 * SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 * OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 * AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES, 
 * SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY 
 * FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A 
 * SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
 * FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 * COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *     CAMAS, WA
 **********************************************************************/

#include "abl_types.h"
#include "sdk7a404_cf_driver.h"

/* CF device handle */
STATIC INT_32 cfdev;

/***********************************************************************
 *
 * Function: c_entry
 *
 * Purpose: CF example
 *
 * Processing:
 *     This example opens the CF interface and reads the first 64
 *     sectors from a CF card device.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: Always returns 1
 *
 * Notes:
 *     Since this program has no real output, it is best single stepped
 *     through to examine the data obtained from the CF device.
 *
 **********************************************************************/
int c_entry(void)
{
    INT_32 lp;
    char data[512];
    CF_BLOCKS_T cfba;

    /* Open CF */
    if ((cfdev = cf_open((UNS_8 *) CF_BASE, 0)) == 0x00000000)
    {
        return 0;
    }

    /* Read 64 sectors from the CF card */
    for (lp = 0; lp < 64; lp++)
    {
        /* Issue read command */
        cfba.sector = lp;
        cfba.num_blocks = 1;
        cf_ioctl(cfdev, CF_READ_BLOCKS, (INT_32) &cfba);

        /* Wait for CF device to go 'unbusy' */
        while (cf_ioctl(cfdev, CF_GET_STATUS, CF_CARD_BUSY) == 1);

        /* Read data */
        cf_read(cfdev, data, 512);
    }    

    /* Close CF */
    cf_close(cfdev);

    return 1;
}

#ifndef __GNUC__
/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int main(void)
{
    return c_entry();
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -