git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1203 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2009-10-03 19:24:16 +00:00
parent fdf3ac2d0a
commit cbf137ed95
7 changed files with 29 additions and 13 deletions

View File

@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -O2 -ggdb -fomit-frame-pointer -mabi=apcs-gnu
USE_OPT = -O0 -ggdb -fomit-frame-pointer -mabi=apcs-gnu
endif
# C++ specific options here (added to USE_OPT).

View File

@ -339,7 +339,8 @@
#define THREAD_EXT_FIELDS \
struct { \
/* Add thread custom fields here.*/ \
void *p_timeouts; \
/* Space for the LWIP sys_timeouts structure.*/ \
void *p_lwipspace[1]; \
};
#endif
@ -350,7 +351,7 @@ struct { \
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
#define THREAD_EXT_INIT(tp) { \
/* Add thread initialization code here.*/ \
currp->p_timeouts = NULL; \
(tp)->p_lwipspace[0] = NULL; \
}
#endif

View File

@ -66,14 +66,14 @@ void sys_init(void) {
sys_sem_t sys_sem_new(u8_t count) {
sys_sem_t sem = mem_malloc(sizeof(Semaphore));
sys_sem_t sem = chHeapAlloc(sizeof(Semaphore));
chSemInit(sem, (cnt_t)count);
return sem;
}
void sys_sem_free(sys_sem_t sem) {
mem_free(sem);
chHeapFree(sem);
}
void sys_sem_signal(sys_sem_t sem) {
@ -97,14 +97,14 @@ u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout) {
sys_mbox_t sys_mbox_new(int size) {
sys_mbox_t mbox;
mbox = mem_malloc(sizeof(Mailbox) + sizeof(msg_t) * size);
mbox = chHeapAlloc(sizeof(Mailbox) + sizeof(msg_t) * size);
chMBInit(mbox, (void *)(mbox + 1), size);
return mbox;
}
void sys_mbox_free(sys_mbox_t mbox) {
mem_free(mbox);
chHeapFree(mbox);
}
void sys_mbox_post(sys_mbox_t mbox, void *msg) {
@ -141,13 +141,13 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) {
struct sys_timeouts *sys_arch_timeouts(void) {
return (struct sys_timeouts *)&currp->p_timeouts;
return (struct sys_timeouts *)currp->p_lwipspace;
}
sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg),
void *arg, int stacksize, int prio) {
size_t wsz = THD_WA_SIZE(stacksize);
void *wsp = mem_malloc(wsz);
void *wsp = chHeapAlloc(wsz);
if (wsp == NULL)
return NULL;
return (sys_thread_t)chThdCreateStatic(wsp, wsz, prio, (tfunc_t)thread, arg);

View File

@ -79,6 +79,11 @@
#define PERIODIC_TIMER_ID 1
#define FRAME_RECEIVED_ID 2
/**
* Stack area for the LWIP-MAC thread.
*/
WORKING_AREA(wa_lwip_thread, LWIP_THREAD_STACK_SIZE);
/*
* Initialization.
*/

View File

@ -44,7 +44,7 @@
/** @brief MAC thread stack size. */
#if !defined(LWIP_THREAD_STACK_SIZE) || defined(__DOXYGEN__)
#define LWIP_THREAD_STACK_SIZE 256
#define LWIP_THREAD_STACK_SIZE 512
#endif
/** @brief Transmission timeout. */
@ -97,9 +97,12 @@
#define LWIP_IFNAME1 's'
#endif
extern WORKING_AREA(wa_lwip_thread, LWIP_THREAD_STACK_SIZE);
#ifdef __cplusplus
extern "C" {
#endif
msg_t lwip_thread(void *p);
#ifdef __cplusplus
}
#endif

View File

@ -1010,7 +1010,7 @@
* sys_thread_new() when the thread is created.
*/
#ifndef TCPIP_THREAD_PRIO
#define TCPIP_THREAD_PRIO (LOWPRIO)
#define TCPIP_THREAD_PRIO (LOWPRIO + 1)
#endif
/**

View File

@ -23,15 +23,16 @@
#include <test.h>
#include "board.h"
#include "lwipthread.h"
static WORKING_AREA(waThread1, 64);
static msg_t Thread1(void *arg) {
while (TRUE) {
palSetPad(IOPORT2, PIOB_LCD_BL);
chThdSleepMilliseconds(100);
palClearPad(IOPORT2, PIOB_LCD_BL);
chThdSleepMilliseconds(900);
palSetPad(IOPORT2, PIOB_LCD_BL);
chThdSleepMilliseconds(100);
}
return 0;
}
@ -52,6 +53,12 @@ int main(int argc, char **argv) {
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
* Creates the LWIP threads.
*/
chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, LOWPRIO,
lwip_thread, NULL);
/*
* Normal main() thread activity.
*/