Inital commit of stm32f4xx framework.

crypto-aes
Damien 9 years ago
parent 3ef4abb446
commit ed65605edc

1
stm/.gitignore vendored

@ -0,0 +1 @@
build

@ -0,0 +1,130 @@
STMSRC=lib
FATFSSRC=fatfs
PYSRC=../py
BUILD=build
AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfloat-abi=hard -DSTM32F40XX -DHSE_VALUE=8000000
CFLAGS = -I. -I$(PYSRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4)
CFLAGS_PY = -DEMIT_ENABLE_THUMB
LDFLAGS = --nostdlib -T stm.ld
SRC_C = \
main.c \
printf.c \
system_stm32f4xx.c \
flash.c \
string0.c \
malloc0.c \
stm32fxxx_it.c \
usb.c \
# sd.c \
SRC_S = \
delay.s \
startup_stm32f40xx.s \
PY_O = \
# malloc.o \
qstr.o \
misc.o \
lexer.o \
parse.o \
scope.o \
compile.o \
emitcommon.o \
emitpass1.o \
emitbc.o \
asmthumb.o \
emitnthumb.o \
emitinlinethumb.o \
runtime.o \
vm.o \
SRC_FATFS = \
ff.c \
diskio.c \
SRC_STM = \
stm32f4xx_rcc.c \
stm32f4xx_flash.c \
stm32f4xx_dma.c \
stm32f4xx_exti.c \
stm32f4xx_gpio.c \
stm_misc.c \
usb_core.c \
usb_dcd.c \
usb_dcd_int.c \
usb_bsp.c \
usbd_core.c \
usbd_ioreq.c \
usbd_req.c \
usbd_usr.c \
usbd_desc.c \
usbd_cdc_core.c \
usbd_cdc_vcp.c \
usbd_msc_bot.c \
usbd_msc_core.c \
usbd_msc_data.c \
usbd_msc_scsi.c \
usbd_storage_msd.c \
# not needed
# usb_otg.c \
# usb_hcd.c \
# usb_hcd_int.c \
# for SD card
# stm32f4xx_sdio.c \
# stm324x7i_eval.c \
# stm324x7i_eval_sdio_sd.c \
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(PY_O) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o))
all: $(BUILD) $(BUILD)/flash.dfu
$(BUILD)/flash.dfu: $(BUILD)/flash.bin
python2 ~/stm/dfu/dfu.py -b 0x08000000:$< $@
$(BUILD)/flash.bin: $(BUILD)/flash.elf
arm-none-eabi-objcopy -O binary -j .isr_vector -j .text -j .data $^ $@
$(BUILD)/flash.elf: $(OBJ)
$(LD) $(LDFLAGS) -o $@ $(OBJ)
arm-none-eabi-size $@
$(BUILD):
mkdir $@
$(BUILD)/%.o: %.s
$(AS) -o $@ $<
$(BUILD)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(FATFSSRC)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(STMSRC)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(PYSRC)/%.c mpyconfig.h
$(CC) $(CFLAGS) $(CFLAGS_PY) -c -o $@ $<
$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
$(CC) $(CFLAGS) $(CFLAGS_PY) -DN_THUMB -c -o $@ $<
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
$(BUILD)/vm.o: $(PYSRC)/vm.c
$(CC) $(CFLAGS) $(CFLAGS_PY) -O3 -c -o $@ $<
$(BUILD)/parse.o: $(PYSRC)/grammar.h
$(BUILD)/compile.o: $(PYSRC)/grammar.h
$(BUILD)/emitbc.o: $(PYSRC)/emit.h
clean:
/bin/rm -r $(BUILD)
.PHONY: all clean

@ -0,0 +1,28 @@
.syntax unified
.cpu cortex-m4
.thumb
.text
.align 2
.global delay_ms
.thumb
.thumb_func
.type delay_ms, %function
@ void delay_ms(int ms)
delay_ms:
@ r0 is argument, trashes r2, r3
adds r3, r0, #0
b .L2
.L5:
movw r2, #55999
b .L3
.L4:
subs r2, r2, #1
.L3:
cmp r2, #0
bgt .L4
subs r3, r3, #1
.L2:
cmp r3, #0
bgt .L5
bx lr
.size delay_ms, .-delay_ms

@ -0,0 +1,272 @@
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */
/* This is an example of glue functions to attach various exsisting */
/* storage control module to the FatFs module with a defined API. */
/*-----------------------------------------------------------------------*/
#include <stdint.h>
#include <stdio.h>
#include "ff.h" /* FatFs lower layer API */
#include "diskio.h" /* FatFs lower layer API */
PARTITION VolToPart[] = {
{0, 1}, // Logical drive 0 ==> Physical drive 0, 1st partition
/*
{0, 2}, // Logical drive 1 ==> Physical drive 0, 2nd partition
{0, 3}, // Logical drive 2 ==> Physical drive 0, 3rd partition
{1, 0}, // Logical drive 3 ==> Physical drive 1 (auto detection)
*/
};
#define PD_FLASH_SECTOR_SIZE (512)
#define PD_FLASH_PART1_START_SECTOR (0x100)
#define PD_FLASH_PART1_NUM_SECTORS (128) // 64k
#define PD_FLASH_MEM_START_ADDR (0x08020000) // 128k above start, first 128k block
#define PD_FLASH_RAM_BUF (0x10000000) // CCM data RAM, 64k
static void pd_flash_init() {
printf("IN\n");
// fill RAM buffer
uint32_t *src = (uint32_t*)PD_FLASH_MEM_START_ADDR;
uint32_t *dest = (uint32_t*)PD_FLASH_RAM_BUF;
for (int i = 0; i < PD_FLASH_PART1_NUM_SECTORS * PD_FLASH_SECTOR_SIZE / 4; i++) {
*dest++ = *src++;
}
}
extern void flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32);
static void pd_flash_flush() {
printf("FL\n");
// sync the RAM buffer by writing it to the flash page
flash_write(PD_FLASH_MEM_START_ADDR, (const uint32_t*)PD_FLASH_RAM_BUF, PD_FLASH_PART1_NUM_SECTORS * PD_FLASH_SECTOR_SIZE / 4);
}
static void build_partition(uint8_t *buf, int boot, int type, uint32_t start_sector, uint32_t num_sectors) {
buf[0] = boot;
if (num_sectors == 0) {
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
} else {
buf[1] = 0xff;
buf[2] = 0xff;
buf[3] = 0xff;
}
buf[4] = type;
if (num_sectors == 0) {
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
} else {
buf[5] = 0xff;
buf[6] = 0xff;
buf[7] = 0xff;
}
buf[8] = start_sector;
buf[9] = start_sector >> 8;
buf[10] = start_sector >> 16;
buf[11] = start_sector >> 24;
buf[12] = num_sectors;
buf[13] = num_sectors >> 8;
buf[14] = num_sectors >> 16;
buf[15] = num_sectors >> 24;
}
static DRESULT pd_flash_read_sector(uint8_t *dest, uint32_t sector) {
//printf("RD %u\n", sector);
if (sector == 0) {
// fake the MBR so we can decide on our own partition table
for (int i = 0; i < 446; i++) {
dest[i] = 0;
}
build_partition(dest + 446, 0, 0x01 /* FAT12 */, PD_FLASH_PART1_START_SECTOR, PD_FLASH_PART1_NUM_SECTORS);
build_partition(dest + 462, 0, 0, 0, 0);
build_partition(dest + 478, 0, 0, 0, 0);
build_partition(dest + 494, 0, 0, 0, 0);
dest[510] = 0x55;
dest[511] = 0xaa;
return RES_OK;
} else if (PD_FLASH_PART1_START_SECTOR <= sector && sector < PD_FLASH_PART1_START_SECTOR + PD_FLASH_PART1_NUM_SECTORS) {
// non-MBR sector(s), just copy straight from flash
uint8_t *src = (uint8_t*)PD_FLASH_RAM_BUF + (sector - PD_FLASH_PART1_START_SECTOR) * PD_FLASH_SECTOR_SIZE;
for (int i = PD_FLASH_SECTOR_SIZE; i > 0; i--) {
*dest++ = *src++;
}
return RES_OK;
} else {
// bad sector number
return RES_ERROR;
}
}
static DRESULT pd_flash_write_sector(const uint8_t *src, uint32_t sector) {
printf("WR %u\n", sector);
if (sector == 0) {
// can't write MBR, but pretend we did
return RES_OK;
} else if (PD_FLASH_PART1_START_SECTOR <= sector && sector < PD_FLASH_PART1_START_SECTOR + PD_FLASH_PART1_NUM_SECTORS) {
// non-MBR sector(s), copy to RAM buffer
uint8_t *dest = (uint8_t*)PD_FLASH_RAM_BUF + (sector - PD_FLASH_PART1_START_SECTOR) * PD_FLASH_SECTOR_SIZE;
for (int i = PD_FLASH_SECTOR_SIZE; i > 0; i--) {
*dest++ = *src++;
}
return RES_OK;
} else {
// bad sector number
return RES_ERROR;
}
}
/* Definitions of physical drive number for each media */
#define PD_FLASH (0)
#define PD_SD (1)
/*-----------------------------------------------------------------------*/
/* Initialize a Drive */
/*-----------------------------------------------------------------------*/
DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber (0..) */
)
{
switch (pdrv) {
case PD_FLASH :
pd_flash_init();
return 0;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/
/* Get Disk Status */
/*-----------------------------------------------------------------------*/
DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber (0..) */
)
{
switch (pdrv) {
case PD_FLASH :
// flash is ready
return 0;
case PD_SD:
return STA_NOINIT;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/
/* Read Sector(s) */
/*-----------------------------------------------------------------------*/
DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address (LBA) */
UINT count /* Number of sectors to read (1..128) */
)
{
DRESULT res;
switch (pdrv) {
case PD_FLASH:
for (int i = 0; i < count; i++) {
if ((res = pd_flash_read_sector(buff + i * PD_FLASH_SECTOR_SIZE, sector + i)) != RES_OK) {
return res;
}
}
return RES_OK;
}
return RES_PARERR;
}
/*-----------------------------------------------------------------------*/
/* Write Sector(s) */
/*-----------------------------------------------------------------------*/
#if _USE_WRITE
DRESULT disk_write (
BYTE pdrv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address (LBA) */
UINT count /* Number of sectors to write (1..128) */
)
{
DRESULT res;
switch (pdrv) {
case PD_FLASH:
for (int i = 0; i < count; i++) {
if ((res = pd_flash_write_sector(buff + i * PD_FLASH_SECTOR_SIZE, sector + i)) != RES_OK) {
return res;
}
}
return RES_OK;
}
return RES_PARERR;
}
#endif
/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/
#if _USE_IOCTL
DRESULT disk_ioctl (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
switch (pdrv) {
case PD_FLASH:
switch (cmd) {
case CTRL_SYNC:
pd_flash_flush();
return RES_OK;
case GET_BLOCK_SIZE:
*((DWORD*)buff) = 1; // block erase size in units of the sector size
return RES_OK;
}
}
return RES_PARERR;
}
#endif
DWORD get_fattime (
void
)
{
int year = 2013;
int month = 10;
int day = 12;
int hour = 21;
int minute = 42;
int second = 13;
return ((year - 1980) << 25) | ((month) << 21) | ((day) << 16) | ((hour) << 11) | ((minute) << 5) | (second / 2);
}

@ -0,0 +1,89 @@
/*-----------------------------------------------------------------------
/ Low level disk interface modlue include file (C)ChaN, 2013
/-----------------------------------------------------------------------*/
#ifndef _DISKIO_DEFINED
#define _DISKIO_DEFINED
#ifdef __cplusplus
extern "C" {
#endif
#define _USE_WRITE 1 /* 1: Enable disk_write function */
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
#include "integer.h"
/* Status of Disk Functions */
typedef BYTE DSTATUS;
/* Results of Disk Functions */
typedef enum {
RES_OK = 0, /* 0: Successful */
RES_ERROR, /* 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */
} DRESULT;
/*---------------------------------------*/
/* Prototypes for disk control functions */
DSTATUS disk_initialize (BYTE pdrv);
DSTATUS disk_status (BYTE pdrv);
DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, UINT count);
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
DWORD get_fattime (void);
/* Disk Status Bits (DSTATUS) */
#define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */
#define STA_PROTECT 0x04 /* Write protected */
/* Command code for disk_ioctrl fucntion */
/* Generic command (used by FatFs) */
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
/* Generic command (not used by FatFs) */
#define CTRL_POWER 5 /* Get/Set power status */
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
#define CTRL_EJECT 7 /* Eject media */
#define CTRL_FORMAT 8 /* Create physical format on the media */
/* MMC/SDC specific ioctl command */
#define MMC_GET_TYPE 10 /* Get card type */
#define MMC_GET_CSD 11 /* Get CSD */
#define MMC_GET_CID 12 /* Get CID */
#define MMC_GET_OCR 13 /* Get OCR */
#define MMC_GET_SDSTAT 14 /* Get SD status */
/* ATA/CF specific ioctl command */
#define ATA_GET_REV 20 /* Get F/W revision */
#define ATA_GET_MODEL 21 /* Get model name */
#define ATA_GET_SN 22 /* Get serial number */
/* MMC card type flags (MMC_GET_TYPE) */
#define CT_MMC 0x01 /* MMC ver 3 */
#define CT_SD1 0x02 /* SD ver 1 */
#define CT_SD2 0x04 /* SD ver 2 */
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
#define CT_BLOCK 0x08 /* Block addressing */
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,342 @@
/*---------------------------------------------------------------------------/
/ FatFs - FAT file system module include file R0.10 (C)ChaN, 2013
/----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems.
/ This is a free software that opened for education, research and commercial
/ developments under license policy of following terms.
/
/ Copyright (C) 2013, ChaN, all right reserved.
/
/ * The FatFs module is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for
/ personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
/ * Redistributions of source code must retain the above copyright notice.
/
/----------------------------------------------------------------------------*/
#ifndef _FATFS
#define _FATFS 80960 /* Revision ID */
#ifdef __cplusplus
extern "C" {
#endif
#include "integer.h" /* Basic integer types */
#include "ffconf.h" /* FatFs configuration options */
#if _FATFS != _FFCONF
#error Wrong configuration file (ffconf.h).
#endif
/* Definitions of volume management */
#if _MULTI_PARTITION /* Multiple partition configuration */
typedef struct {
BYTE pd; /* Physical drive number */
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
} PARTITION;
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
#else /* Single partition configuration */
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
#endif
/* Type of path name strings on FatFs API */
#if _LFN_UNICODE /* Unicode string */
#if !_USE_LFN
#error _LFN_UNICODE must be 0 in non-LFN cfg.
#endif
#ifndef _INC_TCHAR
typedef WCHAR TCHAR;
#define _T(x) L ## x
#define _TEXT(x) L ## x
#endif
#else /* ANSI/OEM string */
#ifndef _INC_TCHAR
typedef char TCHAR;
#define _T(x) x
#define _TEXT(x) x
#endif
#endif
/* File system object structure (FATFS) */
typedef struct {
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
BYTE drv; /* Physical drive number */
BYTE csize; /* Sectors per cluster (1,2,4...128) */
BYTE n_fats; /* Number of FAT copies (1 or 2) */
BYTE wflag; /* win[] flag (b0:dirty) */
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
WORD id; /* File system mount ID */
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
#if _MAX_SS != 512
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
#endif
#if _FS_REENTRANT
_SYNC_t sobj; /* Identifier of sync object */
#endif
#if !_FS_READONLY
DWORD last_clust; /* Last allocated cluster */
DWORD free_clust; /* Number of free clusters */
#endif
#if _FS_RPATH
DWORD cdir; /* Current directory start cluster (0:root) */
#endif
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
DWORD fsize; /* Sectors per FAT */
DWORD volbase; /* Volume start sector */
DWORD fatbase; /* FAT start sector */
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
DWORD database; /* Data start sector */
DWORD winsect; /* Current sector appearing in the win[] */
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
} FATFS;
/* File object structure (FIL) */
typedef struct {
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
WORD id; /* Owner file system mount ID (**do not change order**) */
BYTE flag; /* File status flags */
BYTE err; /* Abort flag (error code) */
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
DWORD fsize; /* File size */
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
DWORD clust; /* Current cluster of fpter */
DWORD dsect; /* Current data sector of fpter */
#if !_FS_READONLY
DWORD dir_sect; /* Sector containing the directory entry */
BYTE* dir_ptr; /* Pointer to the directory entry in the window */
#endif
#if _USE_FASTSEEK
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
#endif
#if _FS_LOCK
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
#endif
#if !_FS_TINY
BYTE buf[_MAX_SS]; /* File data read/write buffer */
#endif
} FIL;
/* Directory object structure (DIR) */
typedef struct {
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
WORD id; /* Owner file system mount ID (**do not change order**) */
WORD index; /* Current read/write index number */
DWORD sclust; /* Table start cluster (0:Root dir) */
DWORD clust; /* Current cluster */
DWORD sect; /* Current sector */
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
#if _FS_LOCK
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
#endif
#if _USE_LFN
WCHAR* lfn; /* Pointer to the LFN working buffer */
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
#endif
} DIR;
/* File status structure (FILINFO) */
typedef struct {
DWORD fsize; /* File size */
WORD fdate; /* Last modified date */
WORD ftime; /* Last modified time */
BYTE fattrib; /* Attribute */
TCHAR fname[13]; /* Short file name (8.3 format) */
#if _USE_LFN
TCHAR* lfname; /* Pointer to the LFN buffer */
UINT lfsize; /* Size of LFN buffer in TCHAR */
#endif
} FILINFO;
/* File function return code (FRESULT) */
typedef enum {
FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
} FRESULT;
/*--------------------------------------------------------------*/
/* FatFs module application interface */
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
FRESULT f_close (FIL* fp); /* Close an open file object */
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
FRESULT f_truncate (FIL* fp); /* Truncate file */
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
FRESULT f_closedir (DIR* dp); /* Close an open directory */
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* sn); /* Get volume label */
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
#define f_error(fp) ((fp)->err)
#define f_tell(fp) ((fp)->fptr)
#define f_size(fp) ((fp)->fsize)
#ifndef EOF
#define EOF (-1)
#endif
/*--------------------------------------------------------------*/
/* Additional user defined functions */
/* RTC function */
#if !_FS_READONLY
DWORD get_fattime (void);
#endif
/* Unicode support functions */
#if _USE_LFN /* Unicode - OEM code conversion */
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
#if _USE_LFN == 3 /* Memory functions */
void* ff_memalloc (UINT msize); /* Allocate memory block */
void ff_memfree (void* mblock); /* Free memory block */
#endif
#endif
/* Sync functions */
#if _FS_REENTRANT
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
#endif
/*--------------------------------------------------------------*/
/* Flags and offset address */
/* File access control and file status flags (FIL.flag) */
#define FA_READ 0x01
#define FA_OPEN_EXISTING 0x00
#if !_FS_READONLY
#define FA_WRITE 0x02
#define FA_CREATE_NEW 0x04
#define FA_CREATE_ALWAYS 0x08
#define FA_OPEN_ALWAYS 0x10
#define FA__WRITTEN 0x20
#define FA__DIRTY 0x40
#endif
/* FAT sub type (FATFS.fs_type) */
#define FS_FAT12 1
#define FS_FAT16 2
#define FS_FAT32 3
/* File attribute bits for directory entry */
#define AM_RDO 0x01 /* Read only */
#define AM_HID 0x02 /* Hidden */
#define AM_SYS 0x04 /* System */
#define AM_VOL 0x08 /* Volume label */
#define AM_LFN 0x0F /* LFN entry */
#define AM_DIR 0x10 /* Directory */
#define AM_ARC 0x20 /* Archive */
#define AM_MASK 0x3F /* Mask of defined bits */
/* Fast seek feature */
#define CREATE_LINKMAP 0xFFFFFFFF
/*--------------------------------*/
/* Multi-byte word access macros */
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
#else /* Use byte-by-byte access to the FAT structure */
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _FATFS */

@ -0,0 +1,212 @@
/*---------------------------------------------------------------------------/
/ FatFs - FAT file system module configuration file R0.10 (C)ChaN, 2013
/----------------------------------------------------------------------------/
/
/ CAUTION! Do not forget to make clean the project after any changes to
/ the configuration options.
/
/----------------------------------------------------------------------------*/
#ifndef _FFCONF
#define _FFCONF 80960 /* Revision ID */
/*---------------------------------------------------------------------------/
/ Functions and Buffer Configurations
/----------------------------------------------------------------------------*/
#define _FS_TINY 1 /* 0:Normal or 1:Tiny */
/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
/ object instead of the sector buffer in the individual file object for file
/ data transfer. This reduces memory consumption 512 bytes each file object. */
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
/ writing functions, f_write(), f_sync(), f_unlink(), f_mkdir(), f_chmod(),
/ f_rename(), f_truncate() and useless f_getfree(). */
#define _FS_MINIMIZE 0 /* 0 to 3 */
/* The _FS_MINIMIZE option defines minimization level to remove API functions.
/
/ 0: All basic functions are enabled.
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
/ f_truncate() and f_rename() function are removed.
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
/ 3: f_lseek() function is removed in addition to 2. */
#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
#define _USE_MKFS 1 /* 0:Disable or 1:Enable */
/* To enable f_mkfs() function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
#define _USE_FASTSEEK 0 /* 0:Disable or 1:Enable */
/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
#define _USE_LABEL 0 /* 0:Disable or 1:Enable */
/* To enable volume label functions, set _USE_LAVEL to 1 */
#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
/* To enable f_forward() function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
/*---------------------------------------------------------------------------/
/ Locale and Namespace Configurations
/----------------------------------------------------------------------------*/
#define _CODE_PAGE 1
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
/ Incorrect setting of the code page can cause a file open failure.
/
/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows)
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
/ 949 - Korean (DBCS, OEM, Windows)
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
/ 1250 - Central Europe (Windows)
/ 1251 - Cyrillic (Windows)
/ 1252 - Latin 1 (Windows)
/ 1253 - Greek (Windows)
/ 1254 - Turkish (Windows)
/ 1255 - Hebrew (Windows)
/ 1256 - Arabic (Windows)
/ 1257 - Baltic (Windows)
/ 1258 - Vietnam (OEM, Windows)
/ 437 - U.S. (OEM)
/ 720 - Arabic (OEM)
/ 737 - Greek (OEM)
/ 775 - Baltic (OEM)
/ 850 - Multilingual Latin 1 (OEM)
/ 858 - Multilingual Latin 1 + Euro (OEM)
/ 852 - Latin 2 (OEM)
/ 855 - Cyrillic (OEM)
/ 866 - Russian (OEM)
/ 857 - Turkish (OEM)
/ 862 - Hebrew (OEM)
/ 874 - Thai (OEM, Windows)
/ 1 - ASCII (Valid for only non-LFN cfg.)
*/
#define _USE_LFN 0 /* 0 to 3 */
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
/* The _USE_LFN option switches the LFN feature.
/
/ 0: Disable LFN feature. _MAX_LFN has no effect.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
/ 2: Enable LFN with dynamic working buffer on the STACK.
/ 3: Enable LFN with dynamic working buffer on the HEAP.
/
/ To enable LFN feature, Unicode handling functions ff_convert() and ff_wtoupper()
/ function must be added to the project.
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. When use stack for the
/ working buffer, take care on stack overflow. When use heap memory for the working
/ buffer, memory management functions, ff_memalloc() and ff_memfree(), must be added
/ to the project. */
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
/* To switch the character encoding on the FatFs API to Unicode, enable LFN feature
/ and set _LFN_UNICODE to 1. */
#define _STRF_ENCODE 3 /* 0:ANSI/OEM, 1:UTF-16LE, 2:UTF-16BE, 3:UTF-8 */
/* When Unicode API is enabled, character encoding on the all FatFs API is switched
/ to Unicode. This option selects the character encoding on the file to be read/written
/ via string functions, f_gets(), f_putc(), f_puts and f_printf().
/ This option has no effect when _LFN_UNICODE is 0. */
#define _FS_RPATH 0 /* 0 to 2 */
/* The _FS_RPATH option configures relative path feature.
/
/ 0: Disable relative path feature and remove related functions.
/ 1: Enable relative path. f_chdrive() and f_chdir() function are available.
/ 2: f_getcwd() function is available in addition to 1.
/
/ Note that output of the f_readdir() fnction is affected by this option. */
/*---------------------------------------------------------------------------/
/ Drive/Volume Configurations
/----------------------------------------------------------------------------*/
#define _VOLUMES 1
/* Number of volumes (logical drives) to be used. */
#define _MULTI_PARTITION 1 /* 0:Single partition, 1:Enable multiple partition */
/* When set to 0, each volume is bound to the same physical drive number and
/ it can mount only first primaly partition. When it is set to 1, each volume
/ is tied to the partitions listed in VolToPart[]. */
#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */
/* Maximum sector size to be handled.
/ Always set 512 for memory card and hard disk but a larger value may be
/ required for on-board flash memory, floppy disk and optical disk.
/ When _MAX_SS is larger than 512, it configures FatFs to variable sector size
/ and GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */
#define _USE_ERASE 0 /* 0:Disable or 1:Enable */
/* To enable sector erase feature, set _USE_ERASE to 1. Also CTRL_ERASE_SECTOR command
/ should be added to the disk_ioctl() function. */
#define _FS_NOFSINFO 0 /* 0 or 1 */
/* If you need to know the correct free space on the FAT32 volume, set this
/ option to 1 and f_getfree() function at first time after volume mount will
/ force a full FAT scan.
/
/ 0: Load all informations in the FSINFO if available.
/ 1: Do not trust free cluster count in the FSINFO.
*/
/*---------------------------------------------------------------------------/
/ System Configurations
/----------------------------------------------------------------------------*/
#define _WORD_ACCESS 0 /* 0 or 1 */
/* The _WORD_ACCESS option is an only platform dependent option. It defines
/ which access method is used to the word data on the FAT volume.
/
/ 0: Byte-by-byte access. Always compatible with all platforms.
/ 1: Word access. Do not choose this unless under both the following conditions.
/
/ * Byte order on the memory is little-endian.
/ * Address miss-aligned word access is always allowed for all instructions.
/
/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance
/ and reduce code size.
*/
/* A header file that defines sync object types on the O/S, such as
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
#define _SYNC_t HANDLE /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module.
/
/ 0: Disable re-entrancy. _SYNC_t and _FS_TIMEOUT have no effect.
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
/ function must be added to the project. */
#define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
/* To enable file lock control feature, set _FS_LOCK to 1 or greater.
The value defines how many files can be opened simultaneously. */
#endif /* _FFCONFIG */

@ -0,0 +1,33 @@
/*-------------------------------------------*/
/* Integer type definitions for FatFs module */
/*-------------------------------------------*/
#ifndef _FF_INTEGER
#define _FF_INTEGER
#ifdef _WIN32 /* FatFs development platform */
#include <windows.h>
#include <tchar.h>
#else /* Embedded platform */
/* This type MUST be 8 bit */
typedef unsigned char BYTE;
/* These types MUST be 16 bit */
typedef short SHORT;
typedef unsigned short WORD;
typedef unsigned short WCHAR;
/* These types MUST be 16 bit or 32 bit */
typedef int INT;
typedef unsigned int UINT;
/* These types MUST be 32 bit */
typedef long LONG;
typedef unsigned long DWORD;
#endif
#endif

@ -0,0 +1,109 @@
#include <stm32f4xx.h>
#include <stm32f4xx_flash.h>
/* Base address of the Flash sectors */
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */
#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */
#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */
#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbytes */
#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbytes */
#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbytes */
#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbytes */
static uint32_t GetSector(uint32_t Address);
void flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) {
// unlock
FLASH_Unlock();
// Clear pending flags (if any)
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
// Device voltage range supposed to be [2.7V to 3.6V], the operation will be done by word
if (FLASH_EraseSector(GetSector(flash_dest), VoltageRange_3) != FLASH_COMPLETE) {
/* Error occurred while sector erase.
User can add here some code to deal with this error */
return;
}
/* Program the user Flash area word by word ********************************/
for (int i = 0; i < num_word32; i++) {
if (FLASH_ProgramWord(flash_dest, *src) == FLASH_COMPLETE)
{
flash_dest += 4;
src += 1;
}
else
{
/* Error occurred while writing data in Flash memory.
User can add here some code to deal with this error */
return;
}
}
// lock
FLASH_Lock();
}
/**
* @brief Gets the sector of a given address
* @param None
* @retval The sector of a given address
*/
static uint32_t GetSector(uint32_t Address)
{
uint32_t sector = 0;
if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
{
sector = FLASH_Sector_0;
}
else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
{
sector = FLASH_Sector_1;
}
else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
{
sector = FLASH_Sector_2;
}
else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
{
sector = FLASH_Sector_3;
}
else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
{
sector = FLASH_Sector_4;
}
else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
{
sector = FLASH_Sector_5;
}
else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
{
sector = FLASH_Sector_6;
}
else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
{
sector = FLASH_Sector_7;
}
else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
{
sector = FLASH_Sector_8;
}
else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
{
sector = FLASH_Sector_9;
}
else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
{
sector = FLASH_Sector_10;
}
return sector;
}

@ -0,0 +1,98 @@
const uint8_t font_petme128_8x8[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 32=
0x00,0x00,0x00,0x4f,0x4f,0x00,0x00,0x00, // 33=!
0x00,0x07,0x07,0x00,0x00,0x07,0x07,0x00, // 34="
0x14,0x7f,0x7f,0x14,0x14,0x7f,0x7f,0x14, // 35=#
0x00,0x24,0x2e,0x6b,0x6b,0x3a,0x12,0x00, // 36=$
0x00,0x63,0x33,0x18,0x0c,0x66,0x63,0x00, // 37=%
0x00,0x32,0x7f,0x4d,0x4d,0x77,0x72,0x50, // 38=&
0x00,0x00,0x00,0x04,0x06,0x03,0x01,0x00, // 39='
0x00,0x00,0x1c,0x3e,0x63,0x41,0x00,0x00, // 40=(
0x00,0x00,0x41,0x63,0x3e,0x1c,0x00,0x00, // 41=)
0x08,0x2a,0x3e,0x1c,0x1c,0x3e,0x2a,0x08, // 42=*
0x00,0x08,0x08,0x3e,0x3e,0x08,0x08,0x00, // 43=+
0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00, // 44=,
0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, // 45=-
0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00, // 46=.
0x00,0x40,0x60,0x30,0x18,0x0c,0x06,0x02, // 47=/
0x00,0x3e,0x7f,0x49,0x45,0x7f,0x3e,0x00, // 48=0
0x00,0x40,0x44,0x7f,0x7f,0x40,0x40,0x00, // 49=1
0x00,0x62,0x73,0x51,0x49,0x4f,0x46,0x00, // 50=2
0x00,0x22,0x63,0x49,0x49,0x7f,0x36,0x00, // 51=3
0x00,0x18,0x18,0x14,0x16,0x7f,0x7f,0x10, // 52=4
0x00,0x27,0x67,0x45,0x45,0x7d,0x39,0x00, // 53=5
0x00,0x3e,0x7f,0x49,0x49,0x7b,0x32,0x00, // 54=6
0x00,0x03,0x03,0x79,0x7d,0x07,0x03,0x00, // 55=7
0x00,0x36,0x7f,0x49,0x49,0x7f,0x36,0x00, // 56=8
0x00,0x26,0x6f,0x49,0x49,0x7f,0x3e,0x00, // 57=9
0x00,0x00,0x00,0x24,0x24,0x00,0x00,0x00, // 58=:
0x00,0x00,0x80,0xe4,0x64,0x00,0x00,0x00, // 59=;
0x00,0x08,0x1c,0x36,0x63,0x41,0x41,0x00, // 60=<
0x00,0x14,0x14,0x14,0x14,0x14,0x14,0x00, // 61==
0x00,0x41,0x41,0x63,0x36,0x1c,0x08,0x00, // 62=>
0x00,0x02,0x03,0x51,0x59,0x0f,0x06,0x00, // 63=?
0x00,0x3e,0x7f,0x41,0x4d,0x4f,0x2e,0x00, // 64=@
0x00,0x7c,0x7e,0x0b,0x0b,0x7e,0x7c,0x00, // 65=A
0x00,0x7f,0x7f,0x49,0x49,0x7f,0x36,0x00, // 66=B
0x00,0x3e,0x7f,0x41,0x41,0x63,0x22,0x00, // 67=C
0x00,0x7f,0x7f,0x41,0x63,0x3e,0x1c,0x00, // 68=D
0x00,0x7f,0x7f,0x49,0x49,0x41,0x41,0x00, // 69=E
0x00,0x7f,0x7f,0x09,0x09,0x01,0x01,0x00, // 70=F
0x00,0x3e,0x7f,0x41,0x49,0x7b,0x3a,0x00, // 71=G
0x00,0x7f,0x7f,0x08,0x08,0x7f,0x7f,0x00, // 72=H
0x00,0x00,0x41,0x7f,0x7f,0x41,0x00,0x00, // 73=I
0x00,0x20,0x60,0x41,0x7f,0x3f,0x01,0x00, // 74=J
0x00,0x7f,0x7f,0x1c,0x36,0x63,0x41,0x00, // 75=K
0x00,0x7f,0x7f,0x40,0x40,0x40,0x40,0x00, // 76=L
0x00,0x7f,0x7f,0x06,0x0c,0x06,0x7f,0x7f, // 77=M
0x00,0x7f,0x7f,0x0e,0x1c,0x7f,0x7f,0x00, // 78=N
0x00,0x3e,0x7f,0x41,0x41,0x7f,0x3e,0x00, // 79=O
0x00,0x7f,0x7f,0x09,0x09,0x0f,0x06,0x00, // 80=P
0x00,0x1e,0x3f,0x21,0x61,0x7f,0x5e,0x00, // 81=Q
0x00,0x7f,0x7f,0x19,0x39,0x6f,0x46,0x00, // 82=R
0x00,0x26,0x6f,0x49,0x49,0x7b,0x32,0x00, // 83=S
0x00,0x01,0x01,0x7f,0x7f,0x01,0x01,0x00, // 84=T
0x00,0x3f,0x7f,0x40,0x40,0x7f,0x3f,0x00, // 85=U
0x00,0x1f,0x3f,0x60,0x60,0x3f,0x1f,0x00, // 86=V
0x00,0x7f,0x7f,0x30,0x18,0x30,0x7f,0x7f, // 87=W
0x00,0x63,0x77,0x1c,0x1c,0x77,0x63,0x00, // 88=X
0x00,0x07,0x0f,0x78,0x78,0x0f,0x07,0x00, // 89=Y
0x00,0x61,0x71,0x59,0x4d,0x47,0x43,0x00, // 90=Z
0x00,0x00,0x7f,0x7f,0x41,0x41,0x00,0x00, // 91=[
0x00,0x02,0x06,0x0c,0x18,0x30,0x60,0x40, // 92='\'
0x00,0x00,0x41,0x41,0x7f,0x7f,0x00,0x00, // 93=]
0x00,0x08,0x0c,0x06,0x06,0x0c,0x08,0x00, // 94=^
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0, // 95=_
0x00,0x00,0x01,0x03,0x06,0x04,0x00,0x00, // 96=`
0x00,0x20,0x74,0x54,0x54,0x7c,0x78,0x00, // 97=a
0x00,0x7f,0x7f,0x44,0x44,0x7c,0x38,0x00, // 98=b
0x00,0x38,0x7c,0x44,0x44,0x6c,0x28,0x00, // 99=c
0x00,0x38,0x7c,0x44,0x44,0x7f,0x7f,0x00, // 100=d
0x00,0x38,0x7c,0x54,0x54,0x5c,0x58,0x00, // 101=e
0x00,0x08,0x7e,0x7f,0x09,0x03,0x02,0x00, // 102=f
0x00,0x98,0xbc,0xa4,0xa4,0xfc,0x7c,0x00, // 103=g
0x00,0x7f,0x7f,0x04,0x04,0x7c,0x78,0x00, // 104=h
0x00,0x00,0x00,0x7d,0x7d,0x00,0x00,0x00, // 105=i
0x00,0x40,0xc0,0x80,0x80,0xfd,0x7d,0x00, // 106=j
0x00,0x7f,0x7f,0x30,0x38,0x6c,0x44,0x00, // 107=k
0x00,0x00,0x41,0x7f,0x7f,0x40,0x00,0x00, // 108=l
0x00,0x7c,0x7c,0x18,0x30,0x18,0x7c,0x7c, // 109=m
0x00,0x7c,0x7c,0x04,0x04,0x7c,0x78,0x00, // 110=n
0x00,0x38,0x7c,0x44,0x44,0x7c,0x38,0x00, // 111=o
0x00,0xfc,0xfc,0x24,0x24,0x3c,0x18,0x00, // 112=p
0x00,0x18,0x3c,0x24,0x24,0xfc,0xfc,0x00, // 113=q
0x00,0x7c,0x7c,0x04,0x04,0x0c,0x08,0x00, // 114=r
0x00,0x48,0x5c,0x54,0x54,0x74,0x20,0x00, // 115=s
0x04,0x04,0x3f,0x7f,0x44,0x64,0x20,0x00, // 116=t
0x00,0x3c,0x7c,0x40,0x40,0x7c,0x3c,0x00, // 117=u
0x00,0x1c,0x3c,0x60,0x60,0x3c,0x1c,0x00, // 118=v
0x00,0x1c,0x7c,0x30,0x18,0x30,0x7c,0x1c, // 119=w
0x00,0x44,0x6c,0x38,0x38,0x6c,0x44,0x00, // 120=x
0x00,0x9c,0xbc,0xa0,0xa0,0xfc,0x7c,0x00, // 121=y
0x00,0x44,0x64,0x74,0x5c,0x4c,0x44,0x00, // 122=z
0x00,0x08,0x08,0x3e,0x77,0x41,0x41,0x00, // 123={
0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00, // 124=|
0x00,0x41,0x41,0x77,0x3e,0x08,0x08,0x00, // 125=}
0x00,0x02,0x03,0x01,0x03,0x02,0x03,0x01, // 126=~
0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55, // 127
};

File diff suppressed because it is too large Load Diff

@ -0,0 +1,649 @@
/**************************************************************************//**
* @file core_cm4_simd.h
* @brief CMSIS Cortex-M4 SIMD Header File
* @version V3.01
* @date 06. March 2012
*
* @note
* Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* @par
* ARM Limited (ARM) is supplying this software for use with Cortex-M
* processor based microcontrollers. This file can be freely distributed
* within development tools that are supporting such ARM based processors.
*
* @par
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __CORE_CM4_SIMD_H
#define __CORE_CM4_SIMD_H
/*******************************************************************************
* Hardware Abstraction Layer
******************************************************************************/
/* ################### Compiler specific Intrinsics ########################### */
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
Access to dedicated SIMD instructions
@{
*/
#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
/* ARM armcc specific functions */
/*------ CM4 SIMD Intrinsics -----------------------------------------------------*/
#define __SADD8 __sadd8
#define __QADD8 __qadd8
#define __SHADD8 __shadd8
#define __UADD8 __uadd8
#define __UQADD8 __uqadd8
#define __UHADD8 __uhadd8
#define __SSUB8 __ssub8
#define __QSUB8 __qsub8
#define __SHSUB8 __shsub8
#define __USUB8 __usub8
#define __UQSUB8 __uqsub8
#define __UHSUB8 __uhsub8
#define __SADD16 __sadd16
#define __QADD16 __qadd16
#define __SHADD16 __shadd16
#define __UADD16 __uadd16
#define __UQADD16 __uqadd16
#define __UHADD16 __uhadd16
#define __SSUB16 __ssub16
#define __QSUB16 __qsub16
#define __SHSUB16 __shsub16
#define __USUB16 __usub16
#define __UQSUB16 __uqsub16
#define __UHSUB16 __uhsub16
#define __SASX __sasx
#define __QASX __qasx
#define __SHASX __shasx
#define __UASX __uasx
#define __UQASX __uqasx
#define __UHASX __uhasx
#define __SSAX __ssax
#define __QSAX __qsax
#define __SHSAX __shsax
#define __USAX __usax
#define __UQSAX __uqsax
#define __UHSAX __uhsax
#define __USAD8 __usad8
#define __USADA8 __usada8
#define __SSAT16 __ssat16
#define __USAT16 __usat16
#define __UXTB16 __uxtb16
#define __UXTAB16 __uxtab16
#define __SXTB16 __sxtb16
#define __SXTAB16 __sxtab16
#define __SMUAD __smuad
#define __SMUADX __smuadx
#define __SMLAD __smlad
#define __SMLADX __smladx
#define __SMLALD __smlald
#define __SMLALDX __smlaldx
#define __SMUSD __smusd
#define __SMUSDX __smusdx
#define __SMLSD __smlsd
#define __SMLSDX __smlsdx
#define __SMLSLD __smlsld
#define __SMLSLDX __smlsldx
#define __SEL __sel
#define __QADD __qadd
#define __QSUB __qsub
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
/*-- End CM4 SIMD Intrinsics -----------------------------------------------------*/
#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
/* IAR iccarm specific functions */
/*------ CM4 SIMD Intrinsics -----------------------------------------------------*/
#include <cmsis_iar.h>
/*-- End CM4 SIMD Intrinsics -----------------------------------------------------*/
#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
/* TI CCS specific functions */
/*------ CM4 SIMD Intrinsics -----------------------------------------------------*/
#include <cmsis_ccs.h>
/*-- End CM4 SIMD Intrinsics -----------------------------------------------------*/
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
/* GNU gcc specific functions */
/*------ CM4 SIMD Intrinsics -----------------------------------------------------*/
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)