1 /***************************************************************************//**
\r
2 * (c) Copyright 2007-2018 Microsemi SoC Products Group. All rights reserved.
\r
4 * Hardware abstraction layer functions.
\r
6 * SVN $Revision: 9661 $
\r
7 * SVN $Date: 2018-01-15 16:13:33 +0530 (Mon, 15 Jan 2018) $
\r
12 #include "cpu_types.h"
\r
13 #include "hw_reg_access.h"
\r
15 /***************************************************************************//**
\r
16 * Enable all interrupts at the processor level.
\r
18 void HAL_enable_interrupts( void );
\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
25 psr_t HAL_disable_interrupts( void );
\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
32 void HAL_restore_interrupts( psr_t saved_psr );
\r
34 /***************************************************************************//**
\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
40 /***************************************************************************//**
\r
41 * The macro HAL_set_32bit_reg() allows writing a 32 bits wide register.
\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
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
52 /***************************************************************************//**
\r
53 * The macro HAL_get_32bit_reg() is used to read the value of a 32 bits wide
\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
62 #define HAL_get_32bit_reg(BASE_ADDR, REG_NAME) \
\r
63 (HW_get_32bit_reg( ((BASE_ADDR) + (REG_NAME##_REG_OFFSET)) ))
\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
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
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
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
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
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
98 /***************************************************************************//**
\r
99 * The macro HAL_set_16bit_reg() allows writing a 16 bits wide register.
\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
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
110 /***************************************************************************//**
\r
111 * The macro HAL_get_16bit_reg() is used to read the value of a 16 bits wide
\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
120 #define HAL_get_16bit_reg(BASE_ADDR, REG_NAME) \
\r
121 (HW_get_16bit_reg( (BASE_ADDR) + (REG_NAME##_REG_OFFSET) ))
\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
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
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
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
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
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
156 /***************************************************************************//**
\r
157 * The macro HAL_set_8bit_reg() allows writing a 8 bits wide register.
\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
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
168 /***************************************************************************//**
\r
169 * The macro HAL_get_8bit_reg() is used to read the value of a 8 bits wide
\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
178 #define HAL_get_8bit_reg(BASE_ADDR, REG_NAME) \
\r
179 (HW_get_8bit_reg( (BASE_ADDR) + (REG_NAME##_REG_OFFSET) ))
\r
181 /***************************************************************************//**
\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
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
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
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