]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo_Hardware_Platform/hal/hal.h
Add missing +TCP code.
[freertos] / FreeRTOS / Demo / CORTEX_SmartFusion2_M2S050_SoftConsole / RTOSDemo_Hardware_Platform / hal / hal.h
1 /***************************************************************************//**\r
2  * (c) Copyright 2007-2013 Microsemi SoC Products Group. All rights reserved.\r
3  * \r
4  * Hardware abstraction layer functions.\r
5  * \r
6  * SVN $Revision: 5258 $\r
7  * SVN $Date: 2013-03-21 12:41:02 +0000 (Thu, 21 Mar 2013) $\r
8  */\r
9 #ifndef HAL_H_\r
10 #define HAL_H_\r
11 \r
12 #include "cpu_types.h"\r
13 #include "hw_reg_access.h"\r
14 \r
15 /***************************************************************************//**\r
16  * Enable all interrupts at the processor level.\r
17  */\r
18 void HAL_enable_interrupts( void );\r
19 \r
20 /***************************************************************************//**\r
21  * Disable all interrupts at the processor core level.\r
22  * Return the interrupts enable state before disabling occured so that it can \r
23  * later be restored. \r
24  */\r
25 psr_t HAL_disable_interrupts( void );\r
26 \r
27 /***************************************************************************//**\r
28  * Restore the interrupts enable state at the processor core level.\r
29  * This function is normally passed the value returned from a previous call to\r
30  * HAL_disable_interrupts(). \r
31  */\r
32 void HAL_restore_interrupts( psr_t saved_psr );\r
33 \r
34 /***************************************************************************//**\r
35  */\r
36 #define FIELD_OFFSET(FIELD_NAME)  (FIELD_NAME##_OFFSET)\r
37 #define FIELD_SHIFT(FIELD_NAME)   (FIELD_NAME##_SHIFT)\r
38 #define FIELD_MASK(FIELD_NAME)    (FIELD_NAME##_MASK)\r
39 \r
40 /***************************************************************************//**\r
41  * The macro HAL_set_32bit_reg() allows writing a 32 bits wide register.\r
42  *\r
43  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
44  *              peripheral containing the register.\r
45  * REG_NAME:    A string identifying the register to write. These strings are\r
46  *              specified in a header file associated with the peripheral.\r
47  * VALUE:       A variable of type uint32_t containing the value to write.\r
48  */\r
49 #define HAL_set_32bit_reg(BASE_ADDR, REG_NAME, VALUE) \\r
50           (HW_set_32bit_reg( ((BASE_ADDR) + (REG_NAME##_REG_OFFSET)), (VALUE) ))\r
51 \r
52 /***************************************************************************//**\r
53  * The macro HAL_get_32bit_reg() is used to read the value  of a 32 bits wide\r
54  * register.\r
55  * \r
56  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
57  *              peripheral containing the register.\r
58  * REG_NAME:    A string identifying the register to read. These strings are\r
59  *              specified in a header file associated with the peripheral.\r
60  * RETURN:              This function-like macro returns a uint32_t value.\r
61  */\r
62 #define HAL_get_32bit_reg(BASE_ADDR, REG_NAME) \\r
63           (HW_get_32bit_reg( ((BASE_ADDR) + (REG_NAME##_REG_OFFSET)) ))\r
64 \r
65 /***************************************************************************//**\r
66  * The macro HAL_set_32bit_reg_field() is used to write a field within a\r
67  * 32 bits wide register. The field written can be one or more bits.\r
68  * \r
69  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
70  *              peripheral containing the register.\r
71  * FIELD_NAME:  A string identifying the register field to write. These strings\r
72  *                              are specified in a header file associated with the peripheral.\r
73  * VALUE:       A variable of type uint32_t containing the field value to write.\r
74  */\r
75 #define HAL_set_32bit_reg_field(BASE_ADDR, FIELD_NAME, VALUE) \\r
76             (HW_set_32bit_reg_field(\\r
77                 (BASE_ADDR) + FIELD_OFFSET(FIELD_NAME),\\r
78                 FIELD_SHIFT(FIELD_NAME),\\r
79                 FIELD_MASK(FIELD_NAME),\\r
80                 (VALUE)))\r
81   \r
82 /***************************************************************************//**\r
83  * The macro HAL_get_32bit_reg_field() is used to read a register field from\r
84  * within a 32 bit wide peripheral register. The field can be one or more bits.\r
85  * \r
86  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
87  *              peripheral containing the register.\r
88  * FIELD_NAME:  A string identifying the register field to write. These strings\r
89  *                              are specified in a header file associated with the peripheral.\r
90  * RETURN:              This function-like macro returns a uint32_t value.\r
91  */\r
92 #define HAL_get_32bit_reg_field(BASE_ADDR, FIELD_NAME) \\r
93             (HW_get_32bit_reg_field(\\r
94                 (BASE_ADDR) + FIELD_OFFSET(FIELD_NAME),\\r
95                 FIELD_SHIFT(FIELD_NAME),\\r
96                 FIELD_MASK(FIELD_NAME)))\r
97   \r
98 /***************************************************************************//**\r
99  * The macro HAL_set_16bit_reg() allows writing a 16 bits wide register.\r
100  *\r
101  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
102  *              peripheral containing the register.\r
103  * REG_NAME:    A string identifying the register to write. These strings are\r
104  *              specified in a header file associated with the peripheral.\r
105  * VALUE:       A variable of type uint_fast16_t containing the value to write.\r
106  */\r
107 #define HAL_set_16bit_reg(BASE_ADDR, REG_NAME, VALUE) \\r
108             (HW_set_16bit_reg( ((BASE_ADDR) + (REG_NAME##_REG_OFFSET)), (VALUE) ))\r
109 \r
110 /***************************************************************************//**\r
111  * The macro HAL_get_16bit_reg() is used to read the value  of a 16 bits wide\r
112  * register.\r
113  * \r
114  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
115  *              peripheral containing the register.\r
116  * REG_NAME:    A string identifying the register to read. These strings are\r
117  *              specified in a header file associated with the peripheral.\r
118  * RETURN:              This function-like macro returns a uint16_t value.\r
119  */\r
120 #define HAL_get_16bit_reg(BASE_ADDR, REG_NAME) \\r
121             (HW_get_16bit_reg( (BASE_ADDR) + (REG_NAME##_REG_OFFSET) ))\r
122 \r
123 /***************************************************************************//**\r
124  * The macro HAL_set_16bit_reg_field() is used to write a field within a\r
125  * 16 bits wide register. The field written can be one or more bits.\r
126  * \r
127  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
128  *              peripheral containing the register.\r
129  * FIELD_NAME:  A string identifying the register field to write. These strings\r
130  *                              are specified in a header file associated with the peripheral.\r
131  * VALUE:       A variable of type uint16_t containing the field value to write.\r
132  */\r
133 #define HAL_set_16bit_reg_field(BASE_ADDR, FIELD_NAME, VALUE) \\r
134             (HW_set_16bit_reg_field(\\r
135                 (BASE_ADDR) + FIELD_OFFSET(FIELD_NAME),\\r
136                 FIELD_SHIFT(FIELD_NAME),\\r
137                 FIELD_MASK(FIELD_NAME),\\r
138                 (VALUE)))  \r
139 \r
140 /***************************************************************************//**\r
141  * The macro HAL_get_16bit_reg_field() is used to read a register field from\r
142  * within a 8 bit wide peripheral register. The field can be one or more bits.\r
143  * \r
144  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
145  *              peripheral containing the register.\r
146  * FIELD_NAME:  A string identifying the register field to write. These strings\r
147  *                              are specified in a header file associated with the peripheral.\r
148  * RETURN:              This function-like macro returns a uint16_t value.\r
149  */\r
150 #define HAL_get_16bit_reg_field(BASE_ADDR, FIELD_NAME) \\r
151             (HW_get_16bit_reg_field(\\r
152                 (BASE_ADDR) + FIELD_OFFSET(FIELD_NAME),\\r
153                 FIELD_SHIFT(FIELD_NAME),\\r
154                 FIELD_MASK(FIELD_NAME)))\r
155 \r
156 /***************************************************************************//**\r
157  * The macro HAL_set_8bit_reg() allows writing a 8 bits wide register.\r
158  *\r
159  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
160  *              peripheral containing the register.\r
161  * REG_NAME:    A string identifying the register to write. These strings are\r
162  *              specified in a header file associated with the peripheral.\r
163  * VALUE:       A variable of type uint_fast8_t containing the value to write.\r
164  */\r
165 #define HAL_set_8bit_reg(BASE_ADDR, REG_NAME, VALUE) \\r
166           (HW_set_8bit_reg( ((BASE_ADDR) + (REG_NAME##_REG_OFFSET)), (VALUE) ))\r
167 \r
168 /***************************************************************************//**\r
169  * The macro HAL_get_8bit_reg() is used to read the value of a 8 bits wide\r
170  * register.\r
171  * \r
172  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
173  *              peripheral containing the register.\r
174  * REG_NAME:    A string identifying the register to read. These strings are\r
175  *              specified in a header file associated with the peripheral.\r
176  * RETURN:              This function-like macro returns a uint8_t value.\r
177  */\r
178 #define HAL_get_8bit_reg(BASE_ADDR, REG_NAME) \\r
179           (HW_get_8bit_reg( (BASE_ADDR) + (REG_NAME##_REG_OFFSET) ))\r
180 \r
181 /***************************************************************************//**\r
182  */\r
183 #define HAL_set_8bit_reg_field(BASE_ADDR, FIELD_NAME, VALUE) \\r
184             (HW_set_8bit_reg_field(\\r
185                 (BASE_ADDR) + FIELD_OFFSET(FIELD_NAME),\\r
186                 FIELD_SHIFT(FIELD_NAME),\\r
187                 FIELD_MASK(FIELD_NAME),\\r
188                 (VALUE)))\r
189 \r
190 /***************************************************************************//**\r
191  * The macro HAL_get_8bit_reg_field() is used to read a register field from\r
192  * within a 8 bit wide peripheral register. The field can be one or more bits.\r
193  * \r
194  * BASE_ADDR:   A variable of type addr_t specifying the base address of the\r
195  *              peripheral containing the register.\r
196  * FIELD_NAME:  A string identifying the register field to write. These strings\r
197  *                              are specified in a header file associated with the peripheral.\r
198  * RETURN:              This function-like macro returns a uint8_t value.\r
199  */\r
200 #define HAL_get_8bit_reg_field(BASE_ADDR, FIELD_NAME) \\r
201             (HW_get_8bit_reg_field(\\r
202                 (BASE_ADDR) + FIELD_OFFSET(FIELD_NAME),\\r
203                 FIELD_SHIFT(FIELD_NAME),\\r
204                 FIELD_MASK(FIELD_NAME)))\r
205   \r
206 #endif /*HAL_H_*/\r