4. An implementation of the system as thread(s) written in protothread style, plus additional code that monitors the serial port and touch sensors, and dispatches them to the threads.

Dependencies:   mbed

Committer:
manujose
Date:
Tue Nov 30 22:02:03 2010 +0000
Revision:
0:3667ad9a98cc
protothreads

Who changed what in which revision?

UserRevisionLine numberNew contents of line
manujose 0:3667ad9a98cc 1 /*
manujose 0:3667ad9a98cc 2 * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
manujose 0:3667ad9a98cc 3 * All rights reserved.
manujose 0:3667ad9a98cc 4 *
manujose 0:3667ad9a98cc 5 * Redistribution and use in source and binary forms, with or without
manujose 0:3667ad9a98cc 6 * modification, are permitted provided that the following conditions
manujose 0:3667ad9a98cc 7 * are met:
manujose 0:3667ad9a98cc 8 * 1. Redistributions of source code must retain the above copyright
manujose 0:3667ad9a98cc 9 * notice, this list of conditions and the following disclaimer.
manujose 0:3667ad9a98cc 10 * 2. Redistributions in binary form must reproduce the above copyright
manujose 0:3667ad9a98cc 11 * notice, this list of conditions and the following disclaimer in the
manujose 0:3667ad9a98cc 12 * documentation and/or other materials provided with the distribution.
manujose 0:3667ad9a98cc 13 * 3. Neither the name of the Institute nor the names of its contributors
manujose 0:3667ad9a98cc 14 * may be used to endorse or promote products derived from this software
manujose 0:3667ad9a98cc 15 * without specific prior written permission.
manujose 0:3667ad9a98cc 16 *
manujose 0:3667ad9a98cc 17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
manujose 0:3667ad9a98cc 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
manujose 0:3667ad9a98cc 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
manujose 0:3667ad9a98cc 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
manujose 0:3667ad9a98cc 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
manujose 0:3667ad9a98cc 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
manujose 0:3667ad9a98cc 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
manujose 0:3667ad9a98cc 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
manujose 0:3667ad9a98cc 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
manujose 0:3667ad9a98cc 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
manujose 0:3667ad9a98cc 27 * SUCH DAMAGE.
manujose 0:3667ad9a98cc 28 *
manujose 0:3667ad9a98cc 29 * This file is part of the protothreads library.
manujose 0:3667ad9a98cc 30 *
manujose 0:3667ad9a98cc 31 * Author: Adam Dunkels <adam@sics.se>
manujose 0:3667ad9a98cc 32 *
manujose 0:3667ad9a98cc 33 * $Id: lc.h,v 1.2 2005/02/24 10:36:59 adam Exp $
manujose 0:3667ad9a98cc 34 */
manujose 0:3667ad9a98cc 35
manujose 0:3667ad9a98cc 36 /**
manujose 0:3667ad9a98cc 37 * \addtogroup pt
manujose 0:3667ad9a98cc 38 * @{
manujose 0:3667ad9a98cc 39 */
manujose 0:3667ad9a98cc 40
manujose 0:3667ad9a98cc 41 /**
manujose 0:3667ad9a98cc 42 * \defgroup lc Local continuations
manujose 0:3667ad9a98cc 43 * @{
manujose 0:3667ad9a98cc 44 *
manujose 0:3667ad9a98cc 45 * Local continuations form the basis for implementing protothreads. A
manujose 0:3667ad9a98cc 46 * local continuation can be <i>set</i> in a specific function to
manujose 0:3667ad9a98cc 47 * capture the state of the function. After a local continuation has
manujose 0:3667ad9a98cc 48 * been set can be <i>resumed</i> in order to restore the state of the
manujose 0:3667ad9a98cc 49 * function at the point where the local continuation was set.
manujose 0:3667ad9a98cc 50 *
manujose 0:3667ad9a98cc 51 *
manujose 0:3667ad9a98cc 52 */
manujose 0:3667ad9a98cc 53
manujose 0:3667ad9a98cc 54 /**
manujose 0:3667ad9a98cc 55 * \file lc.h
manujose 0:3667ad9a98cc 56 * Local continuations
manujose 0:3667ad9a98cc 57 * \author
manujose 0:3667ad9a98cc 58 * Adam Dunkels <adam@sics.se>
manujose 0:3667ad9a98cc 59 *
manujose 0:3667ad9a98cc 60 */
manujose 0:3667ad9a98cc 61
manujose 0:3667ad9a98cc 62 #ifdef DOXYGEN
manujose 0:3667ad9a98cc 63 /**
manujose 0:3667ad9a98cc 64 * Initialize a local continuation.
manujose 0:3667ad9a98cc 65 *
manujose 0:3667ad9a98cc 66 * This operation initializes the local continuation, thereby
manujose 0:3667ad9a98cc 67 * unsetting any previously set continuation state.
manujose 0:3667ad9a98cc 68 *
manujose 0:3667ad9a98cc 69 * \hideinitializer
manujose 0:3667ad9a98cc 70 */
manujose 0:3667ad9a98cc 71 #define LC_INIT(lc)
manujose 0:3667ad9a98cc 72
manujose 0:3667ad9a98cc 73 /**
manujose 0:3667ad9a98cc 74 * Set a local continuation.
manujose 0:3667ad9a98cc 75 *
manujose 0:3667ad9a98cc 76 * The set operation saves the state of the function at the point
manujose 0:3667ad9a98cc 77 * where the operation is executed. As far as the set operation is
manujose 0:3667ad9a98cc 78 * concerned, the state of the function does <b>not</b> include the
manujose 0:3667ad9a98cc 79 * call-stack or local (automatic) variables, but only the program
manujose 0:3667ad9a98cc 80 * counter and such CPU registers that needs to be saved.
manujose 0:3667ad9a98cc 81 *
manujose 0:3667ad9a98cc 82 * \hideinitializer
manujose 0:3667ad9a98cc 83 */
manujose 0:3667ad9a98cc 84 #define LC_SET(lc)
manujose 0:3667ad9a98cc 85
manujose 0:3667ad9a98cc 86 /**
manujose 0:3667ad9a98cc 87 * Resume a local continuation.
manujose 0:3667ad9a98cc 88 *
manujose 0:3667ad9a98cc 89 * The resume operation resumes a previously set local continuation, thus
manujose 0:3667ad9a98cc 90 * restoring the state in which the function was when the local
manujose 0:3667ad9a98cc 91 * continuation was set. If the local continuation has not been
manujose 0:3667ad9a98cc 92 * previously set, the resume operation does nothing.
manujose 0:3667ad9a98cc 93 *
manujose 0:3667ad9a98cc 94 * \hideinitializer
manujose 0:3667ad9a98cc 95 */
manujose 0:3667ad9a98cc 96 #define LC_RESUME(lc)
manujose 0:3667ad9a98cc 97
manujose 0:3667ad9a98cc 98 /**
manujose 0:3667ad9a98cc 99 * Mark the end of local continuation usage.
manujose 0:3667ad9a98cc 100 *
manujose 0:3667ad9a98cc 101 * The end operation signifies that local continuations should not be
manujose 0:3667ad9a98cc 102 * used any more in the function. This operation is not needed for
manujose 0:3667ad9a98cc 103 * most implementations of local continuation, but is required by a
manujose 0:3667ad9a98cc 104 * few implementations.
manujose 0:3667ad9a98cc 105 *
manujose 0:3667ad9a98cc 106 * \hideinitializer
manujose 0:3667ad9a98cc 107 */
manujose 0:3667ad9a98cc 108 #define LC_END(lc)
manujose 0:3667ad9a98cc 109
manujose 0:3667ad9a98cc 110 /**
manujose 0:3667ad9a98cc 111 * \var typedef lc_t;
manujose 0:3667ad9a98cc 112 *
manujose 0:3667ad9a98cc 113 * The local continuation type.
manujose 0:3667ad9a98cc 114 *
manujose 0:3667ad9a98cc 115 * \hideinitializer
manujose 0:3667ad9a98cc 116 */
manujose 0:3667ad9a98cc 117 #endif /* DOXYGEN */
manujose 0:3667ad9a98cc 118
manujose 0:3667ad9a98cc 119 #ifndef __LC_H__
manujose 0:3667ad9a98cc 120 #define __LC_H__
manujose 0:3667ad9a98cc 121
manujose 0:3667ad9a98cc 122
manujose 0:3667ad9a98cc 123 #ifdef LC_INCLUDE
manujose 0:3667ad9a98cc 124 #include LC_INCLUDE
manujose 0:3667ad9a98cc 125 #else
manujose 0:3667ad9a98cc 126 #include "lc-switch.h"
manujose 0:3667ad9a98cc 127 #endif /* LC_INCLUDE */
manujose 0:3667ad9a98cc 128
manujose 0:3667ad9a98cc 129 #endif /* __LC_H__ */
manujose 0:3667ad9a98cc 130
manujose 0:3667ad9a98cc 131 /** @} */
manujose 0:3667ad9a98cc 132 /** @} */