CMSIS2000  0.0.7
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cr.h
Go to the documentation of this file.
1 /*
2  * CMSIS2000
3  * CMSIS-like sources for LPC2xxx series MCUs
4  *
5  * (C) Copyright 2011-2012, Dmitriy Cherepanov, All Rights Reserved
6  *
7  * Version: 0.0.7
8  * Date of the Last Update: 2013-03-04
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a copy
11  * of this software and associated documentation files (the "Software"), to
12  * deal in the Software without restriction, including without limitation the
13  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14  * sell copies of the Software, and to permit persons to whom the Software is
15  * furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included in
18  * all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26  * IN THE SOFTWARE.
27  *
28  * Do not be lasy! For the latest version see http://irtos.sourceforge.net .
29  *
30  *
31 #*/
32 
33 /*-----------Документация Doxygen -- Doxygen documentation -----------------*/
34 /** \file
35  *\if russian_lng
36  * Используйте данный файл как шаблон для других файлов.
37  *\else
38  * Use this file as a start point to other files.
39  *\endif
40  * \author Dmitriy Cherepanov
41  * \date 2011
42  */
43 /*---------- МАКРОСЫ - MACROSES ----------------------------------------------*/
44 #ifndef _CR_COROUTINE_H_
45 #define _CR_COROUTINE_H_ 1
46 #include "context.h"
47 
48 #define CO_ROUTINE(name_and_args) cr_cntx_t name_and_args
49 
50 #define THIS_IS_STATIC_CR(cr) static cr_cntx_t cr = CR_CONTEXT_INIT_VALUE
51 /** begin execution of CR here at first call time
52  *
53  */
54 #define CR_BEGIN(cr) CR_CONTEXT_RESTORE(cr)
55 /** return from CR next CR call will start execution here
56  *
57  */
58 #define CR_RETURN(cr) CR_CONTEXT_SAVE_AND_RETURN(cr)
59 /** return from CR next CR call will start execution from CR_BEGIN() point
60  *
61  */
62 #define CR_EXIT(cr) CR_CONTEXT_RESET_AND_RETURN(cr)
63 /** end of CR next CR call will start execution from CR_BEGIN() point
64  *
65  */
66 #define CR_END(cr) CR_CONTEXT_END(cr); CR_CONTEXT_RESET_AND_RETURN(cr)
67 /** ABORT CR EXECUTION with negative return value
68  * next CR call will start execution from CR_BEGIN() point
69  *
70  * \warning erorr code MUST be less than 0.
71  * \warning only static CR can start execution from CR_BEGIN() point automatically
72  */
73 #define CR_ABORT(cr,error) CR_CONTEXT_ERROR(cr,error)
74 /** return from CR while condition is true
75  *next CR call will start execution from CR_BEGIN() point
76  *
77  */
78 #define CR_RETURN_WHILE(condition,cr) while ((condition)) { \
79  CR_RETURN(cr); \
80  }
81 
82 /** return from cr while run_cr is executing
83  *
84  */
85 #define CR_WAIT_CR(run_cr,cr) CR_RETURN_WHILE (CR_EXECUTING(run_cr),(cr))
86 
87 /*
88 #define CR_WAIT_UNTIL(cr,condition) do { \
89  \
90  if (!(condition)) { \
91  CR_CONTEXT_RETURN \
92  } \
93  \
94  } while (0)
95 #define CR_WAIT_WHILE
96 */
97 // CR_WAIT_WHILE(cr,condition) CR_WAIT((cr),!(condition))
98 //to do cr_context type -- adresses or line numbers
99 
100 
101 //#define CR_ERROR
102 
103 /* #define_coroutine_name (cr_##__FUNC__##__FILE__)
104 */
105 
106 #endif /* _CR_COROUTINE_H_ */
107