This commit is contained in:
bernard committed 2014-08-01 12:03:24 +08:00
commit 582aff86ed
24 files changed
+3245 -42

No files matched your search

+8 -3
View File
@@ -540,12 +540,17 @@ struct dirent *readdir(DIR *d)
if (fd == RT_NULL)
{
rt_set_errno(-DFS_STATUS_EBADF);
return RT_NULL;
}
if (!d->num ||
(d->cur += ((struct dirent *)(d->buf + d->cur))->d_reclen) >= d->num)
if (d->num)
{
struct dirent* dirent_ptr;
dirent_ptr = (struct dirent*)&d->buf[d->cur];
d->cur += dirent_ptr->d_reclen;
}
if (!d->num || d->cur >= d->num)
{
/* get a new entry */
result = dfs_file_getdents(fd,
+22 -2
View File
@@ -1,8 +1,28 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
cwd = GetCurrentDir()
src = ['spi_core.c', 'spi_dev.c']
CPPPATH = [cwd + '/../include']
src_device = []
if GetDepend('RT_USING_SPI_WIFI'):
src_device += ['spi_wifi_rw009.c']
if GetDepend('RT_USING_W25QXX'):
src_device += ['spi_flash_w25qxx.c']
if GetDepend('RT_USING_ENC28J60'):
src_device += ['enc28j60.c']
if GetDepend('RT_USING_AT45DBXX'):
src_device += ['spi_flash_at45dbxx.c']
if GetDepend('RT_USING_SST25VFXX'):
src_device += ['spi_flash_sst25vfxx.c']
src += src_device
group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_SPI'], CPPPATH = CPPPATH)
Return('group')
@@ -0,0 +1,15 @@
spi_wifi_rw009.c/spi_wifi_rw009.h
RW009
http://www.rt-thread.com/
enc28j60.c/enc28j60.h
http://www.microchip.com/
spi_flash_at45dbxx.c/spi_flash_at45dbxx.h
http://www.atmel.com/
spi_flash_sst25vfxx.c/spi_flash_sst25vfxx.h
http://www.microchip.com/
spi_flash_w25qxx.c/spi_flash_w25qxx.h
http://www.winbond.com/
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,17 @@
#ifndef SPI_FLASH_AT45DBXX_H_INCLUDED
#define SPI_FLASH_AT45DBXX_H_INCLUDED
#include <rtthread.h>
#include <drivers/spi.h>
struct spi_flash_at45dbxx
{
struct rt_device flash_device;
struct rt_device_blk_geometry geometry;
struct rt_spi_device * rt_spi_device;
};
extern rt_err_t at45dbxx_init(const char * flash_device_name, const char * spi_device_name);
#endif // SPI_FLASH_AT45DBXX_H_INCLUDED
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,32 @@
/*
* File : rtdef.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2011-12-16 aozima the first version
*/
#ifndef SPI_FLASH_SST25VFXX_H_INCLUDED
#define SPI_FLASH_SST25VFXX_H_INCLUDED
#include <rtthread.h>
#include <drivers/spi.h>
struct spi_flash_sst25vfxx
{
struct rt_device flash_device;
struct rt_device_blk_geometry geometry;
struct rt_spi_device * rt_spi_device;
struct rt_mutex lock;
};
extern rt_err_t sst25vfxx_init(const char * flash_device_name, const char * spi_device_name);
#endif // SPI_FLASH_SST25VFXX_H_INCLUDED
File diff suppressed because it is too large. Load diff
+34
View File
@@ -0,0 +1,34 @@
/*
* File : spi_flash_w25qxx.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2011-12-16 aozima the first version
* 2012-08-23 aozima add flash lock.
*/
#ifndef SPI_FLASH_W25QXX_H_INCLUDED
#define SPI_FLASH_W25QXX_H_INCLUDED
#include <rtthread.h>
#include <drivers/spi.h>
struct spi_flash_device
{
struct rt_device flash_device;
struct rt_device_blk_geometry geometry;
struct rt_spi_device * rt_spi_device;
struct rt_mutex lock;
};
extern rt_err_t w25qxx_init(const char * flash_device_name,
const char * spi_device_name);
#endif // SPI_FLASH_W25QXX_H_INCLUDED
File diff suppressed because it is too large. Load diff
+123
View File
@@ -0,0 +1,123 @@
/*
* File : spi_wifi_rw009.h
* This file is part of RT-Thread RTOS
* Copyright by Shanghai Real-Thread Electronic Technology Co.,Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2014-07-31 aozima the first version
*/
#ifndef SPI_WIFI_H_INCLUDED
#define SPI_WIFI_H_INCLUDED
#include <stdint.h>
// little-endian
struct cmd_request
{
uint32_t flag;
uint32_t M2S_len; // master to slave data len.
uint32_t magic1;
uint32_t magic2;
};
#define CMD_MAGIC1 (0x67452301)
#define CMD_MAGIC2 (0xEFCDAB89)
#define CMD_FLAG_MRDY (0x01)
// little-endian
struct response
{
uint32_t flag;
uint32_t S2M_len; // slave to master data len.
uint32_t magic1;
uint32_t magic2;
};
#define RESP_FLAG_SRDY (0x01)
#define RESP_MAGIC1 (0x98BADCFE)
#define RESP_MAGIC2 (0x10325476)
/* spi slave configure. */
#define MAX_DATA_LEN 1520
#define SPI_TX_POOL_SIZE 2
// align check
#if (MAX_DATA_LEN & 0x03) != 0
#error MAX_DATA_LEN must ALIGN to 4byte!
#endif
typedef enum
{
data_type_eth_data = 0,
data_type_cmd,
data_type_resp,
}
app_data_type_typedef;
struct spi_data_packet
{
uint32_t data_len;
uint32_t data_type;
char buffer[MAX_DATA_LEN];
};
struct spi_wifi_cmd
{
uint32_t cmd;
char buffer[128];
};
struct spi_wifi_resp
{
uint32_t cmd;
char buffer[128];
};
#define SPI_WIFI_CMD_INIT 128 //wait
#define SPI_WIFI_CMD_SCAN 129 //no wait
#define SPI_WIFI_CMD_JOIN 130 //no wait
/* porting */
extern void spi_wifi_hw_init(void);
extern void spi_wifi_int_cmd(rt_bool_t cmd);
extern rt_bool_t spi_wifi_is_busy(void);
/* tools */
#define node_entry(node, type, member) \
((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))
#define member_offset(type, member) \
((unsigned long)(&((type *)0)->member))
#define SSID_NAME_LENGTH_MAX (32)
#define PASSWORD_LENGTH_MAX (32)
struct cmd_join
{
char ssid[SSID_NAME_LENGTH_MAX];
char passwd[PASSWORD_LENGTH_MAX];
uint8_t bssid[8]; // 6byte + 2byte PAD.
uint32_t channel;
uint32_t security;
};
#endif // SPI_WIFI_H_INCLUDED
+1 -1
View File
@@ -24,10 +24,10 @@
#define PNG_MAX_MALLOC_64K
#define PNG_NO_STDIO
#define PNG_NO_ERROR_NUMBERS
#define PNG_NO_WRITE_SUPPORTED
#define PNG_ABORT() do { rt_kprintf("libpng abort.\n"); } while (0)
#ifndef RT_USING_NEWLIB
#define PNG_NO_WRITE_SUPPORTED
#define PNG_NO_SETJMP_SUPPORTED
#define malloc rtgui_malloc
#define free rtgui_free
+8
View File
@@ -3,6 +3,14 @@
#include <sys/time.h>
#include <rtthread.h>
#ifdef RT_USING_DFS
#include <dfs_posix.h>
#endif
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif
/* Reentrant versions of system calls. */
int
+4 -4
View File
@@ -79,8 +79,8 @@ _reswitch:
STR R1, [R0]
BX LR
/* R0 --> swith from thread stack
* R1 --> swith to thread stack
/* R0 --> switch from thread stack
* R1 --> switch to thread stack
* psr, pc, LR, R12, R3, R2, R1, R0 are pushed into [from] stack
*/
.global PendSV_Handler
@@ -103,7 +103,7 @@ PendSV_Handler:
LDR R0, =rt_interrupt_from_thread
LDR R1, [R0]
CMP R1, #0x00
BEQ swtich_to_thread /* skip register save at the first time */
BEQ switch_to_thread /* skip register save at the first time */
MRS R1, PSP /* get from thread stack pointer */
@@ -118,7 +118,7 @@ PendSV_Handler:
MOV R6, R10
MOV R7, R11
STMIA R1!, {R4 - R7} /* push thread {R8 - R11} high register to thread stack */
swtich_to_thread:
switch_to_thread:
LDR R1, =rt_interrupt_to_thread
LDR R1, [R1]
LDR R1, [R1] /* load thread stack pointer */
+4 -4
View File
@@ -81,8 +81,8 @@ _reswitch
STR r1, [r0]
BX LR
; r0 --> swith from thread stack
; r1 --> swith to thread stack
; r0 --> switch from thread stack
; r1 --> switch to thread stack
; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
EXPORT PendSV_Handler
PendSV_Handler:
@@ -104,7 +104,7 @@ PendSV_Handler:
LDR r0, =rt_interrupt_from_thread
LDR r1, [r0]
CMP r1, #0x00
BEQ swtich_to_thread ; skip register save at the first time
BEQ switch_to_thread ; skip register save at the first time
MRS r1, psp ; get from thread stack pointer
@@ -120,7 +120,7 @@ PendSV_Handler:
MOV r7, r11
STMIA r1!, {r4 - r7} ; push thread {r8 - r11} high register to thread stack
swtich_to_thread
switch_to_thread
LDR r1, =rt_interrupt_to_thread
LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer
+4 -4
View File
@@ -85,8 +85,8 @@ _reswitch
BX LR
ENDP
; r0 --> swith from thread stack
; r1 --> swith to thread stack
; r0 --> switch from thread stack
; r1 --> switch to thread stack
; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
PendSV_Handler PROC
EXPORT PendSV_Handler
@@ -108,7 +108,7 @@ PendSV_Handler PROC
LDR r0, =rt_interrupt_from_thread
LDR r1, [r0]
CMP r1, #0x00
BEQ swtich_to_thread ; skip register save at the first time
BEQ switch_to_thread ; skip register save at the first time
MRS r1, psp ; get from thread stack pointer
@@ -124,7 +124,7 @@ PendSV_Handler PROC
MOV r7, r11
STMIA r1!, {r4 - r7} ; push thread {r8 - r11} high register to thread stack
swtich_to_thread
switch_to_thread
LDR r1, =rt_interrupt_to_thread
LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer
+4 -4
View File
@@ -80,8 +80,8 @@ _reswitch:
STR R1, [R0]
BX LR
/* R0 --> swith from thread stack
* R1 --> swith to thread stack
/* R0 --> switch from thread stack
* R1 --> switch to thread stack
* psr, pc, LR, R12, R3, R2, R1, R0 are pushed into [from] stack
*/
.global PendSV_Handler
@@ -102,14 +102,14 @@ PendSV_Handler:
LDR R0, =rt_interrupt_from_thread
LDR R1, [R0]
CBZ R1, swtich_to_thread /* skip register save at the first time */
CBZ R1, switch_to_thread /* skip register save at the first time */
MRS R1, PSP /* get from thread stack pointer */
STMFD R1!, {R4 - R11} /* push R4 - R11 register */
LDR R0, [R0]
STR R1, [R0] /* update from thread stack pointer */
swtich_to_thread:
switch_to_thread:
LDR R1, =rt_interrupt_to_thread
LDR R1, [R1]
LDR R1, [R1] /* load thread stack pointer */
+4 -4
View File
@@ -81,8 +81,8 @@ _reswitch
STR r1, [r0]
BX LR
; r0 --> swith from thread stack
; r1 --> swith to thread stack
; r0 --> switch from thread stack
; r1 --> switch to thread stack
; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
EXPORT PendSV_Handler
PendSV_Handler:
@@ -102,14 +102,14 @@ PendSV_Handler:
LDR r0, =rt_interrupt_from_thread
LDR r1, [r0]
CBZ r1, swtich_to_thread ; skip register save at the first time
CBZ r1, switch_to_thread ; skip register save at the first time
MRS r1, psp ; get from thread stack pointer
STMFD r1!, {r4 - r11} ; push r4 - r11 register
LDR r0, [r0]
STR r1, [r0] ; update from thread stack pointer
swtich_to_thread
switch_to_thread
LDR r1, =rt_interrupt_to_thread
LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer
+4 -4
View File
@@ -84,8 +84,8 @@ _reswitch
BX LR
ENDP
; r0 --> swith from thread stack
; r1 --> swith to thread stack
; r0 --> switch from thread stack
; r1 --> switch to thread stack
; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
PendSV_Handler PROC
EXPORT PendSV_Handler
@@ -105,14 +105,14 @@ PendSV_Handler PROC
LDR r0, =rt_interrupt_from_thread
LDR r1, [r0]
CBZ r1, swtich_to_thread ; skip register save at the first time
CBZ r1, switch_to_thread ; skip register save at the first time
MRS r1, psp ; get from thread stack pointer
STMFD r1!, {r4 - r11} ; push r4 - r11 register
LDR r0, [r0]
STR r1, [r0] ; update from thread stack pointer
swtich_to_thread
switch_to_thread
LDR r1, =rt_interrupt_to_thread
LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer
+4 -4
View File
@@ -82,8 +82,8 @@ _reswitch:
STR r1, [r0]
BX LR
/* r0 --> swith from thread stack
* r1 --> swith to thread stack
/* r0 --> switch from thread stack
* r1 --> switch to thread stack
* psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
*/
.global PendSV_Handler
@@ -104,7 +104,7 @@ PendSV_Handler:
LDR r0, =rt_interrupt_from_thread
LDR r1, [r0]
CBZ r1, swtich_to_thread /* skip register save at the first time */
CBZ r1, switch_to_thread /* skip register save at the first time */
MRS r1, psp /* get from thread stack pointer */
@@ -127,7 +127,7 @@ PendSV_Handler:
LDR r0, [r0]
STR r1, [r0] /* update from thread stack pointer */
swtich_to_thread:
switch_to_thread:
LDR r1, =rt_interrupt_to_thread
LDR r1, [r1]
LDR r1, [r1] /* load thread stack pointer */
+4 -4
View File
@@ -82,8 +82,8 @@ _reswitch
STR r1, [r0]
BX LR
; r0 --> swith from thread stack
; r1 --> swith to thread stack
; r0 --> switch from thread stack
; r1 --> switch to thread stack
; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
EXPORT PendSV_Handler
PendSV_Handler:
@@ -103,7 +103,7 @@ PendSV_Handler:
LDR r0, =rt_interrupt_from_thread
LDR r1, [r0]
CBZ r1, swtich_to_thread ; skip register save at the first time
CBZ r1, switch_to_thread ; skip register save at the first time
MRS r1, psp ; get from thread stack pointer
@@ -130,7 +130,7 @@ push_flag
LDR r0, [r0]
STR r1, [r0] ; update from thread stack pointer
swtich_to_thread
switch_to_thread
LDR r1, =rt_interrupt_to_thread
LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer
+4 -4
View File
@@ -85,8 +85,8 @@ _reswitch
BX LR
ENDP
; r0 --> swith from thread stack
; r1 --> swith to thread stack
; r0 --> switch from thread stack
; r1 --> switch to thread stack
; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
PendSV_Handler PROC
EXPORT PendSV_Handler
@@ -106,7 +106,7 @@ PendSV_Handler PROC
LDR r0, =rt_interrupt_from_thread
LDR r1, [r0]
CBZ r1, swtich_to_thread ; skip register save at the first time
CBZ r1, switch_to_thread ; skip register save at the first time
MRS r1, psp ; get from thread stack pointer
@@ -129,7 +129,7 @@ PendSV_Handler PROC
LDR r0, [r0]
STR r1, [r0] ; update from thread stack pointer
swtich_to_thread
switch_to_thread
LDR r1, =rt_interrupt_to_thread
LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer