亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? main.c

?? MMC/SD操作
?? C
字號(hào):
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <avr/pgmspace.h>#include "fat16.h"#include "fat16_config.h"#include "partition.h"#include "sd_raw.h"#include "uart.h"/** * \mainpage MMC/SD card example application * * This project is a small test application which implements read and write * support for MMC and SD cards. * * It includes * - low-level \link sd_raw MMC read/write routines \endlink * - \link partition partition table support \endlink * - a simple \link fat16 FAT16 read/write implementation \endlink * * \section circuit The circuit * The curcuit board is a self-made and self-soldered board consisting of a single * copper layer and standard DIL components, except of the MMC/SD card connector. * * The connector is soldered to the bottom side of the board. It has a simple * eject button which, when a card is inserted, needs some space beyond the connector * itself. As an additional feature the connector has two electrical switches * to detect wether a card is inserted and wether this card is write-protected. *  * I used two microcontrollers during development, the Atmel ATmega8 with 8kBytes * of flash, and its pin-compatible alternative, the ATmega168 with 16kBytes flash. * The first one is the one I started with, but when I implemented FAT16 write * support, I ran out of flash space and switched to the ATmega168. *  * \section pictures Pictures * \image html pic01.jpg "The circuit board used to implement and test this application." * \image html pic02.jpg "The MMC/SD card connector on the soldering side of the circuit board." * * \section software The software * The software is written in pure standard ANSI-C. Sure, it might not be the * smallest or the fastest one, but I think it is quite flexible. * * I implemented a simple command prompt which is accessible via the UART. With commands * similiar to Unix you can browse different directories, read and write files, * create new ones and delete them again, and browse different directories. * * \htmlonly * <p> * The following table shows some typical code sizes in bytes: * </p> * * <table border="1" cellpadding="2"> *     <tr> *         <th>layer</th> *         <th>code size</th> *         <th>static RAM usage</th> *     </tr> *     <tr> *         <td>MMC/SD (read-only)</td> *         <td align="right">1002</td> *         <td align="right">0</td> *     </tr> *     <tr> *         <td>MMC/SD (read-write)</td> *         <td align="right">1178</td> *         <td align="right">516</td> *     </tr> *     <tr> *         <td>Partition</td> *         <td align="right">394</td> *         <td align="right">0</td> *     </tr> *     <tr> *         <td>FAT16 (read-only)</td> *         <td align="right">3316</td> *         <td align="right">0</td> *     </tr> *     <tr> *         <td>FAT16 (read-write)</td> *         <td align="right">6158</td> *         <td align="right">0</td> *     </tr> * </table> * * <p> * The static RAM in the read-write case is used for buffering memory card * access. Without this buffer, implementation would have been much more complicated. * </p> *  * <p> * Please note that the numbers above do not include the C library functions * used, e.g. malloc()/free() and some string functions. These will raise the * numbers somewhat if they are not already used in other program parts. * </p> *  * <p> * When opening a partition, filesystem, file or directory, a little amount * of dynamic RAM is used, as listed in the following table. * </p> * * <table border="1" cellpadding="2"> *     <tr> *         <th>descriptor</th> *         <th>dynamic RAM</th> *     </tr> *     <tr> *         <td>partition</td> *         <td align="right">15</td> *     </tr> *     <tr> *         <td>filesystem</td> *         <td align="right">26</td> *     </tr> *     <tr> *         <td>file</td> *         <td align="right">49</td> *     </tr> *     <tr> *         <td>directory</td> *         <td align="right">47</td> *     </tr> * </table> *  * \endhtmlonly * * \section adaptation Adapting the software to your needs * The only hardware dependent part is the communication * layer talking to the memory card. The other parts like partition table and FAT16 * support are completely independent, you could use them even for managing * Compact Flash cards or standard ATAPI hard disks. * * By changing the MCU* variables in the Makefile, you can use other Atmel * microcontrollers or different clock speeds. You might also want to disable * write support completely by changing the corresponding defines in the * sd_raw_config.h and fat16_config.h files. *  * \section bugs Bugs or comments? * If you have comments or found a bug in the software - there might be some * of them - you may contact me per mail at feedback@roland-riegel.de. * * \section acknowledgements Acknowledgements * Thanks go to Ulrich Radig, who explained on his homepage how to interface * MMC cards to the Atmel microcontroller (http://www.ulrichradig.de/). * I adapted his work for my circuit. Although this is a very simple * solution, I had no problems using it. *  * \section copyright Copyright 2006 by Roland Riegel * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 2 as published by * the Free Software Foundation (http://www.gnu.org/copyleft/gpl.html). */uint8_t read_line(char* buffer, uint8_t buffer_length);uint8_t find_file_in_dir(struct fat16_fs_struct* fs, struct fat16_dir_struct* dd, const char* name, struct fat16_dir_entry_struct* dir_entry);struct fat16_file_struct* open_file_in_dir(struct fat16_fs_struct* fs, struct fat16_dir_struct* dd, const char* name); int main(){    /* setup uart */    uart_init();    /* setup stdio */    uart_connect_stdio();    /* setup sd card slot */    if(!sd_raw_init())        return 1;    /* open first partition */    struct partition_struct* partition = partition_open(sd_raw_read,                                                        sd_raw_read_interval,                                                        sd_raw_write,                                                        0);    if(!partition)        return 1;    /* open file system */    struct fat16_fs_struct* fs = fat16_open(partition);    if(!fs)        return 1;    /* open root directory */    struct fat16_dir_entry_struct directory;    fat16_get_dir_entry_of_path(fs, "/", &directory);    struct fat16_dir_struct* dd = fat16_open_dir(fs, &directory);    if(!dd)        return 1;        /* provide a simple shell */    char buffer[32];    while(1)    {        /* print prompt */        uart_putc('>');        uart_putc(' ');        /* read command */        char* command = buffer;        uint8_t command_len = read_line(command, sizeof(buffer));        if(command_len < 1)            continue;        /* execute command */        if(strncmp("cd ", command, 3) == 0)        {            command += 3;            if(command[0] == '\0')                continue;            /* change directory */            struct fat16_dir_entry_struct subdir_entry;            if(find_file_in_dir(fs, dd, command, &subdir_entry))            {                struct fat16_dir_struct* dd_new = fat16_open_dir(fs, &subdir_entry);                if(dd_new)                {                    fat16_close_dir(dd);                    dd = dd_new;                    continue;                }            }            printf_P(PSTR("directory not found: %s\n"), command);        }        else if(strcmp("ls", command) == 0)        {            /* print directory listing */            struct fat16_dir_entry_struct dir_entry;            while(fat16_read_dir(dd, &dir_entry))            {                printf_P(PSTR("%10lu  %s%c\n"),                         dir_entry.file_size,                         dir_entry.long_name,                         (dir_entry.attributes & FAT16_ATTRIB_DIR) ? '/' : ' '                        );            }        }        else if(strncmp("cat ", command, 4) == 0)        {            command += 4;            if(command[0] == '\0')                continue;                        /* search file in current directory and open it */            struct fat16_file_struct* fd = open_file_in_dir(fs, dd, command);            if(!fd)            {                printf_P(PSTR("error opening %s\n"), command);                continue;            }            /* print file contents */            uint8_t buffer[8];            uint32_t offset = 0;            while(fat16_read_file(fd, buffer, sizeof(buffer)) > 0)            {                printf_P(PSTR("%08lx: %02x %02x %02x %02x %02x %02x %02x %02x\n"),                         offset,                         buffer[0],                         buffer[1],                         buffer[2],                         buffer[3],                         buffer[4],                         buffer[5],                         buffer[6],                         buffer[7]                        );                offset += 8;            }            fat16_close_file(fd);        }#if FAT16_WRITE_SUPPORT        else if(strncmp("rm ", command, 3) == 0)        {            command += 3;            if(command[0] == '\0')                continue;                        struct fat16_dir_entry_struct file_entry;            if(find_file_in_dir(fs, dd, command, &file_entry))            {                if(fat16_delete_file(fs, &file_entry))                    continue;            }            printf_P(PSTR("error deleting file: %s\n"), command);        }        else if(strncmp("touch ", command, 6) == 0)        {            command += 6;            if(command[0] == '\0')                continue;            struct fat16_dir_entry_struct file_entry;            if(!fat16_create_file(dd, command, &file_entry))                printf_P(PSTR("error creating file: %s\n"), command);        }        else if(strncmp("write ", command, 6) == 0)        {            command += 6;            if(command[0] == '\0')                continue;            char* offset_value = command;            while(*offset_value != ' ' && *offset_value != '\0')                ++offset_value;            if(*offset_value == ' ')                *offset_value++ = '\0';            else                continue;            /* search file in current directory and open it */            struct fat16_file_struct* fd = open_file_in_dir(fs, dd, command);            if(!fd)            {                printf_P(PSTR("error opening %s\n"), command);                continue;            }            int32_t offset = strtol(offset_value, 0, 0);            if(!fat16_seek_file(fd, &offset, FAT16_SEEK_SET))            {                printf_P(PSTR("error seeking on %s\n"), command);                fat16_close_file(fd);                continue;            }            /* read text from the shell and write it to the file */            uint8_t data_len;            while((data_len = read_line(buffer, sizeof(buffer))))            {                if(fat16_write_file(fd, (uint8_t*) buffer, data_len) != data_len)                {                    printf_P(PSTR("error writing to file\n"));                    break;                }            }            fat16_close_file(fd);        }#endif        else        {            printf_P(PSTR("unknown command: %s\n"), command);        }    }    /* close file system */    fat16_close(fs);    /* close partition */    partition_close(partition);        return 0;}uint8_t read_line(char* buffer, uint8_t buffer_length){    memset(buffer, 0, buffer_length);    uint8_t read_length = 0;    while(read_length < buffer_length - 1)    {        uint8_t c = uart_getc();        uart_putc(c);        if(c != '\n')        {            buffer[read_length] = c;        }        else        {            buffer[read_length] = '\0';            break;        }                ++read_length;    }    return read_length;}uint8_t find_file_in_dir(struct fat16_fs_struct* fs, struct fat16_dir_struct* dd, const char* name, struct fat16_dir_entry_struct* dir_entry){    while(fat16_read_dir(dd, dir_entry))    {        if(strcmp(dir_entry->long_name, name) == 0)        {            fat16_reset_dir(dd);            return 1;        }    }    return 0;}struct fat16_file_struct* open_file_in_dir(struct fat16_fs_struct* fs, struct fat16_dir_struct* dd, const char* name){    struct fat16_dir_entry_struct file_entry;    if(!find_file_in_dir(fs, dd, name, &file_entry))        return 0;    return fat16_open_file(fs, &file_entry);}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区三区高清免费看看| 国产精品久久久久影院| 欧美在线短视频| 99久久777色| aa级大片欧美| 91在线国内视频| 色88888久久久久久影院野外| 色婷婷综合五月| 欧美日韩在线直播| 欧美日韩一区二区在线观看 | 91麻豆免费看片| 婷婷综合五月天| 国产精品欧美久久久久无广告| 久久亚洲精华国产精华液 | 欧美一二三区在线观看| 日韩精品一区二区三区四区| 久久一留热品黄| 日本一区二区综合亚洲| 亚洲欧美精品午睡沙发| 亚洲国产综合人成综合网站| 日本麻豆一区二区三区视频| 激情图区综合网| 国产99精品在线观看| 91在线精品一区二区三区| 91同城在线观看| 在线播放视频一区| 久久综合久久综合九色| 国产精品嫩草影院com| 亚洲精品欧美综合四区| 视频精品一区二区| 国产精品自在在线| 国产精品免费aⅴ片在线观看| 亚洲国产成人在线| 亚洲欧洲日韩综合一区二区| 亚洲视频 欧洲视频| 午夜激情一区二区三区| 国产一区二区三区精品视频| av一本久道久久综合久久鬼色| 欧美中文字幕一区二区三区| 日韩欧美第一区| 一区二区三区在线高清| 日韩国产欧美在线播放| 国产91精品露脸国语对白| 一本大道久久精品懂色aⅴ| 欧美一区二区精美| 亚洲日本免费电影| 美女免费视频一区二区| 国产一区二区三区四区五区入口 | 亚洲国产精品一区二区久久恐怖片| 日本在线播放一区二区三区| 午夜久久福利影院| 另类调教123区| 在线一区二区视频| 久久人人97超碰com| 亚洲与欧洲av电影| 国产一区二区三区| 欧美在线影院一区二区| 久久伊人蜜桃av一区二区| 亚洲自拍另类综合| 成人性色生活片| 日韩欧美亚洲国产精品字幕久久久| 最新高清无码专区| 精品影视av免费| 欧美日韩一区中文字幕| 国产精品三级av在线播放| 日产欧产美韩系列久久99| 91捆绑美女网站| 国产片一区二区| 麻豆传媒一区二区三区| 欧美在线短视频| 国产精品二三区| 国产精品一区二区你懂的| 欧美日韩一级片在线观看| 中文字幕综合网| 成人一级片在线观看| 26uuu亚洲综合色| 日韩中文字幕一区二区三区| 色综合一区二区三区| 亚洲国产精品精华液2区45| 久久99国产精品久久99| 欧美性极品少妇| 美女视频一区二区三区| 日本精品一区二区三区高清 | 亚洲第一狼人社区| 99久久综合国产精品| 2021久久国产精品不只是精品| 亚洲电影一区二区三区| 色哟哟一区二区在线观看 | 福利电影一区二区三区| 欧美va日韩va| 久久成人免费日本黄色| 6080国产精品一区二区| 亚洲第一主播视频| 欧美精品亚洲一区二区在线播放| 一区二区三区蜜桃网| 成人爱爱电影网址| 国产精品天天摸av网| caoporen国产精品视频| 国产午夜亚洲精品羞羞网站| 国产一区二区三区四区五区入口| 26uuu国产在线精品一区二区| 老司机精品视频线观看86| 欧美一区二区私人影院日本| 亚洲国产中文字幕| 在线播放视频一区| 亚洲婷婷国产精品电影人久久| 国产在线视频不卡二| 日韩欧美一区二区视频| 日本欧洲一区二区| 欧美一级午夜免费电影| 另类小说视频一区二区| 欧美第一区第二区| 国产一区视频网站| 久久精品一区二区三区不卡| 国产成人综合精品三级| 国产欧美一区在线| 91丨九色丨尤物| 亚洲激情在线激情| 精品视频一区 二区 三区| 日韩综合一区二区| 欧美不卡一区二区三区| 国产成人av电影在线播放| 日韩理论片网站| 欧美日韩一区二区在线观看视频 | 成人精品一区二区三区中文字幕 | 国产成人午夜高潮毛片| 亚洲国产电影在线观看| 91久久香蕉国产日韩欧美9色| 亚洲成在人线在线播放| 91精品国产综合久久婷婷香蕉 | 日本一区二区三区久久久久久久久不 | 成人欧美一区二区三区| 91天堂素人约啪| 日日夜夜免费精品| 国产欧美日韩视频一区二区| 一本色道久久加勒比精品| 极品少妇一区二区| 中文字幕一区二区5566日韩| 欧美色图天堂网| 国产在线精品一区二区不卡了| 国产精品美女一区二区| 欧美视频自拍偷拍| 国产精品99久久久久| 亚洲自拍偷拍欧美| 91精品国产91久久久久久一区二区 | 欧美人伦禁忌dvd放荡欲情| 亚洲自拍另类综合| 免费三级欧美电影| 婷婷综合另类小说色区| 香蕉成人伊视频在线观看| 亚洲午夜激情av| 国产酒店精品激情| 欧美欧美欧美欧美| 欧美日韩不卡一区二区| 国产精品欧美一区二区三区| 亚洲一区影音先锋| 日韩高清一区二区| 国产成人久久精品77777最新版本| 99国产麻豆精品| 亚洲一区二区三区四区不卡| 久久精品国产精品亚洲精品| 在线视频你懂得一区| 中文字幕日本不卡| 国产乱色国产精品免费视频| 91精品在线免费观看| 日韩精品电影在线观看| 欧美视频中文字幕| 亚洲成人久久影院| 欧美又粗又大又爽| 一区二区三区在线视频免费| 99riav久久精品riav| 国产精品女同一区二区三区| 国产精品18久久久久久vr| 久久亚洲一区二区三区四区| 国产福利一区二区三区视频| 亚洲日本免费电影| 国产盗摄一区二区| 一本大道久久a久久综合婷婷| 久久精品一区二区三区四区| 国产ts人妖一区二区| 国产精品不卡一区| 欧美高清视频在线高清观看mv色露露十八 | 亚洲国产一区二区视频| 欧美性色欧美a在线播放| 天堂av在线一区| 久久嫩草精品久久久精品一| 国产成人精品一区二区三区四区| 日韩美一区二区三区| 成人少妇影院yyyy| 一区二区三区在线观看欧美| 精品国产伦一区二区三区观看体验 | 国产精品正在播放| 中文字幕人成不卡一区| 欧美三级电影精品| 国产成人精品免费网站| 久久免费的精品国产v∧| 高清国产一区二区三区| 亚洲电影中文字幕在线观看| 国产精品灌醉下药二区| 日韩一区二区精品在线观看|