]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - os/7.0.2/include/os/portmacro.h
Merge branch 'tms570_emac' of git@rtime.felk.cvut.cz:pes-rpp/rpp-lib into personal...
[pes-rpp/rpp-lib.git] / os / 7.0.2 / include / os / portmacro.h
1 /*
2     FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd.
3
4
5     FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by:
6     Atollic AB - Atollic provides professional embedded systems development
7     tools for C/C++ development, code analysis and test automation.
8     See http://www.atollic.com
9
10
11     ***************************************************************************
12      *                                                                       *
13      *    FreeRTOS tutorial books are available in pdf and paperback.        *
14      *    Complete, revised, and edited pdf reference manuals are also       *
15      *    available.                                                         *
16      *                                                                       *
17      *    Purchasing FreeRTOS documentation will not only help you, by       *
18      *    ensuring you get running as quickly as possible and with an        *
19      *    in-depth knowledge of how to use FreeRTOS, it will also help       *
20      *    the FreeRTOS project to continue with its mission of providing     *
21      *    professional grade, cross platform, de facto standard solutions    *
22      *    for microcontrollers - completely free of charge!                  *
23      *                                                                       *
24      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *
25      *                                                                       *
26      *    Thank you for using FreeRTOS, and thank you for your support!      *
27      *                                                                       *
28     ***************************************************************************
29
30
31     This file is part of the FreeRTOS distribution.
32
33     FreeRTOS is free software; you can redistribute it and/or modify it under
34     the terms of the GNU General Public License (version 2) as published by the
35     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
36     >>>NOTE<<< The modification to the GPL is included to allow you to
37     distribute a combined work that includes FreeRTOS without being obliged to
38     provide the source code for proprietary components outside of the FreeRTOS
39     kernel.  FreeRTOS is distributed in the hope that it will be useful, but
40     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
41     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
42     more details. You should have received a copy of the GNU General Public
43     License and the FreeRTOS license exception along with FreeRTOS; if not it
44     can be viewed here: http://www.freertos.org/a00114.html and also obtained
45     by writing to Richard Barry, contact details for whom are available on the
46     FreeRTOS WEB site.
47
48     1 tab == 4 spaces!
49
50     http://www.FreeRTOS.org - Documentation, latest information, license and
51     contact details.
52
53     http://www.SafeRTOS.com - A version that is certified for use in safety
54     critical systems.
55
56     http://www.OpenRTOS.com - Commercial support, development, porting,
57     licensing and training services.
58 */
59
60 #ifndef __OS_PORTMACRO_H__
61 #define __OS_PORTMACRO_H__
62
63
64 /*----------------------------------------------------------------------------*/
65 /* RTI Register Frame Definition                                              */
66
67 struct rti
68 {
69     unsigned GCTRL;
70     unsigned TBCTRL;
71     unsigned CAPCTRL;
72     unsigned COMPCTRL;
73     struct
74     {
75         unsigned FRCx;
76         unsigned UCx;
77         unsigned CPUCx;
78         unsigned : 32;
79         unsigned CAFRCx;
80         unsigned CAUCx;
81         unsigned : 32;
82         unsigned : 32;
83     } CNT[2U];
84     struct
85     {
86         unsigned COMPx;
87         unsigned UDCPx;
88     } CMP[4U];
89     unsigned TBLCOMP;
90     unsigned TBHCOMP;
91     unsigned : 32;
92     unsigned : 32;
93     unsigned SETINT;
94     unsigned CLEARINT;
95     unsigned INTFLAG;
96     unsigned : 32;
97     unsigned DWDCTRL;
98     unsigned DWDPRLD;
99     unsigned WDSTATUS;
100     unsigned WDKEY;
101     unsigned WDCNTR;
102 };
103
104 #define RTI ((volatile struct rti *)0xFFFFFC00U)
105
106 /*----------------------------------------------------------------------------*/
107 /* Type Definitions                                                           */
108
109 #define portCHAR        char
110 #define portFLOAT       float
111 #define portDOUBLE      double
112 #define portLONG        long
113 #define portSHORT       short
114 #define portSTACK_TYPE  unsigned long
115 #define portBASE_TYPE   long
116
117 #if (configUSE_16_BIT_TICKS == 1)
118     typedef unsigned portSHORT portTickType;
119     #define portMAX_DELAY (portTickType) 0xFFFF
120 #else
121     typedef unsigned portLONG portTickType;
122     #define portMAX_DELAY (portTickType) 0xFFFFFFFFF
123 #endif
124
125
126 /*----------------------------------------------------------------------------*/
127 /* Architecture Definitions                                                   */
128
129 #define portSTACK_GROWTH    (-1)
130 #define portTICK_RATE_MS    ((portTickType) 1000 / configTICK_RATE_HZ)
131 #define portBYTE_ALIGNMENT  8
132
133 /*----------------------------------------------------------------------------*/
134 /* External Functions                                                         */
135
136 extern void vPortEnterCritical(void);
137 extern void vPortExitCritical(void);
138
139 /*----------------------------------------------------------------------------*/
140 /* Functions Macros                                                           */
141
142 #define portNOP()                asm ("    nop")
143 #define portYIELD()              _call_swi(0)
144 #define portYIELD_FROM_ISR()     vTaskSwitchContext()
145 #define portENTER_CRITICAL()     vPortEnterCritical()
146 #define portEXIT_CRITICAL()      vPortExitCritical()
147 #define portDISABLE_INTERRUPTS() asm ("    CPSID if")
148 #define portENABLE_INTERRUPTS()  asm ("    CPSIE if")
149
150 #define portTASK_FUNCTION(vFunction, pvParameters)       void vFunction(void *pvParameters)
151 #define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)
152
153 #if (configGENERATE_RUN_TIME_STATS == 1)
154 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() \
155 { \
156     RTI->GCTRL         = 0x00000000U; \
157     RTI->TBCTRL        = 0x00000000U; \
158     RTI->COMPCTRL      = 0x00000000U; \
159     RTI->CNT[1U].UCx   = 0x00000000U; \
160     RTI->CNT[1U].FRCx  = 0x00000000U; \
161     RTI->CNT[1U].CPUCx = (configCPU_CLOCK_HZ / 2 / configTICK_RATE_HZ) / 16; \
162     RTI->CMP[1U].UDCPx = (configCPU_CLOCK_HZ / 2 / configTICK_RATE_HZ) / 16; \
163     RTI->GCTRL         = 0x00000002U; \
164 }
165 #define portGET_RUN_TIME_COUNTER_VALUE() (RTI->CNT[1].FRCx)
166 #endif
167
168 #endif
169
170 /*----------------------------------------------------------------------------*/