##// END OF EJS Templates
Added OpenOCD target for olimex-arm-usb-tiny....
Added OpenOCD target for olimex-arm-usb-tiny. Working D51E5TA7601 driver. Added Framebuffer interface. Added generic memory to memory DMA api, mmainly used by framebuffer API. ADS7843 work in progress. Added SOSmartPSU bsp.

File last commit:

r74:0f2d8fe5497f dev_alexis
r103:3311a844031e dev_alexis
Show More
bsp_sdcard.c
116 lines | 3.4 KiB | text/x-c | CLexer
/*------------------------------------------------------------------------------
-- This file is a part of the libuc, microcontroler library
-- Copyright (C) 2013, Alexis Jeandet
--
-- 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
-------------------------------------------------------------------------------
-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@member.fsf.org
-------------------------------------------------------------------------------*/
#include "bsp.h"
#include <streamdevices.h>
#include <malloc.h>
#include <gpio.h>
#include <uart.h>
#include <stdio.h>
#include <stm32f4xx_gpio.h>
#include <stm32f4xx_fsmc.h>
#include <i2c.h>
#include <core.h>
#include <terminal.h>
void bsp_SD_init()
{
if(bspsdcardpresent())
{
sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed);
sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected);
if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT)
{
if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr)
{
if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1))
printf("Can't open fat32 partition 1\n");
}
else
{
printf("Can't open or read MBR\n");
}
if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr)
{
if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2))
printf("Can't open fat32 partition 2\n");
}
else
{
printf("Can't open or read MBR\n");
}
if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr)
{
if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3))
printf("Can't open fat32 partition 3\n");
}
else
{
printf("Can't open or read MBR\n");
}
if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr)
{
if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4))
printf("Can't open fat32 partition 4\n");
}
else
{
printf("Can't open or read MBR\n");
}
}
else
{
printf("Can't initialize SDCARD\n");
}
}
}
void bsppowersdcard(char onoff) //always ON
{
}
char bspsdcardpresent()
{
return gpiogetval(SDCARD2CD);
}
char bspsdcardwriteprotected()
{
return 0;
}
void bspsdcardselect(char YESNO)
{
// gpiosetval(LED1,(int)YESNO);
if(YESNO)
gpioclr(SDCARD2CS);
else
gpioset(SDCARD2CS);
}