///////////////////////////////////////////////////////////////////////
// Filename: main.c
//
// Synopsis: Main program file for frame-based processing using DSP/BIOS
//				Added RTDX stuff.
//
// Authors:  Michael G. Morrow, 3/17/2004
//
// Changes by:	Mark A. Yoder
//
// Date of Last Revision: 31-Mar-2004
//
// Copyright (c): 2001-2004 by Michael G. Morrow.  All rights reserved.
///////////////////////////////////////////////////////////////////////

#include "frames.h"
#include <bsl.h>
#include <rtdx.h>
#include "DSK_Support.h"
#include "c6711cfg.h"

int main()
{
	// initialize all buffers to 0
	ZeroBuffers();
	
	// fall through to DSP/BIOS
}

/*
	The following code is run by the period timer.  It checks the
	MSB (not the sign bit).  If it is 1, it turns the LED on.
	This is a way to see if there is clipping.	
*/
void blinkLEDs(void) {

	int i;
	short lmax=0, ltmp;
	short rmax=0, rtmp;
		
	for(i=0; i<BUFFER_LENGTH; i+=2) {
		rtmp = _abs(buffer[0][i]);
		ltmp = _abs(buffer[0][i+1]);
		rmax = rmax<rtmp ? rtmp: rmax;
		lmax = lmax<ltmp ? ltmp: lmax;
	}
//	LOG_printf(&logTrace, "blinkLeds:  max = %d, %d", lmax, rmax);
	// Turn LED on if MSB (not sign bit) is on.
//	if(lmax & 0x4000) LED_on(LED_3); else LED_off(LED_3);
	if(rmax & 0x4000) LED_on(LED_1); else LED_off(LED_1);
}