I downloaded the GPIO code from the c5505 Google Docs page -- http://code.google.com/p/c5505-ezdsp/ -- and stock, it seemed to be running just fine.
I modified the code to better suit the application i have planned for the GPIO pins. Essentially, 3 of these pins, GPIO[22:24], will be fed by a 3-way rotary switch that will be sending the required 3.3V for a logical 1. Below is the code i have attempted to run.
#include <stdio.h>
#include "tistdtypes.h"
#define EBSR *((volatile ioport Uint16 *)(0x1C00)) //Pin-mux selection register
#define IODIR1 *((volatile ioport Uint16 *)(0x1C06)) //IO direction selection
#define IODIR2 *((volatile ioport Uint16 *)(0x1C07)) //IO direction selection
#define IOINDATA1 *((volatile ioport Uint16 *)(0x1C08)) //GPIO input data register1
#define IOINDATA2 *((volatile ioport Uint16 *)(0x1C09)) //GPIO input data register2
void main (void)
{
Uint16 read_input;
//set mux-selection for GPIO[22:24]
EBSR |= 0x000E;
// set GPIO[22:24] as inputs
IODIR2 |= 0xFE3F;
while(1)
{
//read the input port
read_input = IOINDATA2;
//check the status of GPIO[22:24]
if (read_input && 0x0040){
//if ((read_input & 0x0040) == 1){
printf("worked 22 \n");
}
else if (read_input && 0x0080) {
//else if ((read_input & 0x0080) == 1){
printf("worked 23 \n");
}
else if (read_input && 0x0100) {
//else if ((read_input & 0x0100) == 1){
printf("worked 24 \n");
}
else {
printf(" nope :( \n");
}
}
}
I have tried two different ways to check read_input against the value i'm looking for using bit-wise AND and Logical AND; both do not seem to work.
I have a 3.3V DC supply on a bread-board that i'm using to feed these GPIO pins as well, so I believe the voltage level should be ok.
Also, it compiles with two warnings, which I am not sure if they are critical or not.
1) creating output section ".cio" without a SECTIONS specification
2) creating ".sysmem" section without default size of 0x7d0; use the -heap option to change the default size
I could really use some help because i've been stuck on this for too long :(
Thanks for reading!