1 |
2 |
alfik |
#ifndef __ALT_SEM_H__
|
2 |
|
|
#define __ALT_SEM_H__
|
3 |
|
|
|
4 |
|
|
/******************************************************************************
|
5 |
|
|
* *
|
6 |
|
|
* License Agreement *
|
7 |
|
|
* *
|
8 |
|
|
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
9 |
|
|
* All rights reserved. *
|
10 |
|
|
* *
|
11 |
|
|
* Permission is hereby granted, free of charge, to any person obtaining a *
|
12 |
|
|
* copy of this software and associated documentation files (the "Software"), *
|
13 |
|
|
* to deal in the Software without restriction, including without limitation *
|
14 |
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
15 |
|
|
* and/or sell copies of the Software, and to permit persons to whom the *
|
16 |
|
|
* Software is furnished to do so, subject to the following conditions: *
|
17 |
|
|
* *
|
18 |
|
|
* The above copyright notice and this permission notice shall be included in *
|
19 |
|
|
* all copies or substantial portions of the Software. *
|
20 |
|
|
* *
|
21 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
22 |
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
23 |
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
24 |
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
25 |
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
26 |
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
27 |
|
|
* DEALINGS IN THE SOFTWARE. *
|
28 |
|
|
* *
|
29 |
|
|
* This agreement shall be governed in all respects by the laws of the State *
|
30 |
|
|
* of California and by the laws of the United States of America. *
|
31 |
|
|
* *
|
32 |
|
|
* Altera does not recommend, suggest or require that this reference design *
|
33 |
|
|
* file be used in conjunction or combination with any other product. *
|
34 |
|
|
******************************************************************************/
|
35 |
|
|
|
36 |
|
|
/******************************************************************************
|
37 |
|
|
* *
|
38 |
|
|
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
39 |
|
|
* *
|
40 |
|
|
******************************************************************************/
|
41 |
|
|
|
42 |
|
|
/*
|
43 |
|
|
* This header provides macro definitions that can be used to create and use
|
44 |
|
|
* semaphores. These macros can be used in both a uC/OS-II based environment,
|
45 |
|
|
* and a single threaded HAL based environment.
|
46 |
|
|
*
|
47 |
|
|
* The motivation for these macros is to allow code to be developed which is
|
48 |
|
|
* thread safe under uC/OS-II, but incurs no additional overhead when used in a
|
49 |
|
|
* single threaded HAL environment.
|
50 |
|
|
*
|
51 |
|
|
* In the case of a single threaded HAL environment, they compile to
|
52 |
|
|
* "do nothing" directives, which ensures they do not contribute to the final
|
53 |
|
|
* executable.
|
54 |
|
|
*
|
55 |
|
|
* The following macros are available:
|
56 |
|
|
*
|
57 |
|
|
* ALT_SEM - Create a semaphore instance.
|
58 |
|
|
* ALT_EXTERN_SEM - Create a reference to an external semaphore instance.
|
59 |
|
|
* ALT_STATIC_SEM - Create a static semaphore instance.
|
60 |
|
|
* ALT_SEM_CREATE - Initialise a semaphore.
|
61 |
|
|
* ALT_SEM_PEND - Pend on a semaphore.
|
62 |
|
|
* ALT_SEM_POST - Increment a semaphore.
|
63 |
|
|
*
|
64 |
|
|
* Input arguments and return codes are all consistant with the equivalent
|
65 |
|
|
* uC/OS-II function.
|
66 |
|
|
*
|
67 |
|
|
* It's important to be careful in the use of the macros: ALT_SEM,
|
68 |
|
|
* ALT_EXTERN_SEM, and ALT_STATIC_SEM. In these three cases the semi-colon is
|
69 |
|
|
* included in the macro definition; so, for example, you should use:
|
70 |
|
|
*
|
71 |
|
|
* ALT_SEM(mysem)
|
72 |
|
|
*
|
73 |
|
|
* not:
|
74 |
|
|
*
|
75 |
|
|
* ALT_SEM(mysem);
|
76 |
|
|
*
|
77 |
|
|
* The inclusion of the semi-colon has been necessary to ensure the macros can
|
78 |
|
|
* compile with no warnings when used in a single threaded HAL environment.
|
79 |
|
|
*
|
80 |
|
|
*/
|
81 |
|
|
|
82 |
|
|
#include "priv/alt_no_error.h"
|
83 |
|
|
|
84 |
|
|
#define ALT_SEM(sem)
|
85 |
|
|
#define ALT_EXTERN_SEM(sem)
|
86 |
|
|
#define ALT_STATIC_SEM(sem)
|
87 |
|
|
|
88 |
|
|
#define ALT_SEM_CREATE(sem, value) alt_no_error ()
|
89 |
|
|
#define ALT_SEM_PEND(sem, timeout) alt_no_error ()
|
90 |
|
|
#define ALT_SEM_POST(sem) alt_no_error ()
|
91 |
|
|
|
92 |
|
|
#ifndef ALT_SINGLE_THREADED
|
93 |
|
|
#define ALT_SINGLE_THREADED
|
94 |
|
|
#endif
|
95 |
|
|
|
96 |
|
|
#endif /* __ALT_SEM_H__ */
|