Project

General

Profile

uPP receiving problem ยป main.cpp

Silvano Bertoldo, 07/21/2014 09:05 AM

 
1
/*
2
 * main.c
3
 */
4
#include <std.h>
5
#include <tsk.h>
6
#include <log.h>
7
#include <stdio.h>
8
#include <bcache.h>
9

    
10
#include "quadracfg.h"
11

    
12
#include "SigProc/SigProcFFT.h"
13
#include "core/DspUpp.h"
14

    
15
#define BUFF_SIZE 4096
16

    
17
/* Variables */
18
unsigned short flag;
19

    
20
#pragma DATA_ALIGN( 64 );
21
volatile int16_t buff1[BUFF_SIZE];
22

    
23
using namespace std;
24
using namespace MityDSP;
25

    
26
/* Definizione struttura di configurazione UPP */
27
tcDspUpp::tsDspUppConfig gsUppConfig =
28
	{
29
	4, // Interrupt level. Must be between 4 and 15.
30
	9, // Chan A DMA thread handling priority
31
	9, // Chan B DMA thread handling priority
32
	tcDspUpp::eeReceive, // Directionality of Channel A.
33
	tcDspUpp::eeDisabled, // Directionality of Channel B.
34
	tcDspUpp::ee16Bit, // Chan A data bit width.
35
	tcDspUpp::ee16Bit, // Chan B data bit width.
36
	false, // Use XData[7:0] for ChanA[15:8] even if ChanB is
37
	// disabled. See Table 3 in uPP User's Guide for details.
38
	4, // Size of MBX for Channel A.
39
	4, // Size of MBX for Channel B.
40
	0, // Clock divider for Channel A
41
	// (only in transmit mode). See Section 2.1.1 in uPP User's
42
	// Guide for details. Value must be between 1 and 16.
43
	0, // Clock divider for Channel B
44
	// (only in transmit mode). See Section 2.1.1 in uPP User's
45
	// Guide for details. Value must be between 1 and 16.
46
	tcDspUpp::ee256Bytes, // Chan A Transmit Thresh
47
	tcDspUpp::ee256Bytes, // Chan A Receive Thresh
48
	tcDspUpp::ee256Bytes, // Chan B Transmit Thresh
49
	tcDspUpp::ee256Bytes, // Chan B Receive Thresh
50
	true, // Do not use Chan A start signal
51
	false, // Do not use Chan B start signal
52
	//tcDspUpp::eeUPP_2xTXCLK, // Using external 2xTxClk for Transmit
53
	tcDspUpp::eePLL0_SYSCLK2,
54
	0 // uPP DMA Master Priority
55
	};
56

    
57
// Constant for receive channel.
58
tcDspUpp::teUppChan meRecvChan = tcDspUpp::eeChanA;
59

    
60
/* Puntatore all'oggetto per uPP */
61
tcDspUpp* mpDspUpp;
62

    
63
// Handle to receive mailbox.
64
MBX_Handle mhRecvMbx = NULL;
65
tcDspUpp::tsMbxMsg lsRecvMbxMsg;
66

    
67
#pragma DATA_ALIGN( 64 );
68
uint16_t nBytePerLine;
69
uint16_t nLineCount;
70

    
71
void TestTask();
72

    
73
void main()
74
{
75
	TSK_Handle tsk;
76
	TSK_Attrs tsk_attrs;
77
	tsk_attrs = TSK_ATTRS;
78
	tsk_attrs.priority = 5;
79
	tsk_attrs.name = "Test";
80
	tsk  = TSK_create((Fxn)TestTask, &tsk_attrs);
81
	return;
82
}
83

    
84
void TestTask()
85
{
86

    
87
	short int i;
88

    
89
	nBytePerLine = 2;
90
	nLineCount = BUFF_SIZE;
91
	
92
	mpDspUpp = tcDspUpp::getInstance();
93
	if (!mpDspUpp->initialize(&gsUppConfig))
94
	{	flag = 1;
95
		mhRecvMbx = mpDspUpp->getMBX(meRecvChan);
96
	}
97
	else
98
		flag = 0;
99

    
100
	if (!mpDspUpp->receive(meRecvChan, (uint8_t*)buff1, (uint16_t)nBytePerLine, (uint16_t)nLineCount) )
101
	{	flag = 1;
102
		if(MBX_pend(mhRecvMbx, &lsRecvMbxMsg, 10)==true)
103
			BCACHE_inv(lsRecvMbxMsg.pBufPtr, nLineCount, true);
104
	}
105
	else
106
		flag = 0;
107

    
108
	while(1)
109
	{
110
		i = 1;
111
	}
112
}
113

    
    (1-1/1)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)