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

This commit is contained in:
gdisirio 2009-01-19 15:10:41 +00:00
parent 0810f1daac
commit 79089d6352
19 changed files with 87 additions and 57 deletions

View File

@ -1,12 +1,14 @@
/** /**
* @mainpage ChibiOS/RT * @mainpage ChibiOS/RT
* @author Giovanni Di Sirio (gdisirio@users.sourceforge.net). * @author Giovanni Di Sirio (gdisirio@users.sourceforge.net).
* @section Chibi Chibi ? *
* It is the Japanese word for small as in small child. So ChibiOS/RT * <h2>Chibi ?</h2>
* @htmlonly (<span class="t_nihongo_kanji" xml:lang="ja" lang="ja">&#12385;&#12403;</span>OS/RT) \endhtmlonly * I didn't want a serious name for this project. It is the Japanese word for
* small as in small child. So ChibiOS/RT
* @htmlonly (<span class="t_nihongo_kanji" xml:lang="ja" lang="ja">&#12385;&#12403;</span>OS/RT) @endhtmlonly
* means small Real Time Operating System. * means small Real Time Operating System.
* Source <a href="http://en.wikipedia.org/wiki/Chibi" target="_blank">Wikipedia</a>. * Source <a href="http://en.wikipedia.org/wiki/Chibi" target="_blank">Wikipedia</a>.
* @section ch_features Features * <h2>Features</h2>
* - Free software, GPL3 licensed. * - Free software, GPL3 licensed.
* - Designed for realtime applications. * - Designed for realtime applications.
* - Easily portable. * - Easily portable.
@ -49,7 +51,7 @@
* memory image. * memory image.
* - Almost totally written in C with little ASM code required for ports. * - Almost totally written in C with little ASM code required for ports.
* *
* Related pages: * <h2>Related pages</h2>
* - @subpage Concepts * - @subpage Concepts
* - @subpage Articles * - @subpage Articles
*/ */
@ -241,6 +243,7 @@
* *
* - @subpage article_atomic * - @subpage article_atomic
* - @subpage article_saveram * - @subpage article_saveram
* - @subpage article_interrupts
*/ */
/** @} */ /** @} */
@ -491,7 +494,7 @@
* <h2>Operation Mode</h2> * <h2>Operation Mode</h2>
* Messages are an easy to use and fast IPC mechanism, threads can both serve * Messages are an easy to use and fast IPC mechanism, threads can both serve
* messages and send messages to other threads, the mechanism allows data to * messages and send messages to other threads, the mechanism allows data to
* be carryed in both directions. Data is not copyed between the client and * be carried in both directions. Data is not copied between the client and
* server threads but just a pointer passed so the exchange is very time * server threads but just a pointer passed so the exchange is very time
* efficient.<br> * efficient.<br>
* Messages are usually processed in FIFO order but it is possible to process * Messages are usually processed in FIFO order but it is possible to process

View File

@ -30,16 +30,8 @@
chSemSignalI(&sem1); chSemSignalI(&sem1);
chSemSignalI(&sem2); chSemSignalI(&sem2);
/*
* The "if" is required because the chSemWaitS() does not always internally
* reschedule.
*/
if (chSemGetCounter(&sem3) <= 0)
chSemWaitS(&Sem3); chSemWaitS(&Sem3);
else { chSchRescheduleS(); /* Because chSemWaitS() might not reschedule internally.*/
chSemFastWaitS(&sem3);
chSchRescheduleS();
}
chSysUnlock(); chSysUnlock();
* @endcode * @endcode

34
docs/src/interrupts.dox Normal file
View File

@ -0,0 +1,34 @@
/**
* @page article_interrupts Writing interrupt handlers under ChibiOS/RT
* @{
* Since version 1.1.0 ChbiOS/RT offers a cross-platform system for writing
* interrupt handlers. Port-related and compiler-related details are
* encapsulated within standard system macros.<br>
* An interrupt handler assumes the following general form:
* @code
CH_IRQ_HANDLER(myIRQ) {
CH_IRQ_PROLOGUE();
// IRQ handling code, preemptable if the architecture supports it.
chSysLockI();
// Invocation of some I-Class system API, never preemptable.
chSysUnlockI().
// More IRQ handling code, again preemptable.
CH_IRQ_EPILOGUE();
}
* @endcode
* Note that only interrupt handlers that have to invoke system I-Class APIs
* must be written in this form, handlers unrelated to the OS activity can
* omit the macros.
* Another note about the handler name "myIRQ", in some ports it must be a
* vector number rather than a function name, it could also be a name from
* within a predefined set, see the notes about the various ports.
* <h2>Important Notes</h2>
* - There is an important application note about ARM7 interrupt handlers,
* please read about it in the ARM7 port section: @ref ARM7_IH
*/
/** @} */

View File

@ -13,7 +13,6 @@
static WORKING_AREA(waMyThread, 64); static WORKING_AREA(waMyThread, 64);
static t_msg MyThread(void *arg) { static t_msg MyThread(void *arg) {
while (!chThdShoudTerminate()) { while (!chThdShoudTerminate()) {
/* Do thread inner work */ /* Do thread inner work */
} }
@ -23,9 +22,8 @@ static t_msg MyThread(void *arg) {
main() { main() {
chSysInit(); chSysInit();
... ...
chThdCreate(NORMALPRIO, 0, waMyThread, sizeof(waMyThread), MyThread, NULL); chThdCreateStatic(waMyThread, sizeof(waMyThread), NORMALPRIO, MyThread, NULL);
... ...
chSysPause();
} }
* @endcode * @endcode
* The resulting ASM code for the thread function would be something like this: * The resulting ASM code for the thread function would be something like this:
@ -41,10 +39,10 @@ MyThread:
* @code * @code
#include <ch.h> #include <ch.h>
static BYTE8 waMyThread[UserStackSize(64)]; static WORKING_AREA(waMyThread, 64);
__attribute__((noreturn)) void MyThread(void *arg) {
__attribute__((noreturn))
static void MyThread(void *arg) {
while (!chThdShoudTerminate()) { while (!chThdShoudTerminate()) {
/* Do thread inner work */ /* Do thread inner work */
} }
@ -54,9 +52,8 @@ __attribute__((noreturn)) void MyThread(void *arg) {
main() { main() {
chSysInit(); chSysInit();
... ...
chThdCreate(NORMALPRIO, 0, waMyThread, sizeof(waMyThread), (t_tfunc)MyThread, NULL); chThdCreateStatic(waMyThread, sizeof(waMyThread), NORMALPRIO, MyThread, NULL);
... ...
chSysPause();
} }
* @endcode * @endcode
* This will make GCC believe that the function cannot return and there is no * This will make GCC believe that the function cannot return and there is no

View File

@ -124,7 +124,7 @@ static void ServeInterrupt(void) {
AT91C_BASE_AIC->AIC_EOICR = 0; AT91C_BASE_AIC->AIC_EOICR = 0;
} }
CH_IRQ_HANDLER void EMACIrqHandler(void) { CH_IRQ_HANDLER(EMACIrqHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();

View File

@ -74,7 +74,7 @@ static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) {
AT91C_BASE_AIC->AIC_EOICR = 0; AT91C_BASE_AIC->AIC_EOICR = 0;
} }
CH_IRQ_HANDLER void USART0IrqHandler(void) { CH_IRQ_HANDLER(USART0IrqHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
@ -83,7 +83,7 @@ CH_IRQ_HANDLER void USART0IrqHandler(void) {
CH_IRQ_EPILOGUE(); CH_IRQ_EPILOGUE();
} }
CH_IRQ_HANDLER void USART1IrqHandler(void) { CH_IRQ_HANDLER(USART1IrqHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();

View File

@ -30,9 +30,9 @@
extern "C" { extern "C" {
#endif #endif
void InitSerial(int prio0, int prio1); void InitSerial(int prio0, int prio1);
void UART0IrqHandler(void);
void UART1IrqHandler(void);
void SetUSARTI(AT91PS_USART u, int speed, int mode); void SetUSARTI(AT91PS_USART u, int speed, int mode);
CH_IRQ_HANDLER(UART0IrqHandler);
CH_IRQ_HANDLER(UART1IrqHandler);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -109,7 +109,7 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
} }
} }
CH_IRQ_HANDLER void UART0IrqHandler(void) { CH_IRQ_HANDLER(UART0IrqHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
@ -119,7 +119,7 @@ CH_IRQ_HANDLER void UART0IrqHandler(void) {
CH_IRQ_EPILOGUE(); CH_IRQ_EPILOGUE();
} }
CH_IRQ_HANDLER void UART1IrqHandler(void) { CH_IRQ_HANDLER(UART1IrqHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();

View File

@ -41,9 +41,9 @@
extern "C" { extern "C" {
#endif #endif
void InitSerial(int vector1, int vector2); void InitSerial(int vector1, int vector2);
void UART0IrqHandler(void);
void UART1IrqHandler(void);
void SetUARTI(UART *u, int speed, int lcr, int fcr); void SetUARTI(UART *u, int speed, int lcr, int fcr);
CH_IRQ_HANDLER(UART0IrqHandler);
CH_IRQ_HANDLER(UART1IrqHandler);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -184,9 +184,9 @@ struct context {
#endif /* !THUMB */ #endif /* !THUMB */
/** /**
* IRQ handler function modifier. * IRQ handler function declaration.
*/ */
#define PORT_IRQ_HANDLER __attribute__((naked)) #define PORT_IRQ_HANDLER(id) __attribute__((naked)) void id(void)
/** /**
* This function is empty in this port. * This function is empty in this port.

View File

@ -85,7 +85,7 @@
* registers.<br> * registers.<br>
* Example: * Example:
* @code * @code
* CH_IRQ_HANDLER void irq_handler(void) { * CH_IRQ_HANDLER(irq_handler) {
* CH_IRQ_PROLOGUE(); * CH_IRQ_PROLOGUE();
* *
* serve_interrupt(); * serve_interrupt();

View File

@ -85,7 +85,7 @@ static void ServeInterrupt(USART_TypeDef *u, FullDuplexDriver *com) {
/* /*
* USART1 IRQ service routine. * USART1 IRQ service routine.
*/ */
CH_IRQ_HANDLER void VectorD4(void) { CH_IRQ_HANDLER(VectorD4) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
@ -108,7 +108,7 @@ static void OutNotify1(void) {
/* /*
* USART2 IRQ service routine. * USART2 IRQ service routine.
*/ */
CH_IRQ_HANDLER void VectorD8(void) { CH_IRQ_HANDLER(VectorD8) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
@ -131,7 +131,7 @@ static void OutNotify2(void) {
/* /*
* USART3 IRQ service routine. * USART3 IRQ service routine.
*/ */
CH_IRQ_HANDLER void VectorDC(void) { CH_IRQ_HANDLER(VectorDC) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();

View File

@ -71,7 +71,7 @@ void threadstart(void) {
* This interrupt is used as system tick. * This interrupt is used as system tick.
* @note The timer is initialized in the board setup code. * @note The timer is initialized in the board setup code.
*/ */
CH_IRQ_HANDLER void SysTickVector(void) { CH_IRQ_HANDLER(SysTickVector) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();

View File

@ -207,9 +207,9 @@ struct context {
} }
/** /**
* IRQ handler function modifier. * IRQ handler function declaration.
*/ */
#define PORT_IRQ_HANDLER #define PORT_IRQ_HANDLER(id) void id(void)
/** /**
* This function is empty in this port. * This function is empty in this port.

View File

@ -188,10 +188,10 @@ asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \
} }
/** /**
* IRQ handler function modifier. Note, it just aliases the WinAVR "ISR" * IRQ handler function declaration. Note, it just aliases the WinAVR "ISR"
* macro. * macro.
*/ */
#define PORT_IRQ_HANDLER ISR #define PORT_IRQ_HANDLER(id) ISR(id)
/** /**
* This function is empty in this port. * This function is empty in this port.

View File

@ -155,10 +155,9 @@ struct context {
} }
/** /**
* IRQ handler function modifier. Note, it just aliases the WinMSP "interrupt" * IRQ handler function modifier.
* macro.
*/ */
#define PORT_IRQ_HANDLER interrupt #define PORT_IRQ_HANDLER(id) interrupt void id(void)
/** /**
* This function is empty in this port. * This function is empty in this port.

View File

@ -87,6 +87,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Huge improvements to the ports documentation. - Huge improvements to the ports documentation.
- Articles and notes previously in the wiki now merged in the general - Articles and notes previously in the wiki now merged in the general
documentation, the wiki entries are obsolete and will be removed. documentation, the wiki entries are obsolete and will be removed.
- New application notes and articles added.
*** 1.0.0rc2 *** *** 1.0.0rc2 ***
- FIX: Removed unused variable "retaddr" from the Cortex-M3 port. - FIX: Removed unused variable "retaddr" from the Cortex-M3 port.

View File

@ -156,9 +156,11 @@
#define CH_IRQ_EPILOGUE() PORT_IRQ_EPILOGUE() #define CH_IRQ_EPILOGUE() PORT_IRQ_EPILOGUE()
/** /**
* Standard modifier for IRQ handler functions. * Standard IRQ handler declaration.
* @note @p id can be a function name or a vector number depending on the
* port implementation.
*/ */
#define CH_IRQ_HANDLER PORT_IRQ_HANDLER #define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -122,9 +122,11 @@ struct context {
#define PORT_IRQ_EPILOGUE() #define PORT_IRQ_EPILOGUE()
/** /**
* IRQ handler function modifier. * IRQ handler function declaration.
* @note @p id can be a function name or a vector number depending on the
* port implementation.
*/ */
#define PORT_IRQ_HANDLER #define PORT_IRQ_HANDLER(id) void id(void)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {