Exemplo n.º 1
0
//******************************************************************************
//                            MAIN FUNCTION
//******************************************************************************
int main()
{   
    long lRetVal = -1;

    BoardInit();
    
    //
    // Pinmux Configuration
    //
    PinMuxConfig();
    
    //
    // Initialising the UART terminal
    //
    InitTerm();

    //
    // Create RX and TX Buffer
    //
    pTxBuffer = CreateCircularBuffer(TX_BUFFER_SIZE);
    if(pTxBuffer == NULL)
    {
        UART_PRINT("Unable to Allocate Memory for Tx Buffer\n\r");
        LOOP_FOREVER();
    }    
    pRxBuffer = CreateCircularBuffer(RX_BUFFER_SIZE);
    if(pRxBuffer == NULL)
    {
        UART_PRINT("Unable to Allocate Memory for Rx Buffer\n\r");
        LOOP_FOREVER();
    }    
    
    //
    // Initialising the I2C Interface
    //    
    lRetVal = I2C_IF_Open(1);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }


    //
    // Configure Audio Codec
    //     
    ConfigureAudioCodec(CODEC_I2S_WORD_LEN_24);
       
    GPIO_IF_LedConfigure(LED2|LED3);

    GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);    
    
    //
    // Configure PIN_01 for GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);
    
    //
    // Configure PIN_02 for GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);
    
    
    //Turning off Green,Orange LED after i2c writes completed - First Time
    GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
    GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO);
    
    //
    // Initialize the Audio(I2S) Module
    //    
    AudioCapturerInit();
  
    //
    // Initialize the DMA Module
    //    
    UDMAInit();
    UDMAChannelSelect(UDMA_CH4_I2S_RX, NULL);
    UDMAChannelSelect(UDMA_CH5_I2S_TX, NULL);
   
    //
    // Setup the DMA Mode
    //     
    SetupPingPongDMATransferTx();
    SetupPingPongDMATransferRx();
    
    //
    // Setup the Audio In/Out
    //     
    lRetVal = AudioCapturerSetupDMAMode(DMAPingPongCompleteAppCB_opt, \
                                            CB_EVENT_CONFIG_SZ);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }    
    AudioCaptureRendererConfigure();
    
    // 
    // Start Audio Tx/Rx
    //     
    Audio_Start();
    
    //
    // Start the simplelink thread
    //
    lRetVal = VStartSimpleLinkSpawnTask(9);  
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }


    //
    // Start the Network Task
    //    
    lRetVal = osi_TaskCreate( Network, (signed char*)"NetworkTask",\
                                OSI_STACK_SIZE, NULL, 
                                1, &g_NetworkTask );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }


    //
    // Start the Control Task
    //     
    lRetVal = ControlTaskCreate();
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }    
    
    //
    // Start the Microphone Task
    //       
    lRetVal = osi_TaskCreate( Microphone,(signed char*)"MicroPhone", \
                                OSI_STACK_SIZE, NULL, 
                                1, &g_MicTask );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the Speaker Task
    //
    lRetVal = osi_TaskCreate( Speaker, (signed char*)"Speaker",OSI_STACK_SIZE, \
                                NULL, 1, &g_SpeakerTask ); 
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    
    //
    // Start the task scheduler
    //
    osi_start();      
}
Exemplo n.º 2
0
//******************************************************************************
//                            MAIN FUNCTION
//******************************************************************************
int main()
{
    long lRetVal = -1;
    unsigned char	RecordPlay;

    BoardInit();

    //
    // Pinmux Configuration
    //
    PinMuxConfig();

    //
    // Initialising the UART terminal
    //
    InitTerm();


    //
    // Initialising the I2C Interface
    //
    lRetVal = I2C_IF_Open(1);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    RecordPlay = I2S_MODE_RX_TX;
    g_loopback = 1;


    //
    // Create RX and TX Buffer
    //
    if(RecordPlay == I2S_MODE_RX_TX)
    {
        pRecordBuffer = CreateCircularBuffer(RECORD_BUFFER_SIZE);
        if(pRecordBuffer == NULL)
        {
            UART_PRINT("Unable to Allocate Memory for Tx Buffer\n\r");
            LOOP_FOREVER();
        }
    }

    /* Play */
    if(RecordPlay & I2S_MODE_TX)
    {
        pPlayBuffer = CreateCircularBuffer(PLAY_BUFFER_SIZE);
        if(pPlayBuffer == NULL)
        {
            UART_PRINT("Unable to Allocate Memory for Rx Buffer\n\r");
            LOOP_FOREVER();
        }
    }


    //
    // Configure Audio Codec
    //
    AudioCodecReset(AUDIO_CODEC_TI_3254, NULL);
    AudioCodecConfig(AUDIO_CODEC_TI_3254, AUDIO_CODEC_16_BIT, 16000,
                     AUDIO_CODEC_STEREO, AUDIO_CODEC_SPEAKER_ALL,
                     AUDIO_CODEC_MIC_ALL);

    AudioCodecSpeakerVolCtrl(AUDIO_CODEC_TI_3254, AUDIO_CODEC_SPEAKER_ALL, 50);
    AudioCodecMicVolCtrl(AUDIO_CODEC_TI_3254, AUDIO_CODEC_SPEAKER_ALL, 50);


    GPIO_IF_LedConfigure(LED2|LED3);

    GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);

    //
    // Configure PIN_01 for GPIOOutput
    //
    //MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
    // MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_02 for GPIOOutput
    //
    //MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    // MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);


    //Turning off Green,Orange LED after i2c writes completed - First Time
    GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
    GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO);

    //
    // Initialize the Audio(I2S) Module
    //

    AudioInit();

    //
    // Initialize the DMA Module
    //
    UDMAInit();
    if(RecordPlay & I2S_MODE_TX)
    {
        UDMAChannelSelect(UDMA_CH5_I2S_TX, NULL);
        SetupPingPongDMATransferRx(pPlayBuffer);
    }
    if(RecordPlay == I2S_MODE_RX_TX)
    {
        UDMAChannelSelect(UDMA_CH4_I2S_RX, NULL);
        SetupPingPongDMATransferTx(pRecordBuffer);
    }

    //
    // Setup the Audio In/Out
    //
    lRetVal = AudioSetupDMAMode(DMAPingPongCompleteAppCB_opt, \
                                CB_EVENT_CONFIG_SZ, RecordPlay);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }
    AudioCaptureRendererConfigure(AUDIO_CODEC_16_BIT, 16000, AUDIO_CODEC_STEREO, RecordPlay, 1);

    //
    // Start Audio Tx/Rx
    //
    Audio_Start(RecordPlay);

    //
    // Start the simplelink thread
    //
    lRetVal = VStartSimpleLinkSpawnTask(9);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }


    //
    // Start the Network Task
    //
    lRetVal = osi_TaskCreate( Network, (signed char*)"NetworkTask",\
                              OSI_STACK_SIZE, NULL,
                              1, &g_NetworkTask );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the Control Task
    //
    lRetVal = ControlTaskCreate();
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the Microphone Task
    //
    lRetVal = osi_TaskCreate( Microphone,(signed char*)"MicroPhone", \
                              OSI_STACK_SIZE, NULL,
                              1, &g_MicTask );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the Speaker Task
    //
    lRetVal = osi_TaskCreate( Speaker, (signed char*)"Speaker",OSI_STACK_SIZE, \
                              NULL, 1, &g_SpeakerTask );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the task scheduler
    //
    osi_start();
}