/* * Copyright (C) 2018, Hogeschool Rotterdam, Harry Broeders * All rights reserved. */ #include #include #include #include #include #include #include #include #include #include "ti_drivers_config.h" #include "config.h" // You can select the sample rate here: #define SAMPLINGFREQUENCY 32000 #include "/home/mreenen/.local/MATLAB/R2022a/extern/include/tmwtypes.h" #include "anderanderezooi.h" #define N BL //#define N 32 //const int BL = 32; //const int16_t B[32] = { // 1116, 1269, 1420, 1568, 1712, 1849, 1979, 2101, 2212, // 2312, 2400, 2474, 2535, 2581, 2612, 2628, 2628, 2612, // 2581, 2535, 2474, 2400, 2312, 2212, 2101, 1979, 1849, // 1712, 1568, 1420, 1269, 1116 //}; //#define N 33 //const int BL = 33; //const int16_t B[33] = { // 47, -54, 19, 293, 744, 1292, 1820, 2188, 2274, // 1994, 1329, 337, -856, -2075, -3128, -3840, 27997, -3840, // -3128, -2075, -856, 337, 1329, 1994, 2274, 2188, 1820, // 1292, 744, 293, 19, -54, 47 //}; int16_t buffer_R[N]; #if SAMPLINGFREQUENCY < 8000 || SAMPLINGFREQUENCY > 48000 || SAMPLINGFREQUENCY % 4000 != 0 #error Sampling Frequency must be between 8 kHz and 48 kHz (included) and must be a multiple of 4 kHz. #endif int main(void) { // Init CC3220S LAUNCHXL board. Board_initGeneral(); // Prepare to use TI drivers without operating system. NoRTOS_start(); printf("line-in_2_line_out: STEREO LINE IN ==> HP LINE OUT.\n"); printf("Sampling frequency = %d Hz.\n", SAMPLINGFREQUENCY); // Configure an I2C connection which is used to configure the audio codec. I2C_Handle i2cHandle = ConfigureI2C(CONFIG_I2C_0, I2C_400kHz); // Configure the audio codec. ConfigureAudioCodec(i2cHandle, SAMPLINGFREQUENCY); // Configure an I2S connection which is use to send/receive samples to/from the codec. ConfigureI2S(CONFIG_I2S_0, I2S_BASE, SAMPLINGFREQUENCY); unsigned long n = 0; unsigned long dataLeft, dataRight; int k; int i; while (1) { long outR, v; I2SDataGet(I2S_BASE, I2S_DATA_LINE_1, &dataLeft); I2SDataPut(I2S_BASE, I2S_DATA_LINE_0,(int16_t) 0); I2SDataGet(I2S_BASE, I2S_DATA_LINE_1, &dataRight); buffer_R[n] = dataRight; outR = 0; for (k=0; k < BL; k++) { v = n - k; if(v < 0){ outR += (B[k] * (long)buffer_R[(v + BL)]); }else{ outR += (B[k] * (long)buffer_R[(v)]); } } I2SDataPut(I2S_BASE, I2S_DATA_LINE_0, (outR >> 15)); n++; if(n == BL) n = 0; } return 0; }