git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1203 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
fdf3ac2d0a
commit
cbf137ed95
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
# Compiler options here.
|
# Compiler options here.
|
||||||
ifeq ($(USE_OPT),)
|
ifeq ($(USE_OPT),)
|
||||||
USE_OPT = -O2 -ggdb -fomit-frame-pointer -mabi=apcs-gnu
|
USE_OPT = -O0 -ggdb -fomit-frame-pointer -mabi=apcs-gnu
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# C++ specific options here (added to USE_OPT).
|
# C++ specific options here (added to USE_OPT).
|
||||||
|
|
|
@ -339,7 +339,8 @@
|
||||||
#define THREAD_EXT_FIELDS \
|
#define THREAD_EXT_FIELDS \
|
||||||
struct { \
|
struct { \
|
||||||
/* Add thread custom fields here.*/ \
|
/* Add thread custom fields here.*/ \
|
||||||
void *p_timeouts; \
|
/* Space for the LWIP sys_timeouts structure.*/ \
|
||||||
|
void *p_lwipspace[1]; \
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -350,7 +351,7 @@ struct { \
|
||||||
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
|
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
|
||||||
#define THREAD_EXT_INIT(tp) { \
|
#define THREAD_EXT_INIT(tp) { \
|
||||||
/* Add thread initialization code here.*/ \
|
/* Add thread initialization code here.*/ \
|
||||||
currp->p_timeouts = NULL; \
|
(tp)->p_lwipspace[0] = NULL; \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -66,14 +66,14 @@ void sys_init(void) {
|
||||||
|
|
||||||
sys_sem_t sys_sem_new(u8_t count) {
|
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);
|
chSemInit(sem, (cnt_t)count);
|
||||||
return sem;
|
return sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_sem_free(sys_sem_t sem) {
|
void sys_sem_free(sys_sem_t sem) {
|
||||||
|
|
||||||
mem_free(sem);
|
chHeapFree(sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_sem_signal(sys_sem_t 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 sys_mbox_new(int size) {
|
||||||
sys_mbox_t mbox;
|
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);
|
chMBInit(mbox, (void *)(mbox + 1), size);
|
||||||
return mbox;
|
return mbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_mbox_free(sys_mbox_t mbox) {
|
void sys_mbox_free(sys_mbox_t mbox) {
|
||||||
|
|
||||||
mem_free(mbox);
|
chHeapFree(mbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_mbox_post(sys_mbox_t mbox, void *msg) {
|
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) {
|
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),
|
sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg),
|
||||||
void *arg, int stacksize, int prio) {
|
void *arg, int stacksize, int prio) {
|
||||||
size_t wsz = THD_WA_SIZE(stacksize);
|
size_t wsz = THD_WA_SIZE(stacksize);
|
||||||
void *wsp = mem_malloc(wsz);
|
void *wsp = chHeapAlloc(wsz);
|
||||||
if (wsp == NULL)
|
if (wsp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return (sys_thread_t)chThdCreateStatic(wsp, wsz, prio, (tfunc_t)thread, arg);
|
return (sys_thread_t)chThdCreateStatic(wsp, wsz, prio, (tfunc_t)thread, arg);
|
||||||
|
|
|
@ -79,6 +79,11 @@
|
||||||
#define PERIODIC_TIMER_ID 1
|
#define PERIODIC_TIMER_ID 1
|
||||||
#define FRAME_RECEIVED_ID 2
|
#define FRAME_RECEIVED_ID 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stack area for the LWIP-MAC thread.
|
||||||
|
*/
|
||||||
|
WORKING_AREA(wa_lwip_thread, LWIP_THREAD_STACK_SIZE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
/** @brief MAC thread stack size. */
|
/** @brief MAC thread stack size. */
|
||||||
#if !defined(LWIP_THREAD_STACK_SIZE) || defined(__DOXYGEN__)
|
#if !defined(LWIP_THREAD_STACK_SIZE) || defined(__DOXYGEN__)
|
||||||
#define LWIP_THREAD_STACK_SIZE 256
|
#define LWIP_THREAD_STACK_SIZE 512
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @brief Transmission timeout. */
|
/** @brief Transmission timeout. */
|
||||||
|
@ -97,9 +97,12 @@
|
||||||
#define LWIP_IFNAME1 's'
|
#define LWIP_IFNAME1 's'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern WORKING_AREA(wa_lwip_thread, LWIP_THREAD_STACK_SIZE);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
msg_t lwip_thread(void *p);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1010,7 +1010,7 @@
|
||||||
* sys_thread_new() when the thread is created.
|
* sys_thread_new() when the thread is created.
|
||||||
*/
|
*/
|
||||||
#ifndef TCPIP_THREAD_PRIO
|
#ifndef TCPIP_THREAD_PRIO
|
||||||
#define TCPIP_THREAD_PRIO (LOWPRIO)
|
#define TCPIP_THREAD_PRIO (LOWPRIO + 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,15 +23,16 @@
|
||||||
#include <test.h>
|
#include <test.h>
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#include "lwipthread.h"
|
||||||
|
|
||||||
static WORKING_AREA(waThread1, 64);
|
static WORKING_AREA(waThread1, 64);
|
||||||
static msg_t Thread1(void *arg) {
|
static msg_t Thread1(void *arg) {
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
palSetPad(IOPORT2, PIOB_LCD_BL);
|
|
||||||
chThdSleepMilliseconds(100);
|
|
||||||
palClearPad(IOPORT2, PIOB_LCD_BL);
|
palClearPad(IOPORT2, PIOB_LCD_BL);
|
||||||
chThdSleepMilliseconds(900);
|
chThdSleepMilliseconds(900);
|
||||||
|
palSetPad(IOPORT2, PIOB_LCD_BL);
|
||||||
|
chThdSleepMilliseconds(100);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +53,12 @@ int main(int argc, char **argv) {
|
||||||
*/
|
*/
|
||||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
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.
|
* Normal main() thread activity.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue