Tool/software: TI C/C++ Compiler
Hallo,
I use the board ezdsp5535 and followed the "CSL_GPIO_InputPinExample".
I have a question.
I used the GPIO REGISTERS, in order to generate INTERRUPT on the pin -GPIO10 AND GPIO11.
When the interrupt is active on the pin GPIO10, must display a text on the LCD OR if the interrupt is active on the pin GPIO11, must display another text on the LCD.
1. HOW TO USE 2 INTERRUPTS IN THE SAME PROGRAM???
2. HOW TO CONFIGURE THE PINS (GPIO10 AND GPIO11)?? - IN THE SAME FUNCTIONS ("int gpio_input_int_test(void)")???
-OR I HAVE TO CREATE DIFFERENT FUNCTIONS IN ORDER TO CONFIGURE THEM???
I attached my program bellow.
Thank you so much!!!
Cristina
/* TEST DESCRIPTION: * This example code tests the GPIO(General Purpose Input Output) pin * functionality as input pin. * C5505/C5515 DSP is having 32 GPIO pins which can be configured as input or * output. GPIO pin 11 is configured as input pin by this test code. * For verifying the input functionality, a source is required which sends data * to the GPIO pin configured as input pin. GPIO pin 4 is configured as output * pin and is used as data source for pin 11. These two pins should be connected * with a jumper on the EVM to facilitate the data loop back. Interrupts are * enabled for the GPIO input pin to indicate the high signal on the input pin. * A data value 1 is written to the GPIO pin4 which is loop backed to the pin11 * and is read in the ISR. Test will be successful when the GPIO interrupt for * pin11 is generated. Value read from the pin11 is also compared with the value * written to the pin4 to announce the success of the test. */ #include "ezdsp5535.h" #include "ezdsp5535_led.h" #include "csl_gpio.h" #include "csl_intc.h" #include "ezdsp5535_lcd.h" #include <stdio.h> #include <csl_general.h> #include <string.h> #define CSL_TEST_FAILED (-1) #define CSL_TEST_PASSED (0) /* Global Structure Declaration */ extern CSL_GpioObj GpioObj; extern CSL_GpioObj *hGpio; //int i = 0; Uint16 readVal = 0; Uint16 led = FALSE; int pin_int = 0; //intrerupere activa pe pinul x /* Reference the start of the interrupt vector table */ /* This symbol is defined in file vectors.asm */ extern void VECSTART(void); /* GPIO Interrupt Service Routine */ interrupt void gpioISR(void); /* Function to test the functionality of GPIO as input pin * This function configures GPIO pin 11 as input pin and pin 4 as output pin * A data value is written to pin4 and is read from pin11. Both the values are * compared and the result is returned to the main function. */ int gpio_input_int_test(void); /*afisarea lcd*/ void oled_display(void); volatile Int16 PaSs_StAtE = 0x0001; volatile Int16 PaSs = 0x0000; void main(void) { int result; unsigned int *p = (unsigned int*)0x1C17; EZDSP5535_LED_init(); EZDSP5535_XF_toggle(); EZDSP5535_init( ); *p = 0x0F3F; printf("CSL GPIO Input Pin Test!\n\n"); /* To test GPIO channel (pin) as an input channel in interrupt mode */ result = gpio_input_int_test(); if(CSL_TEST_PASSED == result) { printf("\nCSL GPIO Input Pin Test Passed!!\n"); } else { printf("\nCSL GPIO Input Pin Test Failed!!\n"); PaSs_StAtE = 0x0000; } PaSs = PaSs_StAtE; while(1){} }//ENDMAIN int gpio_input_int_test(void) { CSL_Status status; CSL_GpioPinConfig config; /* Pin muxing for GPIO 11 Pin */ CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP1MODE, MODE2); /* Disable CPU interrupt */ IRQ_globalDisable(); /* Clear any pending interrupts */ IRQ_clearAll(); /* Disable all the interrupts */ IRQ_disableAll(); /* Initialize Interrupt Vector table */ IRQ_setVecs((Uint32)(&VECSTART)); /* Open GPIO module */ hGpio = GPIO_open(&GpioObj,&status); if((NULL == hGpio) || (CSL_SOK != status)) { printf("GPIO_open failed\n"); return(CSL_TEST_FAILED); } else { printf("GPIO_open Successful\n"); } /* Reset the GPIO module */ GPIO_reset(hGpio); //----------------------GPIO11 INTERRUPT------------------------ /** test GPIO_config API to make PIN11 as i/p */ config.pinNum = CSL_GPIO_PIN11; config.direction = CSL_GPIO_DIR_INPUT; config.trigger = CSL_GPIO_TRIG_RISING_EDGE; status = GPIO_configBit(hGpio,&config); if(CSL_SOK != status) { printf("test failed - GPIO_configBit\n"); return(CSL_TEST_FAILED); } else { printf("GPIO PIN11 is configured as Input Pin\n"); } /* Enable GPIO interrupts */ status = GPIO_enableInt(hGpio,CSL_GPIO_PIN11); if(CSL_SOK != status) { printf("test failed- GPIO_enableInt\n"); return(CSL_TEST_FAILED); } //----------------------GPIO10 INTERRUPT------------------------ config.pinNum = CSL_GPIO_PIN10; config.direction = CSL_GPIO_DIR_INPUT; config.trigger = CSL_GPIO_TRIG_RISING_EDGE; status = GPIO_configBit(hGpio,&config); /* Enable GPIO interrupts */ status = GPIO_enableInt(hGpio,CSL_GPIO_PIN10); /* Clear any pending Interrupt */ IRQ_clear(GPIO_EVENT); IRQ_plug(GPIO_EVENT,&gpioISR); /* Enabling Interrupt */ IRQ_enable(GPIO_EVENT); IRQ_globalEnable(); printf("GPIO ISR is called\n"); if(readVal == 1) { printf("Reading Value from GPIO Pin11 is successful\n"); } else { printf("Reading Value from GPIO Pin11 is Failed\n"); PaSs_StAtE = 0x0000; } return(CSL_TEST_PASSED); } interrupt void gpioISR(void) { unsigned int *input_val = (unsigned int*)0x1C08; if(input_val[0] & 0x0800) pin_int = 11; if(input_val[0] & 0x0400) pin_int = 10; /* Clear GPIO Interrupt Flag Register */ GPIO_clearInt(hGpio,CSL_GPIO_PIN10); GPIO_clearInt(hGpio,CSL_GPIO_PIN11); oled_display(); } void oled_display(void) { Int16 i=0; /* Initialize OLED display */ EZDSP5535_OSD9616_init( ); EZDSP5535_OSD9616_send(0x00,0x2e); // Deactivate Scrolling /*-------------------PAGE 0--------------------*/ /* Fill page 0 */ EZDSP5535_OSD9616_send(0x00,0x00); // Set low column address EZDSP5535_OSD9616_send(0x00,0x10); // Set high column address EZDSP5535_OSD9616_send(0x00,0xb0+0); // Set page for page 0 to page 5 for(i=0;i<128;i++) { EZDSP5535_OSD9616_send(0x40,0x00); } /* Write to page 0 */ EZDSP5535_OSD9616_send(0x00,0x00); // Set low column address EZDSP5535_OSD9616_send(0x00,0x10); // Set high column address EZDSP5535_OSD9616_send(0x00,0xb0+0); // Set page for page 0 to page 5 for(i=0;i<50;i++) { EZDSP5535_OSD9616_send(0x40,0x00); // Spaces } if(pin_int == 11) { /*Display the VALUE*/ EZDSP5535_OSD9616_printLetter(0x31,0x49,0x49,0x2F); // 5 EZDSP5535_OSD9616_printLetter(0xE0,0x60,0x00,0x00); // , EZDSP5535_OSD9616_printLetter(0x36,0x49,0x49,0x22); // 3 printf("GPIO11\n"); } if (pin_int == 10) { /*Display the VALUE*/ EZDSP5535_OSD9616_printLetter(0xFF,0xFF,0xFF,0xFF); // 5 EZDSP5535_OSD9616_printLetter(0xE0,0x60,0x00,0x00); // , EZDSP5535_OSD9616_printLetter(0xFF,0xFF,0xFF,0xFF); // 3 printf("GPIO10\n"); } else { EZDSP5535_OSD9616_printLetter(0x00,0x00,0x00,0x00); // 5 EZDSP5535_OSD9616_printLetter(0x00,0x00,0x00,0x00); // , EZDSP5535_OSD9616_printLetter(0x00,0x00,0x00,0x00); // 3 printf("NAN\n"); } }//END_OLEDTEST