Skip to content

Commit e6f6a5d

Browse files
committedJul 8, 2014
major update
added FATFS & Keyboard
1 parent 8a4b4f2 commit e6f6a5d

23 files changed

+7604
-154
lines changed
 

‎.gitattributes

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

‎.gitignore

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
46+
[Dd]ebug/
47+
[Rr]elease/
48+
x64/
49+
build/
50+
[Bb]in/
51+
[Oo]bj/
52+
53+
# MSTest test Results
54+
[Tt]est[Rr]esult*/
55+
[Bb]uild[Ll]og.*
56+
57+
*_i.c
58+
*_p.c
59+
*.ilk
60+
*.meta
61+
*.obj
62+
*.pch
63+
*.pdb
64+
*.pgc
65+
*.pgd
66+
*.rsp
67+
*.sbr
68+
*.tlb
69+
*.tli
70+
*.tlh
71+
*.tmp
72+
*.tmp_proj
73+
*.log
74+
*.vspscc
75+
*.vssscc
76+
.builds
77+
*.pidb
78+
*.log
79+
*.scc
80+
81+
# Visual C++ cache files
82+
ipch/
83+
*.aps
84+
*.ncb
85+
*.opensdf
86+
*.sdf
87+
*.cachefile
88+
89+
# Visual Studio profiler
90+
*.psess
91+
*.vsp
92+
*.vspx
93+
94+
# Guidance Automation Toolkit
95+
*.gpState
96+
97+
# ReSharper is a .NET coding add-in
98+
_ReSharper*/
99+
*.[Rr]e[Ss]harper
100+
101+
# TeamCity is a build add-in
102+
_TeamCity*
103+
104+
# DotCover is a Code Coverage Tool
105+
*.dotCover
106+
107+
# NCrunch
108+
*.ncrunch*
109+
.*crunch*.local.xml
110+
111+
# Installshield output folder
112+
[Ee]xpress/
113+
114+
# DocProject is a documentation generator add-in
115+
DocProject/buildhelp/
116+
DocProject/Help/*.HxT
117+
DocProject/Help/*.HxC
118+
DocProject/Help/*.hhc
119+
DocProject/Help/*.hhk
120+
DocProject/Help/*.hhp
121+
DocProject/Help/Html2
122+
DocProject/Help/html
123+
124+
# Click-Once directory
125+
publish/
126+
127+
# Publish Web Output
128+
*.Publish.xml
129+
*.pubxml
130+
131+
# NuGet Packages Directory
132+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133+
#packages/
134+
135+
# Windows Azure Build Output
136+
csx
137+
*.build.csdef
138+
139+
# Windows Store app package directory
140+
AppPackages/
141+
142+
# Others
143+
sql/
144+
*.Cache
145+
ClientBin/
146+
[Ss]tyle[Cc]op.*
147+
~$*
148+
*~
149+
*.dbmdl
150+
*.[Pp]ublish.xml
151+
*.pfx
152+
*.publishsettings
153+
154+
# RIA/Silverlight projects
155+
Generated_Code/
156+
157+
# Backup & report files from converting an old project file to a newer
158+
# Visual Studio version. Backup files are not needed, because we have git ;-)
159+
_UpgradeReport_Files/
160+
Backup*/
161+
UpgradeLog*.XML
162+
UpgradeLog*.htm
163+
164+
# SQL Server files
165+
App_Data/*.mdf
166+
App_Data/*.ldf
167+
168+
#############
169+
## Windows detritus
170+
#############
171+
172+
# Windows image file caches
173+
Thumbs.db
174+
ehthumbs.db
175+
176+
# Folder config file
177+
Desktop.ini
178+
179+
# Recycle Bin used on file shares
180+
$RECYCLE.BIN/
181+
182+
# Mac crap
183+
.DS_Store
184+
185+
186+
#############
187+
## Python
188+
#############
189+
190+
*.py[co]
191+
192+
# Packages
193+
*.egg
194+
*.egg-info
195+
dist/
196+
build/
197+
eggs/
198+
parts/
199+
var/
200+
sdist/
201+
develop-eggs/
202+
.installed.cfg
203+
204+
# Installer logs
205+
pip-log.txt
206+
207+
# Unit test / coverage reports
208+
.coverage
209+
.tox
210+
211+
#Translations
212+
*.mo
213+
214+
#Mr Developer
215+
.mr.developer.cfg

‎RA8875.c

+169-31
Large diffs are not rendered by default.

‎RA8875.h

+62-61
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
#define LCD_CS_LOW() LCD_CS = 0
3636
#define LCD_CS_HIGH() LCD_CS = 1
3737

38-
typedef unsigned int uint;
38+
//typedef unsigned int uint;
39+
3940
typedef unsigned char uchar;
4041
typedef unsigned long ulong;
4142

@@ -97,9 +98,9 @@ typedef unsigned long ulong;
9798
#define color_purple color_red|color_blue
9899

99100

100-
void Delay1ms(uint i);
101-
void Delay10ms(uint i);
102-
void Delay100ms(uint i);
101+
void Delay1ms(unsigned int i);
102+
void Delay10ms(unsigned int i);
103+
void Delay100ms(unsigned int i);
103104
void NextStep(void);
104105

105106
void LCD_CmdWrite(unsigned char cmd);
@@ -114,25 +115,25 @@ void Chk_Busy(void);
114115
void Chk_BTE_Busy(void);
115116
void Chk_DMA_Busy(void);
116117
void PLL_ini(void);
117-
void Active_Window(uint XL,uint XR ,uint YT ,uint YB);
118+
void Active_Window(unsigned int XL,unsigned int XR ,unsigned int YT ,unsigned int YB);
118119
void LCD_Initial(void);
119-
void Text_Background_Color1(uint b_color);
120+
void Text_Background_Color1(unsigned int b_color);
120121
void Text_Background_Color(unsigned char setR, uchar setG, uchar setB);
121-
void Text_Foreground_Color1(uint b_color);
122+
void Text_Foreground_Color1(unsigned int b_color);
122123
void Text_Foreground_Color(unsigned char setR,uchar setG,uchar setB);
123-
void BTE_Size(uint width, uint height);
124-
void BTE_Source(uint SX,uint DX ,uint SY ,uint DY);
125-
void MemoryWrite_Position(uint X,uint Y);
126-
void FontWrite_Position(uint X,uint Y);
124+
void BTE_Size(unsigned int width, unsigned int height);
125+
void BTE_Source(unsigned int SX,unsigned int DX ,unsigned int SY ,unsigned int DY);
126+
void MemoryWrite_Position(unsigned int X,unsigned int Y);
127+
void FontWrite_Position(unsigned int X,unsigned int Y);
127128
void String(unsigned char *str);
128-
void Scroll_Window(uint XL,uint XR ,uint YT ,uint YB);
129-
void Scroll(uint X,uint Y);
130-
void DMA_block_mode_size_setting(uint BWR,uint BHR,uint SPWR);
129+
void Scroll_Window(unsigned int XL,unsigned int XR ,unsigned int YT ,unsigned int YB);
130+
void Scroll(unsigned int X,unsigned int Y);
131+
void DMA_block_mode_size_setting(unsigned int BWR,unsigned int BHR,unsigned int SPWR);
131132
void DMA_Start_address_setting(ulong set_address);
132-
void Draw_Circle(uint X,uint Y,uint R);
133-
void Draw_Ellipse(uint X,uint Y,uint R1,uint R2);
134-
void Draw_Line(uint XS,uint XE ,uint YS,uint YE);
135-
void Draw_Triangle(uint X3,uint Y3);
133+
void Draw_Circle(unsigned int X,unsigned int Y,unsigned int R);
134+
void Draw_Ellipse(unsigned int X,unsigned int Y,unsigned int R1,unsigned int R2);
135+
void Draw_Line(unsigned int XS,unsigned int XE ,unsigned int YS,unsigned int YE);
136+
void Draw_Triangle(unsigned int X3,unsigned int Y3);
136137
char Touch_Status(void);
137138
char Chk_INT(void);
138139
char Chk_INT2(void);
@@ -141,57 +142,57 @@ unsigned char ADC_Y(void);
141142
unsigned char ADC_XY(void);
142143
void TP(void);
143144
void Displaypicture(unsigned char picnum);
144-
void CutPictrue(unsigned char picnum,uint x1,uint y1,uint x2,uint y2,unsigned long x,unsigned long y);
145+
void CutPictrue(unsigned char picnum,unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2,unsigned long x,unsigned long y);
145146
void Test(void);
146147

147-
void MakeCircle(uint x0, uint y0, uint r, uint color, char filled);
148+
void MakeCircle(unsigned int x0, unsigned int y0, unsigned int r, unsigned int color, char filled);
148149
char waitPoll(uchar regname, uchar waitflag);
149150
void fillRect(void);
150-
void drawRect(uint x, uint y, uint w, uint h, uint color, char filled);
151-
void drawLine(uint x0, uint x1, uint y0, uint y1, uint color);
151+
void drawRect(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int color, char filled);
152+
void drawLine(unsigned int x0, unsigned int x1, unsigned int y0, unsigned int y1, unsigned int color);
152153

153154
#define FILL 1
154155
#define NOFILL 0
155156

156157
typedef struct _Button_ {
157-
uint top;
158-
uint left;
159-
uint width;
160-
uint height;
158+
unsigned int top;
159+
unsigned int left;
160+
unsigned int width;
161+
unsigned int height;
161162
} Button;
162163

163164

164165
typedef struct _Fader_ {
165-
uint bar_value;
166-
uint bar_max;
167-
168-
uint sel_width;
169-
uint sel_height;
170-
uint sel_color;
171-
172-
uint bar_x;
173-
uint bar_y;
174-
uint bar_width;
175-
uint bar_height;
176-
uint bar_color;
166+
unsigned int bar_value;
167+
unsigned int bar_max;
168+
169+
unsigned int sel_width;
170+
unsigned int sel_height;
171+
unsigned int sel_color;
172+
173+
unsigned int bar_x;
174+
unsigned int bar_y;
175+
unsigned int bar_width;
176+
unsigned int bar_height;
177+
unsigned int bar_color;
177178

178179
} Fader;
179180

180181
typedef struct _TouchButton_ {
181-
uint top;
182-
uint left;
183-
uint width;
184-
uint height;
185-
uint fore_color;
186-
uint back_color;
182+
unsigned int top;
183+
unsigned int left;
184+
unsigned int width;
185+
unsigned int height;
186+
unsigned int fore_color;
187+
unsigned int back_color;
187188
char text[13];
188189
} TouchButton;
189190

190191
typedef struct _ImageButton_ {
191-
uint top;
192-
uint left;
193-
uint width;
194-
uint height;
192+
unsigned int top;
193+
unsigned int left;
194+
unsigned int width;
195+
unsigned int height;
195196
char up[13];
196197
char down[13];
197198
} ImageButton;
@@ -206,21 +207,21 @@ void ClearScreen(char area);
206207
void Display(char val);
207208
void Layers(char val);
208209
void FontSize (char size);
209-
void SetColors(uint f_color, uint b_color);
210-
void GraphicCursor(uint x, uint y, uchar color1, uchar color2);
210+
void SetColors(unsigned int f_color, unsigned int b_color);
211+
void GraphicCursor(unsigned int x, unsigned int y, uchar color1, uchar color2);
211212
void Backlight(uchar div, uchar pwm);
212-
void DrawLine (uint xs,uint ys,uint xe,uint ye, uint color);
213-
void DrawSquare ( uint x,uint y,uint w,uint h, uint color, char fill);
214-
void DrawCircle(uint x0, uint y0, uint r, uint color, char filled);
215-
void LCD_ReadBuff(char *buff, uint len);
216-
void SetGraphicsCursorRead(uint x, uint y);
217-
void SetGraphicsCursorWrite(uint x, uint y);
218-
void WriteCommandW(uchar command, uint data);
213+
void DrawLine (unsigned int xs,unsigned int ys,unsigned int xe,unsigned int ye, unsigned int color);
214+
void DrawSquare ( unsigned int x,unsigned int y,unsigned int w,unsigned int h, unsigned int color, char fill);
215+
void DrawCircle(unsigned int x0, unsigned int y0, unsigned int r, unsigned int color, char filled);
216+
void LCD_ReadBuff(char *buff, unsigned int len);
217+
void SetGraphicsCursorRead(unsigned int x, unsigned int y);
218+
void SetGraphicsCursorWrite(unsigned int x, unsigned int y);
219+
void WriteCommandW(uchar command, unsigned int data);
219220
void WriteCommand(unsigned char command, unsigned int data);
220-
void putPixelStream(uchar * p, uint count, uint x, uint y);
221-
void OpenASI (char *filename, uint x, uint y);
222-
void ReplaceASI (char *filename, uint x, uint y, uint w, uint h);
221+
void putPixelStream(uchar * p, unsigned int count, unsigned int x, unsigned int y);
222+
void OpenASI (char *filename, unsigned int x, unsigned int y);
223+
void ReplaceASI (char *filename, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
223224
char isImageButton (ImageButton btn);
224225
void BtnClick(Button btn);
225-
void DrawFinger(uint x,uint y,uint colour);
226+
void DrawFinger(unsigned int x,unsigned int y,unsigned int colour);
226227
#endif

‎SevenParallel512.X.rar

1.44 KB
Binary file not shown.

‎diskio.c

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

‎diskio.h

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*-----------------------------------------------------------------------
2+
/ Low level disk interface modlue include file (C)ChaN, 2013
3+
/-----------------------------------------------------------------------*/
4+
5+
#ifndef _DISKIO_DEFINED
6+
#define _DISKIO_DEFINED
7+
8+
#ifdef __cplusplus
9+
extern "C" {
10+
#endif
11+
12+
#define _USE_WRITE 1 /* 1: Enable disk_write function */
13+
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
14+
15+
#include "integer.h"
16+
17+
18+
/* Status of Disk Functions */
19+
typedef BYTE DSTATUS;
20+
21+
/* Results of Disk Functions */
22+
typedef enum {
23+
RES_OK = 0, /* 0: Successful */
24+
RES_ERROR, /* 1: R/W Error */
25+
RES_WRPRT, /* 2: Write Protected */
26+
RES_NOTRDY, /* 3: Not Ready */
27+
RES_PARERR /* 4: Invalid Parameter */
28+
} DRESULT;
29+
30+
31+
/*---------------------------------------*/
32+
/* Prototypes for disk control functions */
33+
34+
35+
DSTATUS disk_initialize (BYTE pdrv);
36+
DSTATUS disk_status (BYTE pdrv);
37+
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
38+
#if _USE_WRITE
39+
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
40+
#endif
41+
#if _USE_IOCTL
42+
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
43+
#endif
44+
void disk_timerproc (void);
45+
46+
47+
/* Disk Status Bits (DSTATUS) */
48+
#define STA_NOINIT 0x01 /* Drive not initialized */
49+
#define STA_NODISK 0x02 /* No medium in the drive */
50+
#define STA_PROTECT 0x04 /* Write protected */
51+
52+
53+
/* Command code for disk_ioctrl fucntion */
54+
55+
/* Generic command (used by FatFs) */
56+
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
57+
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
58+
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
59+
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
60+
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
61+
62+
/* Generic command (not used by FatFs) */
63+
#define CTRL_POWER 5 /* Get/Set power status */
64+
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
65+
#define CTRL_EJECT 7 /* Eject media */
66+
#define CTRL_FORMAT 8 /* Create physical format on the media */
67+
68+
/* MMC/SDC specific ioctl command */
69+
#define MMC_GET_TYPE 10 /* Get card type */
70+
#define MMC_GET_CSD 11 /* Get CSD */
71+
#define MMC_GET_CID 12 /* Get CID */
72+
#define MMC_GET_OCR 13 /* Get OCR */
73+
#define MMC_GET_SDSTAT 14 /* Get SD status */
74+
75+
/* ATA/CF specific ioctl command */
76+
#define ATA_GET_REV 20 /* Get F/W revision */
77+
#define ATA_GET_MODEL 21 /* Get model name */
78+
#define ATA_GET_SN 22 /* Get serial number */
79+
80+
/* MMC card type flags (MMC_GET_TYPE) */
81+
#define CT_MMC 0x01 /* MMC ver 3 */
82+
#define CT_SD1 0x02 /* SD ver 1 */
83+
#define CT_SD2 0x04 /* SD ver 2 */
84+
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
85+
#define CT_BLOCK 0x08 /* Block addressing */
86+
87+
88+
#ifdef __cplusplus
89+
}
90+
#endif
91+
92+
#endif

‎ff.c

+4,585
Large diffs are not rendered by default.

‎ff.h

+344
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
/*---------------------------------------------------------------------------/
2+
/ FatFs - FAT file system module include file R0.10a (C)ChaN, 2014
3+
/----------------------------------------------------------------------------/
4+
/ FatFs module is a generic FAT file system module for small embedded systems.
5+
/ This is a free software that opened for education, research and commercial
6+
/ developments under license policy of following terms.
7+
/
8+
/ Copyright (C) 2014, ChaN, all right reserved.
9+
/
10+
/ * The FatFs module is a free software and there is NO WARRANTY.
11+
/ * No restriction on use. You can use, modify and redistribute it for
12+
/ personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
13+
/ * Redistributions of source code must retain the above copyright notice.
14+
/
15+
/----------------------------------------------------------------------------*/
16+
17+
#ifndef _FATFS
18+
#define _FATFS 29000 /* Revision ID */
19+
20+
#define IMAGEBUFF_LEN 2400
21+
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
26+
#include "integer.h" /* Basic integer types */
27+
#include "ffconf.h" /* FatFs configuration options */
28+
29+
#if _FATFS != _FFCONF
30+
#error Wrong configuration file (ffconf.h).
31+
#endif
32+
33+
34+
35+
/* Definitions of volume management */
36+
37+
#if _MULTI_PARTITION /* Multiple partition configuration */
38+
typedef struct {
39+
BYTE pd; /* Physical drive number */
40+
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
41+
} PARTITION;
42+
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
43+
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
44+
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
45+
46+
#else /* Single partition configuration */
47+
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
48+
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
49+
50+
#endif
51+
52+
53+
54+
/* Type of path name strings on FatFs API */
55+
56+
#if _LFN_UNICODE /* Unicode string */
57+
#if !_USE_LFN
58+
#error _LFN_UNICODE must be 0 in non-LFN cfg.
59+
#endif
60+
#ifndef _INC_TCHAR
61+
typedef WCHAR TCHAR;
62+
#define _T(x) L ## x
63+
#define _TEXT(x) L ## x
64+
#endif
65+
66+
#else /* ANSI/OEM string */
67+
#ifndef _INC_TCHAR
68+
typedef char TCHAR;
69+
#define _T(x) x
70+
#define _TEXT(x) x
71+
#endif
72+
73+
#endif
74+
75+
76+
77+
/* File system object structure (FATFS) */
78+
79+
typedef struct {
80+
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
81+
BYTE drv; /* Physical drive number */
82+
BYTE csize; /* Sectors per cluster (1,2,4...128) */
83+
BYTE n_fats; /* Number of FAT copies (1 or 2) */
84+
BYTE wflag; /* win[] flag (b0:dirty) */
85+
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
86+
WORD id; /* File system mount ID */
87+
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
88+
#if _MAX_SS != _MIN_SS
89+
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
90+
#endif
91+
#if _FS_REENTRANT
92+
_SYNC_t sobj; /* Identifier of sync object */
93+
#endif
94+
#if !_FS_READONLY
95+
DWORD last_clust; /* Last allocated cluster */
96+
DWORD free_clust; /* Number of free clusters */
97+
#endif
98+
#if _FS_RPATH
99+
DWORD cdir; /* Current directory start cluster (0:root) */
100+
#endif
101+
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
102+
DWORD fsize; /* Sectors per FAT */
103+
DWORD volbase; /* Volume start sector */
104+
DWORD fatbase; /* FAT start sector */
105+
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
106+
DWORD database; /* Data start sector */
107+
DWORD winsect; /* Current sector appearing in the win[] */
108+
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
109+
} FATFS;
110+
111+
112+
113+
/* File object structure (FIL) */
114+
115+
typedef struct {
116+
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
117+
WORD id; /* Owner file system mount ID (**do not change order**) */
118+
BYTE flag; /* File status flags */
119+
BYTE err; /* Abort flag (error code) */
120+
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
121+
DWORD fsize; /* File size */
122+
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
123+
DWORD clust; /* Current cluster of fpter */
124+
DWORD dsect; /* Current data sector of fpter */
125+
#if !_FS_READONLY
126+
DWORD dir_sect; /* Sector containing the directory entry */
127+
BYTE* dir_ptr; /* Pointer to the directory entry in the window */
128+
#endif
129+
#if _USE_FASTSEEK
130+
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
131+
#endif
132+
#if _FS_LOCK
133+
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
134+
#endif
135+
#if !_FS_TINY
136+
BYTE buf[_MAX_SS]; /* File data read/write buffer */
137+
#endif
138+
} FIL;
139+
140+
141+
142+
/* Directory object structure (DIR) */
143+
144+
typedef struct {
145+
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
146+
WORD id; /* Owner file system mount ID (**do not change order**) */
147+
WORD index; /* Current read/write index number */
148+
DWORD sclust; /* Table start cluster (0:Root dir) */
149+
DWORD clust; /* Current cluster */
150+
DWORD sect; /* Current sector */
151+
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
152+
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
153+
#if _FS_LOCK
154+
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
155+
#endif
156+
#if _USE_LFN
157+
WCHAR* lfn; /* Pointer to the LFN working buffer */
158+
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
159+
#endif
160+
} DIR;
161+
162+
163+
164+
/* File status structure (FILINFO) */
165+
166+
typedef struct {
167+
DWORD fsize; /* File size */
168+
WORD fdate; /* Last modified date */
169+
WORD ftime; /* Last modified time */
170+
BYTE fattrib; /* Attribute */
171+
TCHAR fname[13]; /* Short file name (8.3 format) */
172+
#if _USE_LFN
173+
TCHAR* lfname; /* Pointer to the LFN buffer */
174+
UINT lfsize; /* Size of LFN buffer in TCHAR */
175+
#endif
176+
} FILINFO;
177+
178+
179+
180+
/* File function return code (FRESULT) */
181+
182+
typedef enum {
183+
FR_OK = 0, /* (0) Succeeded */
184+
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
185+
FR_INT_ERR, /* (2) Assertion failed */
186+
FR_NOT_READY, /* (3) The physical drive cannot work */
187+
FR_NO_FILE, /* (4) Could not find the file */
188+
FR_NO_PATH, /* (5) Could not find the path */
189+
FR_INVALID_NAME, /* (6) The path name format is invalid */
190+
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
191+
FR_EXIST, /* (8) Access denied due to prohibited access */
192+
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
193+
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
194+
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
195+
FR_NOT_ENABLED, /* (12) The volume has no work area */
196+
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
197+
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
198+
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
199+
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
200+
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
201+
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
202+
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
203+
} FRESULT;
204+
205+
206+
207+
/*--------------------------------------------------------------*/
208+
/* FatFs module application interface */
209+
210+
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
211+
FRESULT f_close (FIL* fp); /* Close an open file object */
212+
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
213+
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
214+
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
215+
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
216+
FRESULT f_truncate (FIL* fp); /* Truncate file */
217+
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
218+
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
219+
FRESULT f_closedir (DIR* dp); /* Close an open directory */
220+
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
221+
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
222+
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
223+
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
224+
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
225+
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
226+
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
227+
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
228+
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
229+
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
230+
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
231+
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* sn); /* Get volume label */
232+
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
233+
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
234+
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
235+
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
236+
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
237+
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
238+
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
239+
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
240+
241+
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
242+
#define f_error(fp) ((fp)->err)
243+
#define f_tell(fp) ((fp)->fptr)
244+
#define f_size(fp) ((fp)->fsize)
245+
246+
#ifndef EOF
247+
#define EOF (-1)
248+
#endif
249+
250+
251+
252+
253+
/*--------------------------------------------------------------*/
254+
/* Additional user defined functions */
255+
256+
/* RTC function */
257+
#if !_FS_READONLY
258+
DWORD get_fattime (void);
259+
#endif
260+
261+
/* Unicode support functions */
262+
#if _USE_LFN /* Unicode - OEM code conversion */
263+
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
264+
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
265+
#if _USE_LFN == 3 /* Memory functions */
266+
void* ff_memalloc (UINT msize); /* Allocate memory block */
267+
void ff_memfree (void* mblock); /* Free memory block */
268+
#endif
269+
#endif
270+
271+
/* Sync functions */
272+
#if _FS_REENTRANT
273+
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
274+
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
275+
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
276+
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
277+
#endif
278+
279+
280+
281+
282+
/*--------------------------------------------------------------*/
283+
/* Flags and offset address */
284+
285+
286+
/* File access control and file status flags (FIL.flag) */
287+
288+
#define FA_READ 0x01
289+
#define FA_OPEN_EXISTING 0x00
290+
291+
#if !_FS_READONLY
292+
#define FA_WRITE 0x02
293+
#define FA_CREATE_NEW 0x04
294+
#define FA_CREATE_ALWAYS 0x08
295+
#define FA_OPEN_ALWAYS 0x10
296+
#define FA__WRITTEN 0x20
297+
#define FA__DIRTY 0x40
298+
#endif
299+
300+
301+
/* FAT sub type (FATFS.fs_type) */
302+
303+
#define FS_FAT12 1
304+
#define FS_FAT16 2
305+
#define FS_FAT32 3
306+
307+
308+
/* File attribute bits for directory entry */
309+
310+
#define AM_RDO 0x01 /* Read only */
311+
#define AM_HID 0x02 /* Hidden */
312+
#define AM_SYS 0x04 /* System */
313+
#define AM_VOL 0x08 /* Volume label */
314+
#define AM_LFN 0x0F /* LFN entry */
315+
#define AM_DIR 0x10 /* Directory */
316+
#define AM_ARC 0x20 /* Archive */
317+
#define AM_MASK 0x3F /* Mask of defined bits */
318+
319+
320+
/* Fast seek feature */
321+
#define CREATE_LINKMAP 0xFFFFFFFF
322+
323+
324+
325+
/*--------------------------------*/
326+
/* Multi-byte word access macros */
327+
328+
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
329+
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
330+
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
331+
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
332+
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
333+
#else /* Use byte-by-byte access to the FAT structure */
334+
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
335+
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
336+
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
337+
#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)
338+
#endif
339+
340+
#ifdef __cplusplus
341+
}
342+
#endif
343+
344+
#endif /* _FATFS */

‎ffconf.h

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
/*---------------------------------------------------------------------------/
2+
/ FatFs - FAT file system module configuration file R0.10a (C)ChaN, 2014
3+
/---------------------------------------------------------------------------*/
4+
5+
#ifndef _FFCONF
6+
#define _FFCONF 29000 /* Revision ID */
7+
8+
9+
/*---------------------------------------------------------------------------/
10+
/ Functions and Buffer Configurations
11+
/---------------------------------------------------------------------------*/
12+
13+
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
14+
/* When _FS_TINY is set to 1, it reduces memory consumption _MAX_SS bytes each
15+
/ file object. For file data transfer, FatFs uses the common sector buffer in
16+
/ the file system object (FATFS) instead of private sector buffer eliminated
17+
/ from the file object (FIL). */
18+
19+
20+
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
21+
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
22+
/ writing functions, f_write(), f_sync(), f_unlink(), f_mkdir(), f_chmod(),
23+
/ f_rename(), f_truncate() and useless f_getfree(). */
24+
25+
26+
#define _FS_MINIMIZE 0 /* 0 to 3 */
27+
/* The _FS_MINIMIZE option defines minimization level to remove API functions.
28+
/
29+
/ 0: All basic functions are enabled.
30+
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
31+
/ f_truncate() and f_rename() function are removed.
32+
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
33+
/ 3: f_lseek() function is removed in addition to 2. */
34+
35+
36+
#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
37+
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
38+
39+
40+
#define _USE_MKFS 1 /* 0:Disable or 1:Enable */
41+
/* To enable f_mkfs() function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
42+
43+
44+
#define _USE_FASTSEEK 1 /* 0:Disable or 1:Enable */
45+
/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
46+
47+
48+
#define _USE_LABEL 1 /* 0:Disable or 1:Enable */
49+
/* To enable volume label functions, set _USE_LAVEL to 1 */
50+
51+
52+
#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
53+
/* To enable f_forward() function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
54+
55+
56+
/*---------------------------------------------------------------------------/
57+
/ Locale and Namespace Configurations
58+
/---------------------------------------------------------------------------*/
59+
60+
#define _CODE_PAGE 437
61+
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
62+
/ Incorrect setting of the code page can cause a file open failure.
63+
/
64+
/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows)
65+
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
66+
/ 949 - Korean (DBCS, OEM, Windows)
67+
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
68+
/ 1250 - Central Europe (Windows)
69+
/ 1251 - Cyrillic (Windows)
70+
/ 1252 - Latin 1 (Windows)
71+
/ 1253 - Greek (Windows)
72+
/ 1254 - Turkish (Windows)
73+
/ 1255 - Hebrew (Windows)
74+
/ 1256 - Arabic (Windows)
75+
/ 1257 - Baltic (Windows)
76+
/ 1258 - Vietnam (OEM, Windows)
77+
/ 437 - U.S. (OEM)
78+
/ 720 - Arabic (OEM)
79+
/ 737 - Greek (OEM)
80+
/ 775 - Baltic (OEM)
81+
/ 850 - Multilingual Latin 1 (OEM)
82+
/ 858 - Multilingual Latin 1 + Euro (OEM)
83+
/ 852 - Latin 2 (OEM)
84+
/ 855 - Cyrillic (OEM)
85+
/ 866 - Russian (OEM)
86+
/ 857 - Turkish (OEM)
87+
/ 862 - Hebrew (OEM)
88+
/ 874 - Thai (OEM, Windows)
89+
/ 1 - ASCII (Valid for only non-LFN cfg.) */
90+
91+
92+
#define _USE_LFN 0 /* 0 to 3 */
93+
#define _MAX_LFN 128 /* Maximum LFN length to handle (12 to 255) */
94+
/* The _USE_LFN option switches the LFN feature.
95+
/
96+
/ 0: Disable LFN feature. _MAX_LFN and _LFN_UNICODE have no effect.
97+
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
98+
/ 2: Enable LFN with dynamic working buffer on the STACK.
99+
/ 3: Enable LFN with dynamic working buffer on the HEAP.
100+
/
101+
/ When enable LFN feature, Unicode handling functions ff_convert() and ff_wtoupper()
102+
/ function must be added to the project.
103+
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. When use stack for the
104+
/ working buffer, take care on stack overflow. When use heap memory for the working
105+
/ buffer, memory management functions, ff_memalloc() and ff_memfree(), must be added
106+
/ to the project. */
107+
108+
109+
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
110+
/* To switch the character encoding on the FatFs API (TCHAR) to Unicode, enable LFN
111+
/ feature and set _LFN_UNICODE to 1. This option affects behavior of string I/O
112+
/ functions. */
113+
114+
115+
#define _STRF_ENCODE 3 /* 0:ANSI/OEM, 1:UTF-16LE, 2:UTF-16BE, 3:UTF-8 */
116+
/* When Unicode API is enabled by _LFN_UNICODE option, this option selects the character
117+
/ encoding on the file to be read/written via string I/O functions, f_gets(), f_putc(),
118+
/ f_puts and f_printf(). This option has no effect when Unicode API is not enabled. */
119+
120+
121+
#define _FS_RPATH 2 /* 0 to 2 */
122+
/* The _FS_RPATH option configures relative path feature.
123+
/
124+
/ 0: Disable relative path feature and remove related functions.
125+
/ 1: Enable relative path. f_chdrive() and f_chdir() function are available.
126+
/ 2: f_getcwd() function is available in addition to 1.
127+
/
128+
/ Note that output of the f_readdir() fnction is affected by this option. */
129+
130+
131+
/*---------------------------------------------------------------------------/
132+
/ Drive/Volume Configurations
133+
/---------------------------------------------------------------------------*/
134+
135+
#define _VOLUMES 1
136+
/* Number of volumes (logical drives) to be used. */
137+
138+
139+
#define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */
140+
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
141+
/* When _STR_VOLUME_ID is set to 1, also pre-defined string can be used as drive number
142+
/ in the path name. _VOLUME_STRS defines the drive ID strings for each logical drives.
143+
/ Number of items must be equal to _VOLUMES. Valid characters for the drive ID strings
144+
/ are: 0-9 and A-Z. */
145+
146+
147+
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Enable multiple partition */
148+
/* By default(0), each logical drive number is bound to the same physical drive number
149+
/ and only a FAT volume found on the physical drive is mounted. When it is set to 1,
150+
/ each logical drive number is bound to arbitrary drive/partition listed in VolToPart[].
151+
*/
152+
153+
154+
#define _MIN_SS 512
155+
#define _MAX_SS 512
156+
/* These options configure the sector size to be supported. (512, 1024, 2048 or 4096)
157+
/ Always set both 512 for most systems, all memory card and hard disk. But a larger
158+
/ value may be required for on-board flash memory and some type of optical media.
159+
/ When _MIN_SS != _MAX_SS, FatFs is configured to multiple sector size and
160+
/ GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */
161+
162+
163+
#define _USE_ERASE 0 /* 0:Disable or 1:Enable */
164+
/* To enable sector erase feature, set _USE_ERASE to 1. Also CTRL_ERASE_SECTOR command
165+
/ should be added to the disk_ioctl() function. */
166+
167+
168+
#define _FS_NOFSINFO 0 /* 0 to 3 */
169+
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
170+
/ option and f_getfree() function at first time after volume mount will force
171+
/ a full FAT scan. Bit 1 controls the last allocated cluster number as bit 0.
172+
/
173+
/ bit0=0: Use free cluster count in the FSINFO if available.
174+
/ bit0=1: Do not trust free cluster count in the FSINFO.
175+
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
176+
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
177+
*/
178+
179+
180+
181+
/*---------------------------------------------------------------------------/
182+
/ System Configurations
183+
/---------------------------------------------------------------------------*/
184+
185+
#define _WORD_ACCESS 0 /* 0 or 1 */
186+
/* The _WORD_ACCESS option is an only platform dependent option. It defines
187+
/ which access method is used to the word data on the FAT volume.
188+
/
189+
/ 0: Byte-by-byte access. Always compatible with all platforms.
190+
/ 1: Word access. Do not choose this unless under both the following conditions.
191+
/
192+
/ * Address misaligned memory access is always allowed for all instructions.
193+
/ * Byte order on the memory is little-endian.
194+
/
195+
/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance
196+
/ and reduce code size.
197+
*/
198+
199+
200+
#define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
201+
/* To enable file lock control feature, set _FS_LOCK to 1 or greater.
202+
/ The value defines how many files/sub-directories can be opened simultaneously.
203+
/ This feature consumes _FS_LOCK * 12 bytes of bss area. */
204+
205+
206+
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
207+
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
208+
#define _SYNC_t HANDLE /* O/S dependent sync object type. e.g. HANDLE, OS_EVENT*, ID and etc.. */
209+
/*#include <windows.h>*/
210+
211+
/* A header file that defines sync object types on the O/S, such as windows.h,
212+
/ ucos_ii.h and semphr.h, should be included here when enable this option.
213+
/ The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module.
214+
/
215+
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
216+
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
217+
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
218+
/ function must be added to the project.
219+
*/
220+
221+
222+
#endif /* _FFCONFIG */

‎ft5206.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#include "fubsd.h"
2+
#include <plib.h>
13
#include "i2c2.h"
24
#include "ft5206.h"
3-
#include "main.h"
5+
46

57
Touch ts_event;
68

‎ft5206.h

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef FT5206_H
22
#define FT5206_H
3-
4-
#include "fubsd.h"
5-
#include <plib.h>
3+
#include "main.h"
64

75
void _nop_();
86
/* touch panel interface define */
@@ -17,18 +15,17 @@ void _nop_();
1715
#define Key_Up 0x00
1816

1917

20-
2118
typedef struct _Touch_ {
22-
UINT x1;
23-
UINT y1;
24-
UINT x2;
25-
UINT y2;
26-
UINT x3;
27-
UINT y3;
28-
UINT x4;
29-
UINT y4;
30-
UINT x5;
31-
UINT y5;
19+
unsigned int x1;
20+
unsigned int y1;
21+
unsigned int x2;
22+
unsigned int y2;
23+
unsigned int x3;
24+
unsigned int y3;
25+
unsigned int x4;
26+
unsigned int y4;
27+
unsigned int x5;
28+
unsigned int y5;
3229
unsigned char touch_point;
3330
unsigned char Key_Sta;
3431
} Touch;
@@ -52,7 +49,7 @@ unsigned char TOUCH_Read_Byte(unsigned char ack);
5249
void TOUCH_Wr_Reg(unsigned char RegIndex,unsigned char RegValue1);
5350
void TOUCH_RdParFrPCTPFun(unsigned char *PCTP_Par,unsigned char ValFlag);
5451
unsigned char TOUCH_Read_Reg(unsigned char RegIndex);
55-
void Draw_Big_Point(UINT x,UINT y,UINT colour);
52+
void Draw_Big_Point(unsigned int x,unsigned int y,unsigned int colour);
5653
unsigned char ft5x0x_read_data(void); //unsigned char ft5x0x_read_data(void);
5754

5855
char CheckPen(void);

‎integer.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*-------------------------------------------*/
2+
/* Integer type definitions for FatFs module */
3+
/*-------------------------------------------*/
4+
5+
#ifndef _FF_INTEGER
6+
#define _FF_INTEGER
7+
8+
#ifdef _WIN32 /* FatFs development platform */
9+
10+
#include <windows.h>
11+
#include <tchar.h>
12+
13+
#else /* Embedded platform */
14+
15+
/* This type MUST be 8 bit */
16+
typedef unsigned char BYTE;
17+
18+
/* These types MUST be 16 bit */
19+
typedef short SHORT;
20+
typedef unsigned short WORD;
21+
typedef unsigned short WCHAR;
22+
23+
/* These types MUST be 16 bit or 32 bit */
24+
typedef int INT;
25+
typedef unsigned int UINT;
26+
27+
/* These types MUST be 32 bit */
28+
typedef long LONG;
29+
typedef unsigned long DWORD;
30+
31+
#endif
32+
33+
#endif

‎keyboard.c

+762
Large diffs are not rendered by default.

‎keyboard.h

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* File: keyboard.h
3+
* Author: Jason
4+
*
5+
* Created on July 7, 2014, 2:10 PM
6+
*
7+
*
8+
BACKSPACE = 0x08
9+
TAB = 0x09
10+
CAP = 0x1c
11+
SHIFT = 0x1d
12+
ENTER = 0x0D
13+
SPACE = 0x20
14+
*
15+
*
16+
*/
17+
#ifndef KEYBOARD_H
18+
#define KEYBOARD_H
19+
20+
#include "ft5206.h"
21+
22+
typedef struct _KB_KEY_ {
23+
unsigned int top;
24+
unsigned int left;
25+
unsigned int width;
26+
unsigned int height;
27+
char ascii;
28+
} KB_Key;
29+
30+
typedef struct _Keyboard_ {
31+
unsigned int top;
32+
unsigned int left;
33+
unsigned int width;
34+
unsigned int text_color;
35+
unsigned int back_color;
36+
unsigned int edge_color;
37+
unsigned int key_width;
38+
unsigned int key_height;
39+
unsigned int height;
40+
char caps;
41+
char shift;
42+
KB_Key keys[128];
43+
} Keyboard;
44+
45+
#define CAPS 2
46+
#define SHIFT 1
47+
#define NOSHIFT 0
48+
49+
Keyboard draw_kb(char isShift, unsigned int left, unsigned int top, unsigned int width, unsigned int ecolor, unsigned int bcolor, unsigned int tcolor);
50+
Keyboard draw_no_shift(unsigned int left, unsigned int top, unsigned int width, unsigned int ecolor, unsigned int bcolor, unsigned int tcolor);
51+
Keyboard draw_shift(unsigned int left, unsigned int top, unsigned int width, unsigned int ecolor, unsigned int bcolor, unsigned int tcolor);
52+
unsigned int draw_keys(unsigned int top, unsigned int left, char key_scale, char *text);
53+
unsigned int getLen (char *text);
54+
55+
char isKey(Keyboard kb, unsigned int left, unsigned int top);
56+
#endif /* KEYBOARD_H */
57+

‎main.c

+214-38
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
#include "RA8875.h"
1818
#include "ft5206.h"
1919

20+
#include "spi2.h"
21+
#include "ff.h"
22+
#include "diskio.h"
23+
24+
#include "keyboard.h"
25+
2026
//* Oscillator Settings
2127
#pragma config FNOSC = PRIPLL // Oscillator selection
2228
#pragma config POSCMOD = HS // Primary oscillator mode
@@ -65,17 +71,28 @@
6571
#define T1_TICK (SYS_FREQ/PB_DIV/PRESCALE/TOGGLES_PER_SEC)
6672

6773

68-
uint fColor = color_black;
69-
uint bColor = color_white;
74+
unsigned int fColor = color_black;
75+
unsigned int bColor = color_white;
7076

7177
char usr_msg[128];
7278

7379
void init_board(void);
7480

7581
Touch OldTouch;
82+
FATFS fs; // Work area (file system object) for the volume
83+
BYTE FILE_IN_BUFF[512];
84+
DSTATUS iStat;
85+
char messageOut[128];
86+
FIL fil; /* File object */
87+
char line[82]; /* Line buffer */
88+
volatile Keyboard AtomKB;
7689

7790
void main() {
78-
int fSize = 20;
91+
int fSize = 30;
92+
unsigned int tryCount = 1;
93+
unsigned int FFST = 0;
94+
unsigned int i,t;
95+
char keytemp;
7996

8097
init_board();
8198
TRISEbits.TRISE5 = 0; //USR_LED = output
@@ -100,83 +117,248 @@ void main() {
100117
FontWrite_Position(0,50);
101118
String(" LCD Mode: 8080 - 8bit");
102119

103-
while(1)
120+
FontWrite_Position(0,90);
121+
String(" Insert SD Card...Waiting");
122+
123+
SpiChnClose(2);
124+
SpiInitDevice(2,SPI_SLOWEST,0);
125+
126+
while(isCD() == 1);
127+
FontWrite_Position(0,110);
128+
String(" SD Card...Found!");
129+
130+
do
131+
{
132+
while(isCD() == 1);
133+
iStat = FR_NOT_READY;
134+
Delay10ms(20);
135+
FontWrite_Position(0,130);
136+
137+
sprintf(messageOut, " Mounting SD Card with Elm Chan's FatFS. Try #%d \0", tryCount);
138+
String(messageOut);
139+
tryCount++;
140+
iStat = f_mount(&fs, "", 1);//(&fs); //MountSD(fs);
141+
}
142+
while(iStat != FR_OK);
143+
144+
if(fs.fs_type == FS_FAT12)
145+
FFST = 12;
146+
if(fs.fs_type == FS_FAT16)
147+
FFST = 16;
148+
if(fs.fs_type == FS_FAT32)
149+
FFST = 32;
150+
151+
SpiChnClose(2);
152+
SpiInitDevice(2,SPI_MED1,0);
153+
154+
FontWrite_Position(0,150);
155+
sprintf(messageOut, " SD Card Filesystem... FAT%d \0", FFST);
156+
String(messageOut);
157+
158+
FontWrite_Position(0,190);
159+
sprintf(messageOut, " Initiating Keyboard... \0");
160+
String(messageOut);
161+
162+
for(i=0;i<5;i++)
104163
{
164+
FontWrite_Position(0,210);
165+
sprintf(messageOut, " Loading in ... %d\0", (5-i));
166+
String(messageOut);
167+
delay_ms(999);
168+
}
169+
170+
/*
171+
SetColors(fColor,bColor);//delay_ms(2);
172+
ClearScreen(0);delay_ms(30);
173+
draw_kb(SHIFT,100,260,600,color_black,color_white,color_black);
174+
delay_ms(2000);
175+
176+
SetColors(fColor,bColor);//delay_ms(2);
177+
ClearScreen(0);delay_ms(30);
178+
draw_kb(SHIFT,100,260,600,color_black,color_red,color_white);
179+
delay_ms(2000);
180+
181+
SetColors(fColor,bColor);//delay_ms(2);
182+
ClearScreen(0);delay_ms(30);
183+
draw_kb(SHIFT,100,260,600,color_black,color_purple,color_white);
184+
delay_ms(2000);
185+
*/
186+
SetColors(fColor,bColor);//delay_ms(2);
187+
ClearScreen(0);delay_ms(30);
188+
AtomKB = draw_kb(NOSHIFT,100,200,600,color_black,color_blue,color_white);
189+
190+
SetColors(fColor,bColor);//delay_ms(2);
191+
192+
for(i=0;i<128;i++)
193+
messageOut[i] = 0x20;
194+
195+
messageOut[0] = '_';
196+
i = 0;
105197

198+
while(1)
199+
{
106200
if(CheckPen() == 0) //The touch screen is pressed
107201
{
108202
do
109203
{
110204
ft5x0x_read_data();
111205

112-
SetColors(fColor,bColor);
206+
keytemp = isKey(AtomKB, ts_event.x1,ts_event.y1);
207+
208+
if(keytemp)
209+
{
210+
if(i == 100)
211+
{
212+
i = 0; //RESET CUR POS IN BUFF
213+
for(t=0;t<128;t++){
214+
messageOut[t] = 0x20;
215+
messageOut[0] = '_';
216+
}
217+
}
218+
219+
220+
221+
if(AtomKB.shift == 1)
222+
{
223+
if(AtomKB.caps == 0)
224+
{
225+
AtomKB = draw_kb(NOSHIFT,100,200,600,color_black,color_blue,color_white);
226+
}
227+
}
228+
switch(keytemp)
229+
{
230+
case 0x08: //DEL
231+
if((i > 0))
232+
i--;
233+
234+
messageOut[i] = 0x20;
235+
messageOut[i+1] = 0x20;
236+
messageOut[i] = '_';
237+
break;
238+
case 0x0d: //RETURN
239+
messageOut[i++] = '[';
240+
messageOut[i++] = 'E';
241+
messageOut[i++] = 'N';
242+
messageOut[i++] = 'T';
243+
messageOut[i++] = ']';
244+
messageOut[i] = '_';
245+
break;
246+
case 0x09: //TAB
247+
messageOut[i++] = '[';
248+
messageOut[i++] = 'T';
249+
messageOut[i++] = 'A';
250+
messageOut[i++] = 'B';
251+
messageOut[i++] = ']';
252+
messageOut[i] = '_';
253+
break;
254+
case 0x1c:
255+
if(AtomKB.caps == 0){
256+
AtomKB = draw_kb(CAPS,100,200,600,color_black,color_blue,color_white);
257+
}else{
258+
AtomKB = draw_kb(NOSHIFT,100,200,600,color_black,color_blue,color_white);
259+
}
260+
break;
261+
case 0x1d:
262+
if(AtomKB.caps == 1) break;
263+
264+
if(AtomKB.shift == 0){
265+
AtomKB = draw_kb(SHIFT,100,200,600,color_black,color_blue,color_white);
266+
} else {
267+
AtomKB = draw_kb(NOSHIFT,100,200,600,color_black,color_blue,color_white);
268+
}
269+
break;
270+
default:
271+
messageOut[i++] = keytemp;
272+
messageOut[i] = '_';
273+
break;
274+
}
275+
SetColors(fColor,bColor);
276+
FontWrite_Position(10,100);
277+
String(messageOut);
278+
delay_ms(160);
279+
}
280+
}while(isPEN()==0);
113281

114-
FontWrite_Position(0,10);
115-
String(" AtomSoftTech - RA8875 7\" TFT with Capacitive Touch");
116282

117-
FontWrite_Position(0,30);
118-
String(" MCU: PIC32MX795F512H");
283+
ts_event.Key_Sta=Key_Up;
284+
}
285+
}
286+
while(1); //TEST STOP HERE
119287

120-
FontWrite_Position(0,50);
121-
String(" LCD Mode: 8080 - 8bit");
288+
SetColors(fColor,bColor);
289+
//OpenASI("main.asi",0,0);
290+
delay_ms(10000);
291+
ClearScreen(0);
292+
delay_ms(200);
293+
294+
while(1)
295+
{
296+
297+
if(CheckPen() == 0) //The touch screen is pressed
298+
{
299+
do
300+
{
301+
ft5x0x_read_data();
122302

123-
FontWrite_Position(0,100);
303+
SetColors(fColor,bColor);
304+
305+
FontWrite_Position(0,180);
124306
sprintf(usr_msg, " X1: %i ",ts_event.x1);
125307
String(usr_msg);
126308

127-
FontWrite_Position(0,120);
309+
FontWrite_Position(0,200);
128310
sprintf(usr_msg, " Y1: %i ",ts_event.y1);
129311
String(usr_msg);
130312

131-
FontWrite_Position(0,150);
313+
FontWrite_Position(0,230);
132314
sprintf(usr_msg, " X2: %i ",ts_event.x2);
133315
String(usr_msg);
134316

135-
FontWrite_Position(0,170);
317+
FontWrite_Position(0,250);
136318
sprintf(usr_msg, " Y2: %i ",ts_event.y2);
137319
String(usr_msg);
138320

139-
FontWrite_Position(0,200);
321+
FontWrite_Position(0,280);
140322
sprintf(usr_msg, " X3: %i ",ts_event.x3);
141323
String(usr_msg);
142324

143-
FontWrite_Position(0,220);
325+
FontWrite_Position(0,300);
144326
sprintf(usr_msg, " Y3: %i ",ts_event.y3);
145327
String(usr_msg);
146328

147-
FontWrite_Position(0,250);
329+
FontWrite_Position(0,330);
148330
sprintf(usr_msg, " X4: %i ",ts_event.x4);
149331
String(usr_msg);
150332

151-
FontWrite_Position(0,270);
333+
FontWrite_Position(0,350);
152334
sprintf(usr_msg, " Y4: %i ",ts_event.y4);
153335
String(usr_msg);
154336

155-
FontWrite_Position(0,300);
337+
FontWrite_Position(0,380);
156338
sprintf(usr_msg, " X5: %i ",ts_event.x5);
157339
String(usr_msg);
158340

159-
FontWrite_Position(0,320);
341+
FontWrite_Position(0,400);
160342
sprintf(usr_msg, " Y5: %i ",ts_event.y5);
161343
String(usr_msg);
162344

163345
switch(ts_event.touch_point)
164346
{
165347
case 5:
166-
DrawCircle(OldTouch.x5,OldTouch.y5,fSize,color_white,1);delay_us((fSize*10));
167-
DrawCircle(ts_event.x5,ts_event.y5,fSize,color_purple,1);delay_us((fSize*10));
348+
DrawCircle(OldTouch.x5,OldTouch.y5,fSize,color_white,1);delay_us((fSize*15));
349+
DrawCircle(ts_event.x5,ts_event.y5,fSize,color_purple,1);delay_us((fSize*15));
168350
case 4:
169-
DrawCircle(OldTouch.x4,OldTouch.y4,fSize,color_white,1);delay_us((fSize*10));
170-
DrawCircle(ts_event.x4,ts_event.y4,fSize,color_cyan,1);delay_us((fSize*10));
351+
DrawCircle(OldTouch.x4,OldTouch.y4,fSize,color_white,1);delay_us((fSize*15));
352+
DrawCircle(ts_event.x4,ts_event.y4,fSize,color_cyan,1);delay_us((fSize*15));
171353
case 3:
172-
DrawCircle(OldTouch.x3,OldTouch.y3,fSize,color_white,1);delay_us((fSize*10));
173-
DrawCircle(ts_event.x3,ts_event.y3,fSize,color_blue,1);delay_us((fSize*10));
354+
DrawCircle(OldTouch.x3,OldTouch.y3,fSize,color_white,1);delay_us((fSize*15));
355+
DrawCircle(ts_event.x3,ts_event.y3,fSize,color_blue,1);delay_us((fSize*15));
174356
case 2:
175-
DrawCircle(OldTouch.x2,OldTouch.y2,fSize,color_white,1);delay_us((fSize*10));
176-
DrawCircle(ts_event.x2,ts_event.y2,fSize,color_green,1);delay_us((fSize*10));
357+
DrawCircle(OldTouch.x2,OldTouch.y2,fSize,color_white,1);delay_us((fSize*15));
358+
DrawCircle(ts_event.x2,ts_event.y2,fSize,color_green,1);delay_us((fSize*15));
177359
case 1:
178-
DrawCircle(OldTouch.x1,OldTouch.y1,fSize,color_white,1);delay_us((fSize*10));
179-
DrawCircle(ts_event.x1,ts_event.y1,fSize,color_red,1);delay_us((fSize*10));
360+
DrawCircle(OldTouch.x1,OldTouch.y1,fSize,color_white,1);delay_us((fSize*15));
361+
DrawCircle(ts_event.x1,ts_event.y1,fSize,color_red,1);delay_us((fSize*15));
180362
break;
181363
}
182364

@@ -187,13 +369,7 @@ void main() {
187369
ts_event.Key_Sta=Key_Up;
188370
}
189371
}
190-
while(1)
191-
{
192-
USR_LED = 0;
193-
delay_ms(160);
194-
USR_LED = 1;
195-
delay_ms(160);
196-
}
372+
197373
}
198374

199375
void init_board(void)

‎main.h

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef MAIN_H
99
#define MAIN_H
1010

11+
1112
void delay_us(int time);
1213
void delay_ms(int time);
1314

‎mmc_pic24f.c

+552
Large diffs are not rendered by default.

‎nbproject/Makefile-default.mk

+65-5
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
4545
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
4646

4747
# Source Files Quoted if spaced
48-
SOURCEFILES_QUOTED_IF_SPACED=main.c ft5206.c i2c2.c RA8875.c
48+
SOURCEFILES_QUOTED_IF_SPACED=main.c ft5206.c i2c2.c RA8875.c diskio.c mmc_pic24f.c spi2.c ff.c keyboard.c
4949

5050
# Object Files Quoted if spaced
51-
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.o ${OBJECTDIR}/ft5206.o ${OBJECTDIR}/i2c2.o ${OBJECTDIR}/RA8875.o
52-
POSSIBLE_DEPFILES=${OBJECTDIR}/main.o.d ${OBJECTDIR}/ft5206.o.d ${OBJECTDIR}/i2c2.o.d ${OBJECTDIR}/RA8875.o.d
51+
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.o ${OBJECTDIR}/ft5206.o ${OBJECTDIR}/i2c2.o ${OBJECTDIR}/RA8875.o ${OBJECTDIR}/diskio.o ${OBJECTDIR}/mmc_pic24f.o ${OBJECTDIR}/spi2.o ${OBJECTDIR}/ff.o ${OBJECTDIR}/keyboard.o
52+
POSSIBLE_DEPFILES=${OBJECTDIR}/main.o.d ${OBJECTDIR}/ft5206.o.d ${OBJECTDIR}/i2c2.o.d ${OBJECTDIR}/RA8875.o.d ${OBJECTDIR}/diskio.o.d ${OBJECTDIR}/mmc_pic24f.o.d ${OBJECTDIR}/spi2.o.d ${OBJECTDIR}/ff.o.d ${OBJECTDIR}/keyboard.o.d
5353

5454
# Object Files
55-
OBJECTFILES=${OBJECTDIR}/main.o ${OBJECTDIR}/ft5206.o ${OBJECTDIR}/i2c2.o ${OBJECTDIR}/RA8875.o
55+
OBJECTFILES=${OBJECTDIR}/main.o ${OBJECTDIR}/ft5206.o ${OBJECTDIR}/i2c2.o ${OBJECTDIR}/RA8875.o ${OBJECTDIR}/diskio.o ${OBJECTDIR}/mmc_pic24f.o ${OBJECTDIR}/spi2.o ${OBJECTDIR}/ff.o ${OBJECTDIR}/keyboard.o
5656

5757
# Source Files
58-
SOURCEFILES=main.c ft5206.c i2c2.c RA8875.c
58+
SOURCEFILES=main.c ft5206.c i2c2.c RA8875.c diskio.c mmc_pic24f.c spi2.c ff.c keyboard.c
5959

6060

6161
CFLAGS=
@@ -115,6 +115,36 @@ ${OBJECTDIR}/RA8875.o: RA8875.c nbproject/Makefile-${CND_CONF}.mk
115115
@${RM} ${OBJECTDIR}/RA8875.o
116116
@${FIXDEPS} "${OBJECTDIR}/RA8875.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/RA8875.o.d" -o ${OBJECTDIR}/RA8875.o RA8875.c
117117

118+
${OBJECTDIR}/diskio.o: diskio.c nbproject/Makefile-${CND_CONF}.mk
119+
@${MKDIR} ${OBJECTDIR}
120+
@${RM} ${OBJECTDIR}/diskio.o.d
121+
@${RM} ${OBJECTDIR}/diskio.o
122+
@${FIXDEPS} "${OBJECTDIR}/diskio.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/diskio.o.d" -o ${OBJECTDIR}/diskio.o diskio.c
123+
124+
${OBJECTDIR}/mmc_pic24f.o: mmc_pic24f.c nbproject/Makefile-${CND_CONF}.mk
125+
@${MKDIR} ${OBJECTDIR}
126+
@${RM} ${OBJECTDIR}/mmc_pic24f.o.d
127+
@${RM} ${OBJECTDIR}/mmc_pic24f.o
128+
@${FIXDEPS} "${OBJECTDIR}/mmc_pic24f.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mmc_pic24f.o.d" -o ${OBJECTDIR}/mmc_pic24f.o mmc_pic24f.c
129+
130+
${OBJECTDIR}/spi2.o: spi2.c nbproject/Makefile-${CND_CONF}.mk
131+
@${MKDIR} ${OBJECTDIR}
132+
@${RM} ${OBJECTDIR}/spi2.o.d
133+
@${RM} ${OBJECTDIR}/spi2.o
134+
@${FIXDEPS} "${OBJECTDIR}/spi2.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/spi2.o.d" -o ${OBJECTDIR}/spi2.o spi2.c
135+
136+
${OBJECTDIR}/ff.o: ff.c nbproject/Makefile-${CND_CONF}.mk
137+
@${MKDIR} ${OBJECTDIR}
138+
@${RM} ${OBJECTDIR}/ff.o.d
139+
@${RM} ${OBJECTDIR}/ff.o
140+
@${FIXDEPS} "${OBJECTDIR}/ff.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/ff.o.d" -o ${OBJECTDIR}/ff.o ff.c
141+
142+
${OBJECTDIR}/keyboard.o: keyboard.c nbproject/Makefile-${CND_CONF}.mk
143+
@${MKDIR} ${OBJECTDIR}
144+
@${RM} ${OBJECTDIR}/keyboard.o.d
145+
@${RM} ${OBJECTDIR}/keyboard.o
146+
@${FIXDEPS} "${OBJECTDIR}/keyboard.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/keyboard.o.d" -o ${OBJECTDIR}/keyboard.o keyboard.c
147+
118148
else
119149
${OBJECTDIR}/main.o: main.c nbproject/Makefile-${CND_CONF}.mk
120150
@${MKDIR} ${OBJECTDIR}
@@ -140,6 +170,36 @@ ${OBJECTDIR}/RA8875.o: RA8875.c nbproject/Makefile-${CND_CONF}.mk
140170
@${RM} ${OBJECTDIR}/RA8875.o
141171
@${FIXDEPS} "${OBJECTDIR}/RA8875.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/RA8875.o.d" -o ${OBJECTDIR}/RA8875.o RA8875.c
142172

173+
${OBJECTDIR}/diskio.o: diskio.c nbproject/Makefile-${CND_CONF}.mk
174+
@${MKDIR} ${OBJECTDIR}
175+
@${RM} ${OBJECTDIR}/diskio.o.d
176+
@${RM} ${OBJECTDIR}/diskio.o
177+
@${FIXDEPS} "${OBJECTDIR}/diskio.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/diskio.o.d" -o ${OBJECTDIR}/diskio.o diskio.c
178+
179+
${OBJECTDIR}/mmc_pic24f.o: mmc_pic24f.c nbproject/Makefile-${CND_CONF}.mk
180+
@${MKDIR} ${OBJECTDIR}
181+
@${RM} ${OBJECTDIR}/mmc_pic24f.o.d
182+
@${RM} ${OBJECTDIR}/mmc_pic24f.o
183+
@${FIXDEPS} "${OBJECTDIR}/mmc_pic24f.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mmc_pic24f.o.d" -o ${OBJECTDIR}/mmc_pic24f.o mmc_pic24f.c
184+
185+
${OBJECTDIR}/spi2.o: spi2.c nbproject/Makefile-${CND_CONF}.mk
186+
@${MKDIR} ${OBJECTDIR}
187+
@${RM} ${OBJECTDIR}/spi2.o.d
188+
@${RM} ${OBJECTDIR}/spi2.o
189+
@${FIXDEPS} "${OBJECTDIR}/spi2.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/spi2.o.d" -o ${OBJECTDIR}/spi2.o spi2.c
190+
191+
${OBJECTDIR}/ff.o: ff.c nbproject/Makefile-${CND_CONF}.mk
192+
@${MKDIR} ${OBJECTDIR}
193+
@${RM} ${OBJECTDIR}/ff.o.d
194+
@${RM} ${OBJECTDIR}/ff.o
195+
@${FIXDEPS} "${OBJECTDIR}/ff.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/ff.o.d" -o ${OBJECTDIR}/ff.o ff.c
196+
197+
${OBJECTDIR}/keyboard.o: keyboard.c nbproject/Makefile-${CND_CONF}.mk
198+
@${MKDIR} ${OBJECTDIR}
199+
@${RM} ${OBJECTDIR}/keyboard.o.d
200+
@${RM} ${OBJECTDIR}/keyboard.o
201+
@${FIXDEPS} "${OBJECTDIR}/keyboard.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/keyboard.o.d" -o ${OBJECTDIR}/keyboard.o keyboard.c
202+
143203
endif
144204

145205
# ------------------------------------------------------------------------------------

‎nbproject/Makefile-genesis.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
#Sat Jul 05 23:49:33 EDT 2014
2+
#Mon Jul 07 15:13:03 EDT 2014
33
default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=1e76cae264df633ae2bc52ed87663f36
44
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc32\\v1.31\\bin
55
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=20b996ec0591c93034157100c3d90ac3

‎nbproject/configurations.xml

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
<itemPath>ft5206.h</itemPath>
1010
<itemPath>RA8875.h</itemPath>
1111
<itemPath>main.h</itemPath>
12+
<itemPath>diskio.h</itemPath>
13+
<itemPath>ff.h</itemPath>
14+
<itemPath>ffconf.h</itemPath>
15+
<itemPath>integer.h</itemPath>
16+
<itemPath>spi2.h</itemPath>
17+
<itemPath>keyboard.h</itemPath>
1218
</logicalFolder>
1319
<logicalFolder name="LinkerScript"
1420
displayName="Linker Files"
@@ -21,6 +27,11 @@
2127
<itemPath>ft5206.c</itemPath>
2228
<itemPath>i2c2.c</itemPath>
2329
<itemPath>RA8875.c</itemPath>
30+
<itemPath>diskio.c</itemPath>
31+
<itemPath>mmc_pic24f.c</itemPath>
32+
<itemPath>spi2.c</itemPath>
33+
<itemPath>ff.c</itemPath>
34+
<itemPath>keyboard.c</itemPath>
2435
</logicalFolder>
2536
<logicalFolder name="ExternalFiles"
2637
displayName="Important Files"
@@ -50,7 +61,7 @@
5061
</archiverTool>
5162
<loading>
5263
<useAlternateLoadableFile>false</useAlternateLoadableFile>
53-
<parseOnProdLoad>false</parseOnProdLoad>
64+
<parseOnProdLoad>true</parseOnProdLoad>
5465
<alternateLoadableFile></alternateLoadableFile>
5566
</loading>
5667
</compileType>
@@ -200,7 +211,6 @@
200211
<property key="UART4" value="true"/>
201212
<property key="UART5" value="true"/>
202213
<property key="UART6" value="true"/>
203-
<property key="firmware.download.all" value="false"/>
204214
<property key="hwtoolclock.frcindebug" value="false"/>
205215
<property key="memories.aux" value="false"/>
206216
<property key="memories.bootflash" value="true"/>

‎spi2.c

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#include <xc.h>
2+
#include <plib.h>
3+
#include "spi2.h"
4+
#include "RA8875.h"
5+
6+
void spi_delay()
7+
{
8+
UINT tt;
9+
tt = 10;
10+
while(tt--)
11+
Nop();
12+
}
13+
14+
unsigned char SpiTransfer2(unsigned char byte)
15+
{
16+
unsigned char counter;
17+
18+
for(counter=0; counter < 8; counter++)
19+
{
20+
if (byte & 0x80)
21+
MOSI_HIGH();
22+
else
23+
MOSI_LOW();
24+
25+
byte <<= 1;
26+
27+
SCK_HIGH(); /* a slave latches input data bit */
28+
//spi_delay();
29+
if (isMISO())
30+
byte |= 0x01;
31+
32+
SCK_LOW(); /* a slave shifts out next output data bit */
33+
//spi_delay();
34+
}
35+
36+
return(byte);
37+
}
38+
39+
40+
void SpiInitDevice(int chn, int srcClkDiv, int samp)
41+
{
42+
unsigned int config = SPI_OPEN_MSTEN|SPI_OPEN_MODE8|SPI_OPEN_CKE_REV|SPI_OPEN_SMP_END;
43+
//unsigned int config = SPI_CON_MSTEN | SPI_CON_MODE8 | SPI_SMP_OFF | SPI_CKE_ON | CLK_POL_ACTIVE_HIGH |SPI_CON_ON; // SPI configuration word
44+
//if(samp == 0)
45+
//config2 |= ;
46+
47+
SpiChnOpen(chn, config, srcClkDiv);
48+
SpiConfigPins();
49+
release_spi();
50+
}
51+
52+
void SpiConfigPins()
53+
{
54+
55+
SYSKEY = 0x0; // Make sure SYSKEY is locked
56+
SYSKEY = 0xAA996655; // SYSKEY unlock sequence
57+
SYSKEY = 0x556699AA;
58+
59+
//PPSInput(3,SDI2,RPA4); //MISO2 - P18
60+
//PPSOutput(2,RPA1,SDO2); //MOSI2 - P06
61+
62+
SYSKEY = 0x0; // Relock SYSKEY
63+
64+
TRISGbits.TRISG6 = 0; //SCK OUT
65+
TRISGbits.TRISG7 = 1; //MISO IN
66+
TRISGbits.TRISG8 = 0; //MOSI OUT
67+
TRISBbits.TRISB4 = 1; //CD IN
68+
TRISGbits.TRISG9 = 0; //CS OUT
69+
}
70+
71+
unsigned char SpiTransfer(unsigned char byte)
72+
{
73+
SpiChnPutC(2,byte);
74+
while(SpiChnIsBusy(2) > 0);
75+
return SpiChnGetC(2);
76+
}
77+
78+
void release_spi()
79+
{
80+
CS_HIGH();
81+
SpiTransfer(0xff);
82+
}
83+
84+
void CS_HIGH()
85+
{
86+
LCD_CS = 1;
87+
SD_CS = 1;
88+
}
89+
90+
void CS_LOW(char type)
91+
{
92+
CS_HIGH();
93+
switch(type)
94+
{
95+
case LCD:
96+
LCD_CS = 0;
97+
break;
98+
case SD:
99+
SD_CS = 0;
100+
break;
101+
}
102+
}

‎spi2.h

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* File: spi2.h
3+
* Author: Jason
4+
*
5+
* Created on March 1, 2014, 12:13 PM
6+
*/
7+
8+
#ifndef SPI2_H
9+
#define SPI2_H
10+
11+
#include "fubsd.h"
12+
#include <xc.h>
13+
#include <plib.h>
14+
15+
//-----------------------
16+
// SPEEDS
17+
//-----------------------
18+
#define SPI_SLOWEST 200 //400KHz
19+
#define SPI_SLOW 20 //4MHz
20+
#define SPI_MED 10 //8MHz
21+
#define SPI_MED1 4 //20MHz
22+
#define SPI_MED2 3 //26MHz
23+
#define SPI_FAST 2 //40MHz
24+
#define SPI_FASTEST 1 //80MHz
25+
//-----------------------
26+
// CHIP SELECTS
27+
//-----------------------
28+
#define SD_CS LATGbits.LATG9
29+
#define SD_CS_LOW() SD_CS = 0
30+
#define SD_CS_HIGH() SD_CS = 1
31+
32+
33+
#define RFM_CSN FUB_P12
34+
#define RFM_CSN_LOW() PORTClearBits(RFM_CSN)
35+
#define RFM_CSN_HIGH() PORTSetBits(RFM_CSN)
36+
37+
#define RFM_CE FUB_P13
38+
#define RFM_CE_LOW() PORTClearBits(RFM_CE)
39+
#define RFM_CE_HIGH() PORTSetBits(RFM_CE)
40+
//-----------------------
41+
// DATA PINS
42+
//-----------------------
43+
#define MOSI LATGbits.LATG8
44+
#define MOSI_LOW() MOSI = 0
45+
#define MOSI_HIGH() MOSI = 1
46+
47+
#define MISO PORTGbits.RG7
48+
#define isMISO() PORTGbits.RG7
49+
50+
#define SCK LATGbits.LATG6
51+
#define SCK_LOW() SCK = 0
52+
#define SCK_HIGH() SCK = 1
53+
54+
//-----------------------
55+
// MISC
56+
//-----------------------
57+
#define SD_CD PORTBbits.RB4
58+
#define isCD() SD_CD
59+
60+
//-----------------------
61+
// CS TYPES
62+
//-----------------------
63+
#define LCD 0
64+
#define SD 1
65+
66+
//-----------------------
67+
// EXTERNAL FUNCTIONS
68+
//-----------------------
69+
void CS_LOW(char type);
70+
void CS_HIGH();
71+
void SpiInitDevice(int chn, int srcClkDiv, int samp);
72+
void SpiConfigPins();
73+
unsigned char SpiTransfer(unsigned char byte);
74+
void release_spi();
75+
unsigned char SpiTransfer2(unsigned char byte);
76+
77+
#endif /* SPI2_H */
78+

0 commit comments

Comments
 (0)
Please sign in to comment.