We’ve taken over the ezDSP’s LEDs

SourceFilesDebug

/*
 * main.c
 * Author: a GSI from UMich's EECS 452 class
 */
#include <usbstk5515.h>
#include <stdio.h>

//MMIO addresses (GPIO out 1 and 2):
#define LED_out1 *( (ioport volatile Uint16*) 0x1C0A ) //Uint16: 16 bit unsigned int
#define LED_out2 *( (ioport volatile Uint16*) 0x1C0B )

//GPIO dir 1 and 2:
#define LED_dir1 *( (ioport volatile Uint16*) 0x1C06 )
#define LED_dir2 *( (ioport volatile Uint16*) 0x1C07 )

//initializing LED GPIOs as outputs. LEDs are active low => writing 1s to keep them off
void LED_init() {
 LED_dir1 |= (Uint16) (3 << 14); //GPIOs 14, 15
 LED_dir2 |= (Uint16) 3; //GPIOs 16, 17
 //switching them off (driving high)
 LED_out1 |= (Uint16) (3 << 14);
 LED_out2 |= (Uint16) 3;
}

//LED toggling based on index inputted
void toggle_LED(int index) {
 if (index == 3) //Blue: GPIO[14]
 LED_out1 = LED_out1 ^ (Uint16)(1<< (14) );
 else if(index == 2) //Yellow(ish) <-- LOL: GPIO[15]
 LED_out1 = LED_out1 ^ (Uint16)(1<< (15) );
 else if(index == 1) //Red: GPIO[16]
 LED_out2 = LED_out2 ^ (Uint16)(1<< (0) );
 else if(index == 0) //Green: GPIO[17]
 LED_out2 = LED_out2 ^ (Uint16)(1<< (1) );
}

void main(void) { //who uses void main...ever?
 Uint16 value;
 USBSTK5515_init(); //initializes the processor...missing purple color coding? Because typo.

 LED_init();

 while(1) {
 printf("Pick an LED to toggle (0, 1, 2, 3):\n");
 scanf("%d", &value); //where is this getting inputted? On the host PC?
 toggle_LED(value);
 }
}

20150216-022009.jpg

20150216-022022.jpg

20150216-022035.jpg

20150216-022049.jpg

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s