?? initsport.c
字號:
///////////////////////////////////////////////////////////////////////////////////////
//NAME: initSPORT.c (Block-based Talkthrough)
//DATE: 9/18/03
//PURPOSE: Talkthrough framework for sending and receiving samples to the AD1835.
//
//USAGE: This file initializes the SPORTs for DMA Chaining
//
////////////////////////////////////////////////////////////////////////////////////////
#include "tt.h"
#define DAC4
/*
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()
{
//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 ;
*(volatile int *)SPMCTL01 = 0;
*(volatile int *)SPMCTL23 = 0;
*(volatile int *)SPCTL0 = 0 ;
*(volatile int *)SPCTL1 = 0 ;
*(volatile int *)SPCTL2 = 0 ;
//============================================================
//
// Configure SPORT 0 for input from ADC
//
//------------------------------------------------------------
*(volatile int *)SPCTL0 = (BHD | OPMODE | SLEN24 | SPEN_A | SCHEN_A | SDEN_A);
// Enabling Chaining
// Block A will be filled first
*(volatile int *)CPSP0A = (unsigned int) TCB_Block_A - OFFSET + 3 ;
//============================================================
//
// Configure SPORTs 1 & 2 for output to DACs 1-4
//
//------------------------------------------------------------
#ifdef DAC1
*(volatile int *)SPCTL1 = (SPTRAN | OPMODE | SLEN24 | SPEN_A | BHD | SCHEN_A | SDEN_A) ;
// write to DAC1
*(volatile int *)CPSP1A = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
#ifdef DAC2
*(volatile int *)SPCTL1 |= (SPTRAN | OPMODE | SLEN24 | SPEN_B | BHD | SCHEN_B | SDEN_B) ;
// write to DAC2
*(volatile int *)CPSP1B = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
#ifdef DAC3
*(volatile int *)SPCTL2 = (SPTRAN | OPMODE | SLEN24 | SPEN_A | BHD | SCHEN_A | SDEN_A) ;
// write to DAC3
*(volatile int *)CPSP2A = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
#ifdef DAC4
*(volatile int *)SPCTL2 |= (SPTRAN | OPMODE | SLEN24 | SPEN_B | BHD | SCHEN_B | SDEN_B) ;
// write to DAC4
*(volatile int *)CPSP2B = (unsigned int) TCB_Block_C - OFFSET + 3 ;
#endif
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -