test

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Piasiv1206
Date:
Sat Mar 21 09:09:12 2015 +0000
Commit message:
test

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 81825898e19f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Mar 21 09:09:12 2015 +0000
@@ -0,0 +1,269 @@
+#include "mbed.h"
+
+DigitalOut gpo(D0);
+DigitalOut led(LED_RED);
+
+int main()
+{
+    while (true) {
+        gpo = !gpo; // toggle pin
+        led = !led; // toggle led
+        wait(0.2f);
+    }
+}
+
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include "driverlib/debug.h"
+#include "driverlib/gpio.h"
+#include "driverlib/pin_map.h"
+#include "driverlib/rom.h"
+#include "driverlib/sysctl.h"
+#include "driverlib/fpu.h"
+#include "driverlib/uart.h"
+#include "utils/uartstdio.h"
+#include "driverlib/timer.h"
+#include "driverlib/adc.h"
+#include "driverlib/interrupt.h"
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "inc/tm4c123gh6pm.h"
+
+
+void Timer(void)
+{
+
+    volatile uint32_t ui32Loop;
+
+
+        TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
+        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
+        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 ,GPIO_PIN_1);
+        SysCtlDelay(SysCtlClockGet());
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,0x0);
+        SysCtlDelay(SysCtlClockGet());
+        //UARTprintf("PRIYA \n");
+}
+
+void UARTIntHandler(void)
+
+{
+
+    //unsigned int i=0;
+    char LED;
+    //char LED;
+    //char LEDR[10] = 'L','E','D','R';
+    // LEDB[10] = "L","E","D","B" ;
+    uint32_t ui32Status;
+
+        //
+        // Get the interrrupt status.
+        //
+        ui32Status = UARTIntStatus(UART0_BASE, true);
+
+        //
+        // Clear the asserted interrupts.
+        //
+        UARTIntClear(UART0_BASE, ui32Status);
+
+    //while(UARTCharsAvail(UART0_BASE))
+
+    //{
+    LED = UARTCharGetNonBlocking(UART0_BASE);
+    //i++;
+    //}
+
+    if(LED=='R')
+    {
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 ,GPIO_PIN_1);
+    }
+
+    else if (LED=='B')
+    {
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2 ,GPIO_PIN_2);
+    }
+
+    else if (LED== 'O')
+    {
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2 ,0);
+    }
+
+    else if (LED== 'H')
+    {
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 ,0);
+    }
+    else if (LED=='Q')
+        {
+            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3 ,0);
+        }
+    else if (LED=='G')
+        {
+            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3 ,GPIO_PIN_3);
+        }
+    else
+    {
+       UARTprintf("Invalid Input/n");
+    }
+
+
+
+
+
+
+
+    //UARTprintf("priya\n");
+    UARTprintf("%c \n",LED);
+}
+
+/*
+void
+UARTIntHandler(void)
+{
+    uint32_t ui32Status;
+
+    //
+    // Get the interrrupt status.
+    //
+    ui32Status = ROM_UARTIntStatus(UART0_BASE, true);
+
+    //
+    // Clear the asserted interrupts.
+    //
+    ROM_UARTIntClear(UART0_BASE, ui32Status);
+
+    //
+    // Loop while there are characters in the receive FIFO.
+    //
+    while(ROM_UARTCharsAvail(UART0_BASE))
+    {
+        //
+        // Read the next character from the UART and write it back to the UART.
+        //
+        ROM_UARTCharPutNonBlocking(UART0_BASE,
+                                   ROM_UARTCharGetNonBlocking(UART0_BASE));
+
+        //
+        // Blink the LED to show a character transfer is occuring.
+        //
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
+
+        //
+        // Delay for 1 millisecond.  Each SysCtlDelay is about 3 clocks.
+        //
+        SysCtlDelay(SysCtlClockGet() / (1000 * 3));
+
+        //
+        // Turn off the LED
+        //
+        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
+
+    }
+}
+*/
+
+
+void
+ConfigureUART(void)
+{
+    //
+    // Enable the GPIO Peripheral used by the UART.
+    //
+    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
+
+    //
+    // Enable UART0
+    //
+    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
+
+    //
+    // Configure GPIO Pins for UART mode.
+    //
+    GPIOPinConfigure(GPIO_PA0_U0RX);
+    GPIOPinConfigure(GPIO_PA1_U0TX);
+    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
+
+    //
+    // Use the internal 16MHz oscillator as the UART clock source.
+    //
+    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
+
+    //
+    // Initialize the UART for console I/O.
+    //
+    UARTStdioConfig(0, 115200, 16000000);
+}
+
+
+void main(){
+    volatile uint32_t ui32Loop;
+    //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
+    //GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
+    //GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 ,GPIO_PIN_1);
+    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
+                       SYSCTL_XTAL_16MHZ);
+    FPULazyStackingEnable();
+    FPUEnable();
+    int x,p,z;
+    float volt,s;
+
+    IntMasterEnable();
+
+    IntPrioritySet(INT_UART0, 0x00);
+    IntPrioritySet(INT_TIMER0A, 0x40);
+
+
+        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
+        TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
+       TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()*60);
+       IntEnable(INT_TIMER0A);
+       TimerEnable(TIMER0_BASE, TIMER_A);
+       TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
+    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
+    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
+    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
+    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
+    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
+    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
+    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
+    ADCSequenceEnable(ADC0_BASE, 3);
+    ADCIntClear(ADC0_BASE, 3);
+
+
+
+
+
+    ConfigureUART();
+    UARTFlowControlSet(UART0_BASE,UART_FLOWCONTROL_NONE);
+    IntEnable(INT_UART0);
+    UARTFIFODisable(UART0_BASE);
+    UARTIntEnable(UART0_BASE, UART_INT_RX );
+    UARTFIFOLevelSet(UART0_BASE,UART_FIFO_TX1_8,UART_FIFO_RX1_8);
+    while(1){
+        //GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
+                //GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 ,GPIO_PIN_1);
+                //SysCtlDelay(200000);
+                //for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
+                     //   {
+                      //  }
+                //GPIO_PORTF_DATA_R = 0x0;
+                //for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
+                                  //      {
+                                   //     }
+        x=ADC0_SSFIFO3_R;
+        ADC0_PSSI_R = 1<<3;
+    volt = 0.0008058608*x;
+    p = volt;
+    p = p*1000;
+    volt = 0.0008058608*x*1000;
+    s = volt;
+    z = s-p;
+    p = p/1000;
+
+    UARTprintf("Priya %d",x);
+    UARTprintf("volt: %d.%03d \n",p,z);
+    x = 0;
+}
+}
diff -r 000000000000 -r 81825898e19f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Mar 21 09:09:12 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file