1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
/***************************************************************************/
/* Copyright (c) 2024 Microsoft Corporation */
/* Copyright (c) 2026 Eclipse ThreadX contributors */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the MIT License which is available at */
/* https://opensource.org/licenses/MIT. */
/* */
/* SPDX-License-Identifier: MIT */
/***************************************************************************/
/*
* board_setup.c
*
*/
#include "board_setup.h"
#include <string.h>
//=============================================================================
//============ General definitions ============================================
//=============================================================================
// DSP Timer-8 definition
#define C66XX_DSP_TIMER C66XX_TIMER_8
// DSP Timer-8 output frequency in Hz
#define C66XX_DSP_TIMER_FREQ 100
/* DSP Timer-8 interrupt event ID */
#define C66XX_DSP_TIMER_EVENT_ID 67
//=============================================================================
//=============================================================================
//============ Global functions ===============================================
//=============================================================================
void _tx_nmi_vector(void);
void _tx_int4_vector(void);
void _tx_int5_vector(void);
void _tx_int6_vector(void);
void _tx_int7_vector(void);
void _tx_int8_vector(void);
void _tx_int9_vector(void);
void _tx_int10_vector(void);
void _tx_int11_vector(void);
void _tx_int12_vector(void);
void _tx_int13_vector(void);
void _tx_int14_vector(void);
void _tx_int15_vector(void);
//=============================================================================
//=============================================================================
//============ Static functions ===============================================
//=============================================================================
static int32_t tx_timer_init(C66XX_TIMER timer, uint32_t frequency);
static int32_t tx_interrupt_init(void);
//=============================================================================
/*------------ init_output_timer() function -----------------------------------
* DESCRIPTION: Function initializes Timer64 module
* ARGUMENTS:
* None
* RETURNED VALUE: Error code
-----------------------------------------------------------------------------*/
static int32_t tx_timer_init(C66XX_TIMER timer, uint32_t frequency)
{
int32_t r;
C66XX_TIMER_CFG_DD cfg_dd;
// Reset 64-bit timer
if ((r = C66XX_TIMER_reset(timer, C66XX_TIMER_HW_CFG_64BIT)) != C66XX_OK)
goto exit;
// Fill configuration data descriptor
memset(&cfg_dd, 0, C66XX_TIMER_CFG_DD_LEN);
cfg_dd.timer_mode = C66XX_TIMER_MODE_32BIT_UNCHAINED;
cfg_dd.timer_high.clk_src_output_mode = C66XX_TIMER_CLK_OUTPUT_MODE_CLK;
// Init DSP Timer64 module
if ((r = C66XX_TIMER_init(timer, frequency, &cfg_dd)) != C66XX_OK)
goto exit;
// Enable timer interrupt
if ((r = C66XX_TIMER_enable_interrupts(timer, C66XX_TIMER_HW_CFG_32BIT_HIGH)) != C66XX_OK)
goto exit;
// Start 32-bit timer high to enable continuously
if ((r = C66XX_TIMER_start(timer, C66XX_TIMER_HW_CFG_32BIT_HIGH, C66XX_TIMER_COUNT_MODE_CONTINUOUSLY)) != C66XX_OK)
goto exit;
// TIMER module configuration is completed
printf("Timer #%u configuration is completed\n", timer);
exit:
return (r);
}
//-----------------------------------------------------------------------------
/*------------ tx_interrupt_init() function -----------------------------------
* DESCRIPTION: Function initializes CorePack interrupt module
* ARGUMENTS:
* None
* RETURNED VALUE: Error code
-----------------------------------------------------------------------------*/
static int32_t tx_interrupt_init(void)
{
int32_t r;
// Set DSP interrupt handlers to the ones defined in tx_initialize_low_level.asm
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_NMI, _tx_nmi_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_4, _tx_int4_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_5, _tx_int5_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_6, _tx_int6_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_7, _tx_int7_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_8, _tx_int8_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_9, _tx_int9_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_10, _tx_int10_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_11, _tx_int11_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_12, _tx_int12_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_13, _tx_int13_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_14, _tx_int14_vector)) != C66XX_OK)
goto exit;
if ((r = C66XX_INT_set_core_dsp_interrupt_handler(C66XX_DSP_VECTID_15, _tx_int15_vector)) != C66XX_OK)
goto exit;
/* CorePack interrupt module configuration is completed */
printf("INTC configuration is completed\n");
// Exit without errors
r = TASDK_OK;
exit:
return (r);
}
//-----------------------------------------------------------------------------
/*------------ hardware_setup() function --------------------------------------
* DESCRIPTION: Function intializes board hardware
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
int hardware_setup()
{
int r;
/* Init DSP */
if ((r = TA66XX_BC_init()) != TASDK_OK)
goto exit;
// Initialize UART
if ((r = TA66XX_BC_init_uart(C66XX_UART_BAUD_RATE_115200, C66XX_UART_DATA_BITS_8BITS, C66XX_UART_PARITY_NONE, C66XX_UART_STOP_BITS_1BIT)) != TASDK_OK)
goto exit;
// Init DSP Timer
if ((r = tx_timer_init(C66XX_DSP_TIMER, C66XX_DSP_TIMER_FREQ)) != TASDK_OK)
goto exit;
// Init DSP interrupt controller
if ((r = tx_interrupt_init()) != TASDK_OK)
goto exit;
printf("Board is initialized\n");
/* Exit with no errors */
exit:
return (r);
}
//-----------------------------------------------------------------------------
/*------------ tx_nmi_handler() function --------------------------------------
* DESCRIPTION: Function handles NMI interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_nmi_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int4_handler() function -------------------------------------
* DESCRIPTION: Function handles INT4 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int4_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int5_handler() function -------------------------------------
* DESCRIPTION: Function handles INT5 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int5_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int6_handler() function -------------------------------------
* DESCRIPTION: Function handles INT6 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int6_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int7_handler() function -------------------------------------
* DESCRIPTION: Function handles INT7 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int7_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int8_handler() function -------------------------------------
* DESCRIPTION: Function handles INT8 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int8_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int9_handler() function -------------------------------------
* DESCRIPTION: Function handles INT9 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int9_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int10_handler() function ------------------------------------
* DESCRIPTION: Function handles INT10 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int10_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int11_handler() function ------------------------------------
* DESCRIPTION: Function handles INT11 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int11_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int12_handler() function ------------------------------------
* DESCRIPTION: Function handles INT12 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int12_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int13_handler() function ------------------------------------
* DESCRIPTION: Function handles INT13 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int13_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int14_handler() function ------------------------------------
* DESCRIPTION: Function handles INT14 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int14_handler(void)
{
}
//-----------------------------------------------------------------------------
/*------------ tx_int15_handler() function ------------------------------------
* DESCRIPTION: Function handles INT15 interrupt
* ARGUMENTS:
* None
* RETURNED VALUE: None
-----------------------------------------------------------------------------*/
void tx_int15_handler(void)
{
}
//-----------------------------------------------------------------------------
|