fixed #1
This commit is contained in:
		
							
								
								
									
										7
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								Makefile
									
									
									
									
									
								
							@@ -3,9 +3,9 @@
 | 
			
		||||
#Compiler:	arm-none-eabi
 | 
			
		||||
#####################################################################################
 | 
			
		||||
#Add Files and Folders below#########################################################
 | 
			
		||||
CFILES 	= main.c syscalls.c UART/uart.c cmsis_boot/system_stm32f4xx.c
 | 
			
		||||
CFILES 	= main.c syscalls/syscalls.c uart/uart.c startup/system_stm32f4xx.c
 | 
			
		||||
ASFILES = boot/startup_stm32f4xx.S
 | 
			
		||||
INCLUDEPATH = -Iboot -Imathlib -Icmsis -Icmsis_boot -IUART
 | 
			
		||||
INCLUDEPATH = -Iinclude
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
target	= stm32f4sdio
 | 
			
		||||
@@ -19,8 +19,7 @@ mapfile = dafuqishappening
 | 
			
		||||
 | 
			
		||||
#TODO
 | 
			
		||||
 | 
			
		||||
CFILES += FATFS/option/syscall.c FATFS/option/ccsbcs.c FATFS/diskio.c FATFS/ff.c FATFS/shimatta_sdio_driver/shimatta_sdio-driver.c
 | 
			
		||||
INCLUDEPATH += -IFATFS -IFATFS/shimatta_sdio_driver
 | 
			
		||||
CFILES += fatfs/option/syscall.c fatfs/option/ccsbcs.c fatfs/diskio.c fatfs/ff.c fatfs/shimatta_sdio_driver/shimatta_sdio-driver.c
 | 
			
		||||
 | 
			
		||||
###################################################################################
 | 
			
		||||
CC=arm-none-eabi-gcc
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,8 @@
 | 
			
		||||
/*-----------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
//Only ONE device with ONE partition!!!
 | 
			
		||||
#include "diskio.h"		/* FatFs lower layer API */
 | 
			
		||||
#include <shimatta_sdio-driver.h>
 | 
			
		||||
 | 
			
		||||
#include <fatfs/diskio.h>		/* FatFs lower layer API */
 | 
			
		||||
#include "shimatta_sdio_driver/shimatta_sdio-driver.h"
 | 
			
		||||
/* Definitions of physical drive number for each drive */
 | 
			
		||||
#define SDCARD	0	/* Example: Map ATA harddisk to physical drive 0 */
 | 
			
		||||
 | 
			
		||||
@@ -16,8 +16,8 @@
 | 
			
		||||
/----------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "ff.h"			/* Declarations of FatFs API */
 | 
			
		||||
#include "diskio.h"		/* Declarations of disk I/O functions */
 | 
			
		||||
#include <fatfs/ff.h>		/* Declarations of FatFs API */
 | 
			
		||||
#include <fatfs/diskio.h>		/* Declarations of disk I/O functions */
 | 
			
		||||
 | 
			
		||||
//For get_fattime:
 | 
			
		||||
//#include <shimatta_sdio-driver.h>
 | 
			
		||||
@@ -25,7 +25,7 @@
 | 
			
		||||
/   1258  Vietnam (OEM, Windows)
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "../ff.h"
 | 
			
		||||
#include <fatfs/ff.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if _CODE_PAGE == 437
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
/*------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "../ff.h"
 | 
			
		||||
#include <fatfs/ff.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if _FS_REENTRANT
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
 *  Mario Hüttel
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <shimatta_sdio-driver.h>
 | 
			
		||||
#include "shimatta_sdio-driver.h"
 | 
			
		||||
 | 
			
		||||
#define SETAF(PORT,PIN,AF)  PORT->AFR[(PIN < 8 ? 0 : 1)] |= AF << ((PIN < 8 ? PIN : (PIN - 8)) * 4)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										133
									
								
								fatfs/shimatta_sdio_driver/shimatta_sdio-driver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								fatfs/shimatta_sdio_driver/shimatta_sdio-driver.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,133 @@
 | 
			
		||||
/*
 | 
			
		||||
 * shimatta_sdio-driver.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Created on: Apr 26, 2015
 | 
			
		||||
 *  Mario Hüttel
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_
 | 
			
		||||
#define FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_
 | 
			
		||||
 | 
			
		||||
#include <fatfs/diskio.h>
 | 
			
		||||
#include <stm32f4xx.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DSTATUS SDIO_status();
 | 
			
		||||
DSTATUS SDIO_initialize();
 | 
			
		||||
DRESULT SDIO_disk_read(BYTE *buff, DWORD sector, UINT count);
 | 
			
		||||
DRESULT SDIO_disk_write(const BYTE *buff, DWORD sector, UINT count);
 | 
			
		||||
DRESULT SDIO_disk_ioctl(BYTE cmd, void* buff);
 | 
			
		||||
DWORD	get_fattime();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//Defines for Card Status in struct _CardStatus
 | 
			
		||||
#define CURRENT_STATE_IDLE 0
 | 
			
		||||
#define CURRENT_STATE_READY 1
 | 
			
		||||
#define CURRENT_STATE_IDENT 2
 | 
			
		||||
#define CURRENT_STATE_STBY 3
 | 
			
		||||
#define CURRENT_STATE_TRAN 4
 | 
			
		||||
#define CURRENT_STATE_DATA 5
 | 
			
		||||
#define CURRENT_STATE_RCV 6
 | 
			
		||||
#define CURRENT_STATE_PRG 7
 | 
			
		||||
#define CURRENT_STATE_DIS 8
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef struct _CardStatus {
 | 
			
		||||
    uint32_t reserved           : 3;
 | 
			
		||||
    uint32_t AKE_SEQ_ERROR      : 1;
 | 
			
		||||
    uint32_t reserved_2         : 1;
 | 
			
		||||
    uint32_t APP_CMD            : 1;
 | 
			
		||||
    uint32_t reserved_3         : 2;
 | 
			
		||||
    uint32_t READY_FOR_DATA     : 1;
 | 
			
		||||
    uint32_t CURRENT_STATE      : 4;
 | 
			
		||||
    uint32_t ERASE_RESET        : 1;
 | 
			
		||||
    uint32_t CARD_ECC_DIABLED   : 1;
 | 
			
		||||
    uint32_t WP_ERASE_SKIP      : 1;
 | 
			
		||||
    uint32_t CSD_OVERWRITE      : 1;
 | 
			
		||||
    uint32_t reserved17         : 1;
 | 
			
		||||
    uint32_t reserved18         : 1;
 | 
			
		||||
    uint32_t ERROR              : 1;
 | 
			
		||||
    uint32_t CC_ERROR           : 1;
 | 
			
		||||
    uint32_t CARD_ECC_FAILED    : 1;
 | 
			
		||||
    uint32_t ILLEGAL_COMMAND    : 1;
 | 
			
		||||
    uint32_t COM_CRC_ERROR      : 1;
 | 
			
		||||
    uint32_t LOCK_UNLOCK_FAILED : 1;
 | 
			
		||||
    uint32_t CARD_IS_LOCKED     : 1;
 | 
			
		||||
    uint32_t WP_VIOLATION       : 1;
 | 
			
		||||
    uint32_t ERASE_PARAM        : 1;
 | 
			
		||||
    uint32_t ERASE_SEQ_ERROR    : 1;
 | 
			
		||||
    uint32_t BLOCK_LEN_ERROR    : 1;
 | 
			
		||||
    uint32_t ADDRESS_ERROR      : 1;
 | 
			
		||||
    uint32_t OUT_OF_RANGE       : 1;
 | 
			
		||||
}CardStatus_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef enum {CARD_NONE = 0, MMC, SD_V1, SD_V2_SC, SD_V2_HC} card_type_t;
 | 
			
		||||
                        // MMC not supported
 | 
			
		||||
typedef struct _SDInfo {
 | 
			
		||||
    uint16_t rca;
 | 
			
		||||
    card_type_t type;
 | 
			
		||||
}SDInfo_t;
 | 
			
		||||
 | 
			
		||||
typedef union _StatusConv {
 | 
			
		||||
    CardStatus_t statusstruct;
 | 
			
		||||
    uint32_t value;
 | 
			
		||||
}StatusConv_t;
 | 
			
		||||
 | 
			
		||||
//General Definitions
 | 
			
		||||
//Blocksize: 512 = 2^9 => 9
 | 
			
		||||
#define BLOCKSIZE 9     //9
 | 
			
		||||
//Hardware Flow: Prevents over- and underruns.
 | 
			
		||||
#define HW_FLOW   0     //0
 | 
			
		||||
//1 bit: 0
 | 
			
		||||
//4 bit: 1
 | 
			
		||||
#define BUSWIDTH  1     //1
 | 
			
		||||
//Initial Transfer CLK (ca. 400kHz)
 | 
			
		||||
#define INITCLK   120   //120
 | 
			
		||||
//Working CLK (Maximum)
 | 
			
		||||
#define WORKCLK   0     //0
 | 
			
		||||
//Data Timeout in CLK Cycles
 | 
			
		||||
#define DTIMEOUT  150   //150
 | 
			
		||||
//DMA Stream used for TX and RX DMA2 Stream 3 or 6 possible
 | 
			
		||||
#define DMASTREAM DMA2_Stream3
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//Port Definitions
 | 
			
		||||
 | 
			
		||||
#define PORTCLKMASK (RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOCEN)
 | 
			
		||||
 | 
			
		||||
#define ALTFUNC     12
 | 
			
		||||
 | 
			
		||||
#define CLKPORT     GPIOC
 | 
			
		||||
#define D0PORT      GPIOC
 | 
			
		||||
#define D1PORT      GPIOC
 | 
			
		||||
#define D2PORT      GPIOC
 | 
			
		||||
#define D3PORT      GPIOC
 | 
			
		||||
#define CMDPORT     GPIOD
 | 
			
		||||
 | 
			
		||||
#define CLKPIN      12
 | 
			
		||||
#define D0PIN       8
 | 
			
		||||
#define D1PIN       9
 | 
			
		||||
#define D2PIN       10
 | 
			
		||||
#define D3PIN       11
 | 
			
		||||
#define CMDPIN      2
 | 
			
		||||
 | 
			
		||||
// Write Protection
 | 
			
		||||
#define SDIO_ENABLE_WRITEPROT 0
 | 
			
		||||
#define WRITEPROT_PORT GPIOD // Add this port to port clock mask!
 | 
			
		||||
#define WRITEPROT_PIN 0
 | 
			
		||||
#define WRITEPROT_PULLUP 0
 | 
			
		||||
#define WRITEPROT_ACTIVE_LEVEL 0
 | 
			
		||||
 | 
			
		||||
// Card inserted pin
 | 
			
		||||
#define SDIO_ENABLE_INS 0
 | 
			
		||||
#define INS_PORT GPIOD // Add this port to port clock mask!
 | 
			
		||||
#define INS_PIN 0
 | 
			
		||||
#define INS_PULLUP 0
 | 
			
		||||
#define INS_ACTIVE_LEVEL 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_ */
 | 
			
		||||
@@ -151,9 +151,9 @@
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>                      /* standard types definitions                      */
 | 
			
		||||
#include <core_cmInstr.h>                /* Core Instruction Access                         */
 | 
			
		||||
#include <core_cmFunc.h>                 /* Core Function Access                            */
 | 
			
		||||
#include <core_cm4_simd.h>               /* Compiler specific SIMD Intrinsics               */
 | 
			
		||||
#include "core_cmInstr.h"                /* Core Instruction Access                         */
 | 
			
		||||
#include "core_cmFunc.h"                 /* Core Function Access                            */
 | 
			
		||||
#include "core_cm4_simd.h"               /* Compiler specific SIMD Intrinsics               */
 | 
			
		||||
 | 
			
		||||
#endif /* __CORE_CM4_H_GENERIC */
 | 
			
		||||
 | 
			
		||||
@@ -181,8 +181,8 @@ typedef enum
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#include "core_cm4.h"             /* Cortex-M4 processor and core peripherals */
 | 
			
		||||
#include "system_stm32f4xx.h"
 | 
			
		||||
#include <cmsis/core_cm4.h>             /* Cortex-M4 processor and core peripherals */
 | 
			
		||||
#include <startup/system_stm32f4xx.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
/** @addtogroup Peripheral_registers_structures
 | 
			
		||||
							
								
								
									
										6
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.c
									
									
									
									
									
								
							@@ -5,10 +5,8 @@
 | 
			
		||||
 *      Author: mari
 | 
			
		||||
 */
 | 
			
		||||
#include <stm32f4xx.h>
 | 
			
		||||
#include <arm_math.h>
 | 
			
		||||
#include <system_stm32f4xx.h>
 | 
			
		||||
 | 
			
		||||
#include <ff.h>
 | 
			
		||||
#include <cmsis/arm_math.h>
 | 
			
		||||
#include <fatfs/ff.h>
 | 
			
		||||
 | 
			
		||||
#define OUTPUT(pin)  (0b01 << (pin * 2))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -114,7 +114,7 @@
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#include "stm32f4xx.h"
 | 
			
		||||
#include <stm32f4xx.h>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
 * syscalls.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Created on: Dec 14, 2014
 | 
			
		||||
 *      Author: shino-chan
 | 
			
		||||
 *      Author: Mario Huettel <mario.huettel@gmx.net>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "uart.h"
 | 
			
		||||
#include <uart/uart.h>
 | 
			
		||||
 | 
			
		||||
char* _sbrk(int incr) {
 | 
			
		||||
            extern char heap_low;    // Defined by the linker
 | 
			
		||||
@@ -8,7 +8,7 @@
 | 
			
		||||
//PA2 => TX
 | 
			
		||||
//PA3 => RX
 | 
			
		||||
//Alternate Function 7
 | 
			
		||||
#include "uart.h"
 | 
			
		||||
#include <uart/uart.h>
 | 
			
		||||
#include <stm32f4xx.h>
 | 
			
		||||
 | 
			
		||||
void initUART() {
 | 
			
		||||
		Reference in New Issue
	
	Block a user