/
initSPORT.c
140 lines (111 loc) · 4.18 KB
/
initSPORT.c
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
///////////////////////////////////////////////////////////////////////////////////////
//NAME: initSPORT.c (Block-based Talkthrough)
//DATE: 7/15/04
//PURPOSE: Talkthrough framework for sending and receiving samples to the AD1835.
//
//USAGE: This file initializes the SPORTs for DMA Chaining
//
////////////////////////////////////////////////////////////////////////////////////////
#include "tt.h"
//#define DAC1
//#define DAC2
//#define DAC3
//#define DAC4 //eredetileg csak ez.
//ezek a konstansok a tt.h-ban lesznek
//
//
//
//
/*
Here is the mapping between the SPORTS and the DACS
ADC -> DSP : SPORT0A : IIS
DSP -> DAC1 : SPORT1A : IIS
DSP -> DAC2 : SPORT1B : IIS
DSP -> DAC3 : SPORT2A : IIS
DSP -> DAC4 : SPORT2B : IIS
*/
unsigned int PCI = 0x00080000 ;
unsigned int OFFSET = 0x00080000 ;
// TCB blocks for Chaining
//Each block will be used for:
// Filling from the ADC
// Processing filled data
// Sending to DAC
//
//Each one is doing only one of these steps for each SPORT interrupt.
//For this example the startup state is
// Start to 1st interrupt: Block_A is filled first, Block_C is sent
// 1st int to 2nd int: Block_C filled, Block_A processed, Block_B sent
// 2nd int to 3rd int: Block_B filled, Block_C processed, Block_A sent
// 3rd int to 4th int: Block_A filled, Block_B processed, Block_C sent
unsigned int Block_A[NUM_SAMPLES] ;
unsigned int Block_B[NUM_SAMPLES] ;
unsigned int Block_C[NUM_SAMPLES] ;
//Set up the TCBs to rotate automatically
int TCB_Block_A[4] = { 0, sizeof(Block_A), 1, 0};;
int TCB_Block_B[4] = { 0, sizeof(Block_B), 1, 0};
int TCB_Block_C[4] = { 0, sizeof(Block_C), 1, 0};
void InitSPORT()
{
TCB_Block_A[0] = (int) TCB_Block_A + 3 - OFFSET + PCI ;
TCB_Block_A[3] = (unsigned int) Block_A - OFFSET ;
//Proceed from Block A to Block C
/* TCB_Block_A[0] = (int) TCB_Block_C + 3 - OFFSET + PCI ;
TCB_Block_A[3] = (unsigned int) Block_A - OFFSET ;
//Proceed from Block B to Block A
TCB_Block_B[0] = (int) TCB_Block_A + 3 - OFFSET + PCI ;
TCB_Block_B[3] = (unsigned int) Block_B - OFFSET ;
//Proceed from Block C to Block B
TCB_Block_C[0] = (int) TCB_Block_B + 3 - OFFSET + PCI ;
TCB_Block_C[3] = (unsigned int) Block_C - OFFSET ;
*/
*pSPMCTL01 = 0;
*pSPMCTL23 = 0;
*pSPCTL0 = 0 ;
*pSPCTL1 = 0 ;
*pSPCTL2 = 0 ;
//============================================================
//
// Configure SPORTs 1 & 2 for output to DACs 1-4
//
//------------------------------------------------------------
#define LENGTH_OF_DATA SLEN24
//esetleg |DITFS is lehetne: Data Independent Frame Signal
#ifdef DAC1
*pSPCTL1 = (SPTRAN | OPMODE | LENGTH_OF_DATA | SPEN_A | BHD /*| SCHEN_A | SDEN_A*/| DTYPE1 /*| DITFS*/) ;
*pTXSP1A = 10;
*pTXSP1A = 10;
// write to DAC1
//*pCPSP1A = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
#ifdef DAC2
*pSPCTL1 |= (SPTRAN | OPMODE | LENGTH_OF_DATA | SPEN_B | BHD /*| SCHEN_B | SDEN_B*/| DTYPE1 /*| DITFS*/) ;
*pTXSP1B = 0;
*pTXSP1B = 0;
// write to DAC2
//*pCPSP1B = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
#ifdef DAC3
*pSPCTL2 = (SPTRAN | OPMODE | LENGTH_OF_DATA | SPEN_A | BHD /*| SCHEN_A | SDEN_A*/| DTYPE1 /*| DITFS*/) ;
*pTXSP2A = 0;
*pTXSP2A = 0;
// write to DAC3
//*pCPSP2A = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
#ifdef DAC4
*pSPCTL2 |= (SPTRAN | OPMODE | LENGTH_OF_DATA | SPEN_B | BHD /*| SCHEN_B | SDEN_B*/| DTYPE1 /*| DITFS*/) ;
*pTXSP2B = 0;
*pTXSP2B = 0;
// write to DAC4
//*pCPSP2B = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
//============================================================
//
// Configure SPORT 0 for input from ADC
//
//------------------------------------------------------------
*pSPCTL0 = (BHD | OPMODE | LENGTH_OF_DATA | SPEN_A | SCHEN_A | SDEN_A | DTYPE1);
// Enabling Chaining
// Block A will be filled first
*pCPSP0A = (unsigned int) TCB_Block_A - OFFSET + 3 + PCI; //eredetileg nincs
}