#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "global.h"
#include "Xspi.h"
#include "task.h"
#include "MessageQueue.h"
#include "curses.h"
#include "io.h"
#include "cio.h"
#include "utils.h"
#include "Xmmc.h"
#include "ff.h"
#include "mmcconf.h"
Go to the source code of this file.
Functions | |
void | MMCTask (void *arg) __attribute__((noreturn)) |
void | mmcInit (void) |
int | mmcResponse (unsigned char response) |
u08 | mmcReset (void) |
unsigned short | mmcSendStatus (void) |
u08 | mmcSendCommand (u08 cmd, u32 arg) |
u08 | mmcRead (u32 sector, u08 *buffer) |
u08 | mmcWrite (u32 sector, u08 *buffer) |
u08 | mmcCommand (u08 cmd, u32 arg, char *b) |
void | SecDump (int fd, char *b) |
void | MsgMMCReset (void) |
void | MsgMMCReadSector (unsigned long sector) |
void | MsgMMCWriteSector (unsigned long sector, char *b, int n) |
void | MsgMMCSendStatus (void) |
void | MsgMMCWriteTestFile (void) |
Variables | |
MESSAGE_QUEUE * | SDcardMSG |
TCB | Tmmc |
static WINDOW * | mmcW |
Internal command function. Issues a generic MMC command as specified by cmd and arg.
Definition at line 305 of file Xmmc.c.
References XspiTransfer(), and XspiTransferByte().
Referenced by mmcRead(), mmcSendCommand(), mmcSendStatus(), and mmcWrite().
void mmcInit | ( | void | ) |
Initialize AVR<->MMC hardware interface. Prepares hardware for MMC access.
Definition at line 53 of file Xmmc.c.
References ActiveTasks, CreateTask(), Insert(), MMCTask(), MqInit(), and XSPI_CLR_CE.
Read 512-byte sector from card to buffer Returns zero if successful.
Definition at line 219 of file Xmmc.c.
References free, malloc, MMC_READ_SINGLE_BLOCK, MMC_STARTBLOCK_READ, mmcCommand(), wprintw(), XSPI_CLR_CE, XSPI_SET_CE, XspiTransfer(), and XspiTransferByte().
Referenced by disk_read(), and MMCTask().
u08 mmcReset | ( | void | ) |
Initialize the card and prepare it for use. Returns zero if successful.
Definition at line 82 of file Xmmc.c.
References free, malloc, MMC_APP_CMD, MMC_GO_IDLE_STATE, MMC_SEND_OP_COND_A, MMC_SET_BLOCKLEN, mmcResponse(), TimeDelay(), wprintw(), XSPI_CLR_CE, XSPI_SET_CE, XspiTransfer(), and XspiTransferByte().
Referenced by disk_initialize(), and MMCTask().
int mmcResponse | ( | unsigned char | response | ) |
Send card an MMC command. Returns R1 result code.
Definition at line 205 of file Xmmc.c.
References free, malloc, mmcCommand(), XSPI_CLR_CE, and XSPI_SET_CE.
unsigned short mmcSendStatus | ( | void | ) |
Definition at line 187 of file Xmmc.c.
References free, malloc, MMC_SEND_STATUS, mmcCommand(), XSPI_CLR_CE, XSPI_SET_CE, and XspiTransferByte().
Referenced by disk_status(), and MMCTask().
void MMCTask | ( | void * | arg | ) |
Definition at line 361 of file Xmmc.c.
References _open(), _write(), BG, BLUE, DeleteMSG(), f_close(), f_mount(), f_open(), f_sync(), f_write(), FA_CREATE_NEW, FA_WRITE, FG, FSYS, HexDump(), malloc, memcpy(), memset(), MMC_CMD_RDSECTOR, MMC_CMD_RESET, MMC_CMD_STATUS, MMC_CMD_WDSECTOR, MMC_CMD_WRITE_FILE, mmcRead(), mmcReset(), mmcSendStatus(), mmcWrite(), MqGet(), _msg::MsgCmd, newwin(), _msg::Payload, scrollok, SecDump(), sprintf, strlen(), WIN_BOXED, WinSetTitle(), wprintw(), and YELLOW.
Referenced by mmcInit().
Write 512-byte sector from buffer to card Returns zero if successful.
Definition at line 263 of file Xmmc.c.
References free, malloc, MMC_DR_ACCEPT, MMC_DR_MASK, MMC_STARTBLOCK_WRITE, MMC_WRITE_BLOCK, mmcCommand(), wprintw(), XSPI_CLR_CE, XSPI_SET_CE, XspiTransfer(), and XspiTransferByte().
Referenced by disk_write(), and MMCTask().
void MsgMMCReadSector | ( | unsigned long | sector | ) |
Definition at line 459 of file Xmmc.c.
References MMC_CMD_RDSECTOR, MqPut(), _msg::MsgCmd, NewMSG(), and _msg::Payload.
void MsgMMCReset | ( | void | ) |
Definition at line 450 of file Xmmc.c.
References MMC_CMD_RESET, MqPut(), _msg::MsgCmd, and NewMSG().
void MsgMMCSendStatus | ( | void | ) |
Definition at line 487 of file Xmmc.c.
References MMC_CMD_STATUS, MqPut(), _msg::MsgCmd, and NewMSG().
void MsgMMCWriteSector | ( | unsigned long | sector, | |
char * | b, | |||
int | n | |||
) |
Definition at line 471 of file Xmmc.c.
References memcpy(), MMC_CMD_WDSECTOR, MqPut(), _msg::MsgCmd, NewMSG(), and _msg::Payload.
void MsgMMCWriteTestFile | ( | void | ) |
Definition at line 496 of file Xmmc.c.
References MMC_CMD_WRITE_FILE, MqPut(), _msg::MsgCmd, and NewMSG().
void SecDump | ( | int | fd, | |
char * | b | |||
) |
Definition at line 332 of file Xmmc.c.
References _write(), CharToHex(), free, isprint(), malloc, and UnsignedToHex().
Referenced by MMCTask().