📄 main.c
字号:
/*****************************************************************************
File name: main.c
Description: The main module for the Circuit Cellar FATLIB sample program.
This code assumes that the MMC/SD card is hooked up to an MSP430F449 as
per the schematic in the article.
******************************************************************************
Change Log
Date By Whom Change
--------------+-------------------+-------------------------------------------
Jan-03-2005 William Hue Created.
******************************************************************************/
#include <string.h>
#include "fatlib.h"
// Local prototypes:
static void cpu_init(void);
static void lcd_print(char *string);
// Functions:
int main(void)
{
signed int stringSize;
signed char handle;
char stringBuf[100];
cpu_init(); // Initialise the CPU clocks, etc.
eint(); // Enable global interrupts (if required).
fat_initialize(); // Initialise the FAT library.
handle = fat_openRead("hello.txt");
if (handle >= 0)
{
stringSize = fat_read(handle, stringBuf, 99);
stringBuf[stringSize] = '\0';
lcd_print(stringBuf);
fat_close(handle);
}
handle = fat_openWrite("goodbye.txt");
if (handle >= 0)
{
strcpy(stringBuf, "Goodbye World!");
stringSize = strlen(stringBuf);
fat_write(handle,stringBuf, stringSize);
fat_flush(); // Optional.
fat_close(handle);
}
while (1)
{
// Stay here.
}
}
/*****************************************************************************
Name: cpu_init
Parameters: none
Returns: nothing
Description: This method initializes the MSP430 chip.
*****************************************************************************/
static void cpu_init(void)
{
// Stop watchdog timer
WDTCTL = WDTPW + WDTHOLD;
//set up system clocks
SCFQCTL = 108; // No modulation; DCO = 2x(108+1) x 32768 = 7.143424Mhz
SCFI0 |= FLLD0 | FN_3; // 7MHz nominal DCO; divide DCO by 2 in FLL
FLL_CTL0 = DCOPLUS | XCAP18PF; // Give us 2x freq.; set load capacitance for xtal
FLL_CTL1 = 0x20; // set the DCO as source for MCLK and SMCLK; turn off xtal2
}
static void lcd_print(char *string)
{
// Implement as appropriate.
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -