?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik //*****************************************************************************
2 // File Name : mmctest.c
3 //
4 // Title : example usage of mmc functions
5 // Revision : 1.0
6 // Notes :
7 // Target MCU : Atmel AVR series
8 // Editor Tabs : 4
9 //
10 // Revision History:
11 // When Who Description of change
12 // ----------- ----------- -----------------------
13 // 20-SEP-2004 pstang Created the program
14 //*****************************************************************************
15  
16  
17 //----- Include Files ---------------------------------------------------------
18 #include <avr/io.h> // include I/O definitions (port names, pin names, etc)
19 #include <avr/interrupt.h> // include interrupt support
20  
21 #include "global.h" // include our global settings
22 #include "uart.h" // include uart function library
23 #include "rprintf.h" // include printf function library
24 #include "timer.h" // include timer function library (timing, PWM, etc)
25 #include "vt100.h" // include VT100 terminal commands
26 #include "spi.h" // include SPI interface functions
27 #include "mmc.h" // include MMC card access functions
28 #include "debug.h"
29  
30 void mmcTest(void);
31  
32 //----- Begin Code ------------------------------------------------------------
33 int main(void)
34 {
35 // initialize our libraries
36 // initialize the UART (serial port)
37 uartInit();
38 uartSetBaudRate(115200);
39 // make all rprintf statements use uart for output
40 rprintfInit(uartSendByte);
41 // initialize the timer system
42 timerInit();
43 // initialize vt100 terminal
44 vt100Init();
45  
46 timerPause(100);
47  
48 // print welcome message
49 vt100ClearScreen();
50 vt100SetCursorPos(1,0);
51 rprintfProgStrM("\r\nWelcome to the MMC Test Suite!\r\n");
52  
53 timerPause(1000);
54  
55 mmcTest();
56  
57 return 0;
58 }
59  
60 void mmcTest(void)
61 {
62 u32 sector=0;
63 u08 buffer[0x200];
64 int c;
65  
66 // initialize MMC interface
67 mmcInit();
68  
69 // print new prompt
70 rprintf("\r\ncmd>");
71  
72 // testing loop
73 while(1)
74 {
75 // check for keypress
76 if((c=uartGetByte()) != -1)
77 {
78 switch(c)
79 {
80 case 'i':
81 // initialize card
82 rprintf("\r\nResetting MMC/SD Card\r\n");
83 mmcReset();
84 break;
85 case 'r':
86 // read current sector into buffer
87 rprintf("\r\nRead Sector %d\r\n", sector);
88 mmcRead(sector, buffer);
89 // print buffer contents
90 debugPrintHexTable(0x200, buffer);
91 break;
92 case 'w':
93 // write current sector with data from buffer
94 rprintf("\r\nWrite Sector %d\r\n", sector);
95 mmcWrite(sector, buffer);
96 break;
97 // move to new sector
98 case '+': sector++; rprintf("\r\nSector = %d", sector); break;
99 case '-': sector--; rprintf("\r\nSector = %d", sector); break;
100 case '*': sector+=512; rprintf("\r\nSector = %d", sector); break;
101 case '/': sector-=512; rprintf("\r\nSector = %d", sector); break;
102 case '\r':
103 default:
104 break;
105 }
106 // print new prompt
107 rprintf("\r\ncmd>");
108 }
109 }
110  
111 }
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3