mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
pios sdcard, try to open a file
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@104 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
1cafc86aaa
commit
a6c9041f55
@ -29,23 +29,38 @@
|
||||
/* Project Includes */
|
||||
#include "pios.h"
|
||||
|
||||
/* Private Function Prototypes */
|
||||
/* File system object for each logical drive */
|
||||
FATFS Fatfs[_DRIVES];
|
||||
|
||||
/* Create struct for logfile */
|
||||
FIL logfile;
|
||||
|
||||
/**
|
||||
* Initializes all system peripherals
|
||||
* Initialises SDCard
|
||||
*/
|
||||
void PIOS_SDCARD_Init(void)
|
||||
{
|
||||
/* File system object for each logical drive */
|
||||
static FATFS Fatfs[_DRIVES];
|
||||
int result;
|
||||
|
||||
/* Initialize FatFS disk */
|
||||
/* Initialise FatFS disk */
|
||||
if(f_mount(0, &Fatfs[0]) != FR_OK) {
|
||||
/* Failed to mount MicroSD filesystem, flash LED1 forever */
|
||||
/* Failed to setup MicroSD memory structure, flash LED1 forever */
|
||||
while(1) {
|
||||
for(int i = 0; i < 100000; i++);
|
||||
PIOS_LED_Toggle(LED1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Try to Open Logging file */
|
||||
if ( f_open(&logfile, LOG_FILENAME, FA_CREATE_ALWAYS | FA_WRITE ) != FR_OK ) {
|
||||
/* Failed to mount MicroSD or create file, flash LED1 forever */
|
||||
while(1) {
|
||||
for(int i = 0; i < 100000; i++);
|
||||
PIOS_LED_Toggle(LED1);
|
||||
}
|
||||
} else {
|
||||
result = f_puts("Hello\n", &logfile );
|
||||
if ( result != EOF ) { result = f_puts("pios rocks!\n", &logfile ); }
|
||||
f_close( &logfile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,17 @@
|
||||
#ifndef PIOS_CONFIG_H
|
||||
#define PIOS_CONFIG_H
|
||||
|
||||
|
||||
/* Compile Time Macros */
|
||||
|
||||
/* Defaults for Logging */
|
||||
#define LOG_FILENAME "pios.log"
|
||||
|
||||
|
||||
/* Defaults for MinIni */
|
||||
|
||||
#define SYS_INI_FILE system.ini
|
||||
|
||||
/* COM Module */
|
||||
#define GPS_BAUDRATE 19200
|
||||
#define TELEM_BAUDRATE 19200
|
||||
|
Loading…
Reference in New Issue
Block a user