aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/os/hal/ports/TIVA/TM4C129x/hal_lld.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/os/hal/ports/TIVA/TM4C129x/hal_lld.h')
-rw-r--r--lib/chibios-contrib/os/hal/ports/TIVA/TM4C129x/hal_lld.h214
1 files changed, 214 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/hal/ports/TIVA/TM4C129x/hal_lld.h b/lib/chibios-contrib/os/hal/ports/TIVA/TM4C129x/hal_lld.h
new file mode 100644
index 000000000..1080fae75
--- /dev/null
+++ b/lib/chibios-contrib/os/hal/ports/TIVA/TM4C129x/hal_lld.h
@@ -0,0 +1,214 @@
1/*
2 Copyright (C) 2014..2017 Marco Veeneman
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file TIVA/TM4C129x/hal_lld.h
19 * @brief TM4C129x HAL subsystem low level driver header.
20 * @pre This module requires the following macros to be defined in the
21 * @p board.h file:
22 * - TODO: add required macros
23 *
24 * @addtogroup HAL
25 * @{
26 */
27
28#ifndef HAL_LLD_H
29#define HAL_LLD_H
30
31#include "tiva_registry.h"
32
33/*===========================================================================*/
34/* Driver constants. */
35/*===========================================================================*/
36
37/**
38 * @name Platform identification
39 * @{
40 */
41#define PLATFORM_NAME "Tiva C Series TM4C129x"
42/** @} */
43
44/*===========================================================================*/
45/* Driver pre-compile time settings. */
46/*===========================================================================*/
47
48#if !defined(TIVA_MOSC_SINGLE_ENDED)
49#define TIVA_MOSC_SINGLE_ENDED FALSE
50#endif
51
52#if !defined(TIVA_RSCLKCFG_OSCSRC)
53#define TIVA_RSCLKCFG_OSCSRC SYSCTL_RSCLKCFG_OSCSRC_MOSC
54#endif
55
56/*===========================================================================*/
57/* Derived constants and error checks. */
58/*===========================================================================*/
59
60/*
61 * Configuration-related checks.
62 */
63#if !defined(TM4C129x_MCUCONF)
64#error "Using a wrong mcuconf.h file, TM4C129x_MCUCONF not defined"
65#endif
66
67/*
68 * Oscillator-related checks.
69 */
70#if !(TIVA_RSCLKCFG_OSCSRC == SYSCTL_RSCLKCFG_OSCSRC_PIOSC) && \
71 !(TIVA_RSCLKCFG_OSCSRC == SYSCTL_RSCLKCFG_OSCSRC_LFIOSC) && \
72 !(TIVA_RSCLKCFG_OSCSRC == SYSCTL_RSCLKCFG_OSCSRC_MOSC) && \
73 !(TIVA_RSCLKCFG_OSCSRC == SYSCTL_RSCLKCFG_OSCSRC_RTC)
74#error "Invalid value for TIVA_RSCLKCFG_OSCSRC defined"
75#endif
76
77#if TIVA_XTAL_VALUE == 4000000
78#define TIVA_XTAL_ SYSCTL_RCC_XTAL_4MHZ
79#elif TIVA_XTAL_VALUE == 4096000
80#define TIVA_XTAL_ SYSCTL_RCC_XTAL_4_09MHZ
81#elif TIVA_XTAL_VALUE == 4915200
82#define TIVA_XTAL_ SYSCTL_RCC_XTAL_4_91MHZ
83#elif TIVA_XTAL_VALUE == 5000000
84#define TIVA_XTAL_ SYSCTL_RCC_XTAL_5MHZ
85#elif TIVA_XTAL_VALUE == 5120000
86#define TIVA_XTAL_ SYSCTL_RCC_XTAL_5_12MHZ
87#elif TIVA_XTAL_VALUE == 6000000
88#define TIVA_XTAL_ SYSCTL_RCC_XTAL_6MHZ
89#elif TIVA_XTAL_VALUE == 6144000
90#define TIVA_XTAL_ SYSCTL_RCC_XTAL_6_14MHZ
91#elif TIVA_XTAL_VALUE == 7372800
92#define TIVA_XTAL_ SYSCTL_RCC_XTAL_7_37MHZ
93#elif TIVA_XTAL_VALUE == 8000000
94#define TIVA_XTAL_ SYSCTL_RCC_XTAL_8MHZ
95#elif TIVA_XTAL_VALUE == 8192000
96#define TIVA_XTAL_ SYSCTL_RCC_XTAL_8_19MHZ
97#elif TIVA_XTAL_VALUE == 10000000
98#define TIVA_XTAL_ SYSCTL_RCC_XTAL_10MHZ
99#elif TIVA_XTAL_VALUE == 12000000
100#define TIVA_XTAL_ SYSCTL_RCC_XTAL_12MHZ
101#elif TIVA_XTAL_VALUE == 12288000
102#define TIVA_XTAL_ SYSCTL_RCC_XTAL_12_2MHZ
103#elif TIVA_XTAL_VALUE == 13560000
104#define TIVA_XTAL_ SYSCTL_RCC_XTAL_13_5MHZ
105#elif TIVA_XTAL_VALUE == 14318180
106#define TIVA_XTAL_ SYSCTL_RCC_XTAL_14_3MHZ
107#elif TIVA_XTAL_VALUE == 16000000
108#define TIVA_XTAL_ SYSCTL_RCC_XTAL_16MHZ
109#elif TIVA_XTAL_VALUE == 16384000
110#define TIVA_XTAL_ SYSCTL_RCC_XTAL_16_3MHZ
111#elif TIVA_XTAL_VALUE == 18000000
112#define TIVA_XTAL_ SYSCTL_RCC_XTAL_18MHZ
113#elif TIVA_XTAL_VALUE == 20000000
114#define TIVA_XTAL_ SYSCTL_RCC_XTAL_20MHZ
115#elif TIVA_XTAL_VALUE == 24000000
116#define TIVA_XTAL_ SYSCTL_RCC_XTAL_24MHZ
117#elif TIVA_XTAL_VALUE == 25000000
118#define TIVA_XTAL_ SYSCTL_RCC_XTAL_25MHZ
119#else
120#error "Invalid value for TIVA_XTAL_VALUE defined"
121#endif
122
123/*
124#if TIVA_MOSC_ENABLE == TRUE
125#define TIVA_MOSCDIS (0 << 0)
126#define TIVA_XTAL TIVA_XTAL_
127#elif TIVA_MOSC_ENABLE == FALSE
128#define TIVA_MOSCDIS (1 << 0)
129#define TIVA_XTAL 0
130#else
131#error "Invalid value for TIVA_MOSC_ENABLE defined"
132#endif
133
134#if TIVA_DIV400_ENABLE == TRUE
135#define TIVA_DIV400 (1 << 30)
136#elif TIVA_DIV400_ENABLE == FALSE
137#define TIVA_DIV400 (0 << 30)
138#else
139#error "Invalid value for TIVA_DIV400_ENABLE defined"
140#endif
141
142#if (TIVA_SYSDIV_VALUE >= 0x02) && (TIVA_SYSDIV_VALUE <= 0x3f)
143#define TIVA_SYSDIV (TIVA_SYSDIV_VALUE << 23)
144#define TIVA_SYSDIV2 (TIVA_SYSDIV_VALUE << 23)
145#else
146#error "Invalid value for TIVA_SYSDIV_VALUE defined"
147#endif
148
149#if TIVA_USESYSDIV_ENABLE == TRUE
150#define TIVA_USESYSDIV (1 << 22)
151#elif TIVA_USESYSDIV_ENABLE == FALSE
152#define TIVA_USESYSDIV (0 << 22)
153#else
154#error "Invalid value for TIVA_USESYSDIV_ENABLE defined"
155#endif
156
157#if TIVA_SYSDIV2LSB_ENABLE == TRUE
158#define TIVA_SYSDIV2LSB (1 << 22)
159#elif TIVA_SYSDIV2LSB_ENABLE == FALSE
160#define TIVA_SYSDIV2LSB (0 << 22)
161#else
162#error "Invalid value for TIVA_SYSDIV2LSB_ENABLE defined"
163#endif
164
165#if TIVA_BYPASS_ENABLE == TRUE
166#define TIVA_SRC 16000000
167#define TIVA_BYPASS (1 << 11)
168#elif TIVA_BYPASS_ENABLE == FALSE
169#define TIVA_SRC (200000000 + ((TIVA_DIV400 >> 30) * 200000000))
170#define TIVA_BYPASS (0 << 11)
171#else
172#error "Invalid value for TIVA_BYPASS_ENABLE defined"
173#endif
174
175#if (TIVA_OSCSRC == TIVA_RCC_OSCSRC_MOSC) && (TIVA_MOSC_ENABLE == FALSE)
176#error "Main Oscillator selected but not enabled"
177#endif
178*/
179/*
180 * System Clock calculation
181 * TODO: dynamic TIVA_SYSCLK value
182 */
183#define TIVA_SYSCLK 120000000
184
185/*===========================================================================*/
186/* Driver data structures and types. */
187/*===========================================================================*/
188
189/*===========================================================================*/
190/* Driver macros. */
191/*===========================================================================*/
192
193/*===========================================================================*/
194/* External declarations. */
195/*===========================================================================*/
196
197/* Various helpers.*/
198#include "nvic.h"
199#include "tiva_isr.h"
200
201#ifdef __cplusplus
202extern "C" {
203#endif
204 void hal_lld_init(void);
205 void tiva_clock_init(void);
206#ifdef __cplusplus
207}
208#endif
209
210#endif /* HAL_LLD_H */
211
212/**
213 * @}
214 */