1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Split the SDCard functions away in to their own file. Just for readability & clean code. Only init function for now but there will be logging functions added.

init function will also try to access a file on the SDCard, this forces a real mount and will get real errors which we can handle. 

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@100 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
dankers 2009-12-22 19:32:47 +00:00 committed by dankers
parent 6003def85d
commit 2a3f572147
5 changed files with 88 additions and 11 deletions

View File

@ -0,0 +1,51 @@
/**
******************************************************************************
*
* @file pios_sdcard.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2009.
* @brief Sets up basic system hardware, functions are called from Main.
* @see The GNU Public License (GPL) Version 3
* @defgroup PIOS_SDCARD SDCard Functions
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Project Includes */
#include "pios.h"
/* Private Function Prototypes */
/**
* Initializes all system peripherals
*/
void PIOS_SDCARD_Init(void)
{
/* File system object for each logical drive */
static FATFS Fatfs[_DRIVES];
/* Initialize FatFS disk */
if(f_mount(0, &Fatfs[0]) != FR_OK) {
/* Failed to mount MicroSD filesystem, flash LED1 forever */
while(1) {
for(int i = 0; i < 100000; i++);
PIOS_LED_Toggle(LED1);
}
}
}

View File

@ -39,8 +39,6 @@ void NVIC_Configuration(void);
*/
void PIOS_SYS_Init(void)
{
/* File system object for each logical drive */
FATFS Fatfs[_DRIVES];
/* Setup STM32 system (RCC, clock, PLL and Flash configuration) - CMSIS Function */
SystemInit();
@ -51,14 +49,6 @@ void PIOS_SYS_Init(void)
/* Initialize LEDs */
PIOS_LED_Init();
/* Initialize FatFS disk */
if(f_mount(0, &Fatfs[0]) != FR_OK) {
/* Failed to mount MicroSD filesystem, flash LED1 forever */
while(1) {
for(int i = 0; i < 100000; i++);
PIOS_LED_Toggle(LED1);
}
}
}

View File

@ -0,0 +1,32 @@
/**
******************************************************************************
*
* @file pios_sdcard.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2009.
* @brief System and hardware Init functions header.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_SDCARD_H
#define PIOS_SDCARD_H
/* Public Functions */
extern void PIOS_SDCARD_Init(void);
#endif /* PIOS_SDCARD_H */

View File

@ -51,8 +51,11 @@ int main()
{
/* Brings up System using CMSIS functions,
enables the LEDs and mounts the SDCard. */
enables the LEDs. */
PIOS_SYS_Init();
/* Enables the SDCard */
PIOS_SDCARD_Init(void);
/* Call LoadSettings which populates System Vars
so the rest of the hardware can be configured. */

View File

@ -54,6 +54,7 @@
#include <pios_board.h>
#include <pios_sys.h>
#include <pios_led.h>
#include <pios_sdcard.h>
#include <pios_usart.h>
#include <pios_irq.h>
#include <pios_adc.h>