Rajath Ravi / Mbed 2 deprecated ADC_DMA_POST_LEC12

Dependencies:   mbed

main.cpp

Committer:
rajathr
Date:
2021-11-03
Revision:
1:c125f4e65df7
Parent:
0:716b93ab9a58

File content as of revision 1:c125f4e65df7:

#include "gpio.h"
#include "mbed.h"
#include "hardware_adc.h"
#include "hardware_dma_controller.h"

Serial pc(USBTX, USBRX);


int main(void)
{
    uint32_t i,j,k;
    j = 0;
    
    //For Design Problem 1 - Exercise 10 - START
    initADC3_5_withDMA();
    InitPortBPin0asOutput(); //initialize GPIOB as Output
    startADCConversion(); 
    //For Design Problem 1 - Exercise 10 - END
    
    //For Design Problem 2 - Exercise 10 - START
    initADC3_567_withDMA();
    InitPortBPin0asOutput(); //initialize GPIOB as Output
    startADCConversion(); 
    //For Design Problem 2 - Exercise 10 - END
    
    while(1)
    {
        for (i=0; i<10000000; i++)
        {
            for(k=0; k<10000000; k++)
            {
                j=j+1; //Tiny Delay
            }
        }
        
        //Code for DMA - DESIGN PROBLEM 1 - Exercise 10 - START
        pc.printf("ADC Value is %u\n", returnADC3StoredValue1Channel(0));
        toggleGPIOB0();
        //Code for DMA - DESIGN PROBLEM 1 - Exercise 10 - END
        
        
        //Code for DMA - DESIGN PROBLEM 2 - Exercise 10 - START
        pc.printf("ADC Value 1 is %u, ADC Value 2 is % u and ADC Value 3 is %u\n", returnADC3StoredValue3Channel(0), returnADC3StoredValue3Channel(1), returnADC3StoredValue3Channel(2));
        toggleGPIOB0();
        //Code for DMA - DESIGN PROBLEM 2 - Exercise 10 - END
    }
}