日韩欧美自拍在线观看-欧美精品在线看片一区二区-高清性视频一区二区播放-欧美日韩女优制服另类-国产精品久久久久久av蜜臀-成人在线黄色av网站-肥臀熟妇一区二区三区-亚洲视频在线播放老色-在线成人激情自拍视频

登錄 免費注冊 首頁 | 行業(yè)黑名單 | 幫助
維庫電子市場網(wǎng)
技術交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術 | 電源技術 | 測控之家 | EMC技術 | ARM技術 | EDA技術 | PCB技術 | 嵌入式系統(tǒng)
驅動編程 | 集成電路 | 器件替換 | 模擬技術 | 新手園地 | 單 片 機 | DSP技術 | MCU技術 | IC 設計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

請問各位大俠 這用的是哪中編譯器

作者:dudongdao 欄目:單片機
請問各位大俠 這用的是哪中編譯器
/*! \file mmc.c \brief MultiMedia and SD FLASH Card Interface. */
//*****************************************************************************
//
// File NAME    : 'mmc.c'
// Title        : MultiMedia and SD FLASH Card Interface
// Author        : Pascal Stang - COPYRIGHT (C) 2004
// Created        : 2004.09.22
// Revised        : 2004.09.22
// Version        : 0.1
// Target MCU    : ATMEL AVR Series
// Editor Tabs    : 4
//
// NOTE: This code is currently below version 1.0, and therefore is considered
// to be lacking in some functionality or documentation, or may not be fully
// tested.  Nonetheless, you can expect most functions to work.
//
// This code is distributed under the GNU Public License
//        which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************

//----- Include Files ---------------------------------------------------------
#include <avr/io.h>            // include I/O definitions (PORT names, pin names, etc)
#include <avr/signal.h>        // include "signal" names (interrupt names)
#include <avr/interrupt.h>    // include interrupt supPORT

#include "GLOBAL.h"        // include our GLOBAL settings
#include "spi.h"        // include spi bus supPORT

#include "rprintf.h"

#include "mmc.h"

// include project-specific HARDWARE configuration
#include "mmcconf.h"

// GLOBAL variables

// Functions

void mmcInit(void)
{
    // initialize SPI interface
    spiInit();
    // release chip SELECT
    sbi(MMC_CS_DDR, MMC_CS_PIN);
    sbi(MMC_CS_PORT,MMC_CS_PIN);
}

u08 mmcReset(void)
{
    u08 retry;
    u08 r1=0;

    retry = 0;
    do
    {
        // send DUMMY bytes with CS high before accessing
        spiTransferByte(0xFF);
        spiTransferByte(0xFF);
        spiTransferByte(0xFF);
        spiTransferByte(0xFF);
        // resetting card, go to SPI mode
        r1 = mmcSendCommand(MMC_GO_IDLE_STATE, 0);
        rprintf("MMC_GO_IDLE_STATE: R1=0x%x\r\n", r1);
        // do retry counter
        retry++;
        if(retry>10) return -1;
    } while(r1 != 0x01);

    // TODO: check card parameters for voltage compliance
    // before issuing initialize command

    retry = 0;
    do
    {
        // initializing card for operation
        r1 = mmcSendCommand(MMC_SEND_OP_COND, 0);
        rprintf("MMC_SEND_OP_COND: R1=0x%x\r\n", r1);
        // do retry counter
        retry++;
        if(retry>100) return -1;
    } while(r1);
        
    // turn off CRC checking to simplify communication
    r1 = mmcSendCommand(MMC_CRC_ON_OFF, 0);
    rprintf("MMC_CRC_ON_OFF: R1=0x%x\r\n", r1);

    // set block length to 512 bytes
    r1 = mmcSendCommand(MMC_SET_BLOCKLEN, 512);
    rprintf("MMC_SET_BLOCKLEN: R1=0x%x\r\n", r1);

    // return success
    return 0;
}

u08 mmcSendCommand(u08 cmd, u32 arg)
{
    u08 r1;

    // assert chip SELECT
    cbi(MMC_CS_PORT,MMC_CS_PIN);
    // issue the command
    r1 = mmcCommand(cmd, arg);
    // release chip SELECT
    sbi(MMC_CS_PORT,MMC_CS_PIN);

    return r1;
}

u08 mmcRead(u32 sector, u08* buffer)
{
    u08 r1;
    u16 i;

    // assert chip SELECT
    cbi(MMC_CS_PORT,MMC_CS_PIN);
    // issue command
    r1 = mmcCommand(MMC_READ_SINGLE_BLOCK, sector<<9);
    rprintf("MMC Read Block R1=0x%x\r\n", r1);
    // check for valid response
    if(r1 != 0x00)
        return r1;
    // wait for block start
    while(spiTransferByte(0xFF) != MMC_STARTBLOCK_READ);
    // read in data
    for(i=0; i<0x200; i++)
    {
        *buffer++ = spiTransferByte(0xFF);
    }
    // read 16-bit CRC
    spiTransferByte(0xFF);
    spiTransferByte(0xFF);
    // release chip SELECT
    sbi(MMC_CS_PORT,MMC_CS_PIN);
    // return success
    return 0;
}

u08 mmcWrite(u32 sector, u08* buffer)
{
    u08 r1;
    u16 i;

    // assert chip SELECT
    cbi(MMC_CS_PORT,MMC_CS_PIN);
    // issue command
    r1 = mmcCommand(MMC_WRITE_BLOCK, sector<<9);
    rprintf("MMC Write Block R1=0x%x\r\n", r1);
    // check for valid response
    if(r1 != 0x00)
        return r1;
    // send DUMMY
    spiTransferByte(0xFF);
    // send data start token
    spiTransferByte(MMC_STARTBLOCK_WRITE);
    // write data
    for(i=0; i<0x200; i++)
    {
        spiTransferByte(*buffer++);
    }
    // write 16-bit CRC (DUMMY values)
    spiTransferByte(0xFF);
    spiTransferByte(0xFF);
    // read data response token
    r1
2樓: >>參與討論
hanyafeng
不象ICCAVR
 
3樓: >>參與討論
zsmbj
一看就是winavr啦!
 
4樓: >>參與討論
mxh0506
從包含的頭文件上看是GCC
 
5樓: >>參與討論
dudongdao
請問這一句是什么意思呢
rprintf("MMC_GO_IDLE_STATE: R1=0x%x\r\n", r1);

6樓: >>參與討論
computer00
rprintf,一看就知道是個輸出語句。例如發(fā)送到串口什么的
 
參與討論
昵稱:
討論內(nèi)容:
 
 
相關帖子
mega48的看門狗中斷是SIG(SIG_WDT)嗎?
硬件電路設計高手快進!
光耦
初學avr gcc 調試出現(xiàn)問題請教
有一組位數(shù)據(jù)要做奇偶校驗,不知道有沒有硬件支持奇偶檢驗操作
免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進入


Copyright © 1998-2006 www.hbjingang.com 浙ICP證030469號