// This project uses support files generated by Rulph Chassaing
// Comm routines included in C6xdskinit.c

/*1 */ #include "dsk6713_aic23.h"            // needed to access codec function
/*2 */ #include <math.h>                     // needed for sin(*/ function
/*3 */ #define PI 3.14159265359              // define the constant PI 
/*4 */ Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;    // sampling frequency of codec
/*5 */ float f0=1000;                        // generated sinusoid frequency
/*6 */ float fs_float;                       // needed for calculating offset
/*7 */ float angle=0;                        // sin(*/ argument in radians
/*8 */ float offset;                         // sin(*/ argument change per sample period
/*9 */ short amp=20;                         // sine amplitude scaling factor
/*10*/ short sine_value;                     // value sent to codec
/*11*/ 
/*12*/ interrupt void c_int11()              // interrupt service routine
/*13*/ {
/*14*/  switch(fs)                           // get sampling freq in Hz from fs
/*15*/  {
/*16*/    case   DSK6713_AIC23_FREQ_8KHZ:
/*17*/    case   DSK6713_AIC23_FREQ_16KHZ:
/*18*/    case   DSK6713_AIC23_FREQ_24KHZ:
/*19*/    case   DSK6713_AIC23_FREQ_32KHZ:
/*20*/    case   DSK6713_AIC23_FREQ_48KHZ:
/*21*/           fs_float=8000*fs;
/*22*/           break;
/*23*/   case DSK6713_AIC23_FREQ_44KHZ:
/*24*/           fs_float=44000;
/*25*/           break;
/*26*/   case DSK6713_AIC23_FREQ_96KHZ:
/*27*/           fs_float=96000;
/*28*/           break;
/*29*/   }
/*30*/  offset=2*PI*f0/fs_float;             // set offset value
/*31*/  angle = angle + offset;              // previous angle plus offset 
/*32*/  if (angle > 2*PI)                    // reset angle if > 2*PI
/*33*/    angle -= 2*PI;                     // angle = angle - 2*PI 
/*34*/  sine_value=(short)1000*amp*sin(angle);  // calculate current output sample
/*35*/  output_left_sample(sine_value);      // output each sine value
/*36*/  return;                              // return from interrupt
/*37*/ }
/*38*/ 
/*39*/ void main()
/*40*/ {
/*41*/   comm_intr();                        // init DSK, codec, SP0 for interrupts
/*42*/   while(1);                           // wait for an interrupt to occur
/*43*/ }
