[Soekris] Interrupt from GPIO

Antoine Zen-Ruffinen antoine.zen at gmail.com
Fri Dec 14 09:17:03 UTC 2007


Hi folk,

I'm trying to have some interrupt from the GPIO from my net4801. After
looking at the PC87366's datasheet, I seen that some of the pins of
the GPIO are not interrupt enabled, a few are. So I tried to get an
interrupt from the GPIO8 (soekris name) witch is GPIO04 on the
PC87366. I configured some register in order to have the interrupt on
that pin. But when I am toggling the input level on that pin, nothing
append. I think I maybe forgot something.

Some one has already do such thing ? If yes, does he have some code
that I can take as template ?

Here is my PC87366 initialization code, if you want to have a look at
it. (Note that is not a linux code, but code for eCos RTOS, but I
thing you can understand it. HAL_WRITE_UINT8 is equivalent as outb()
and so one)

Tank's

Antoine


#define 	INDEX_REG		0x2E
#define 	DATA_REG		0x2F

#define 	LDR_INDEX		0x07
#define 	SIO_ID_INDEX 	0x20
#define		BASE_ADDR_MSB_INDEX 0x60
#define		BASE_ADDR_LSB_INDEX 0x61
#define 	INT_NUM_INDEX	0x70
#define		INT_TYPE_INDEX	0x71
#define		LDC_INDEX		0x30
#define		GPIO_PSR_INDEX  0xF0
#define		GPIO_PCR_INDEX  0xF1
#define		GPIO_PERR_INDEX 0xF2

#define		GPIO_LDR_VALUE	0x07
#define		PC87366_ID		0xE9

        /* GPIO base address */
        int gpioBaseAddr = 0;
        unsigned char sioId;
	int temp = 0;

	
	//Read SIO ID
	HAL_WRITE_UINT8(INDEX_REG, SIO_ID_INDEX);//Set index for SIO ID
	HAL_READ_UINT8(DATA_REG, sioId);
	
	printf("Super IO id is %X\n", sioId);
	if( sioId != PC87366_ID ) {
		printf("Bad device found !");
		return;
	}
	
	//switch to GPIO function bloc LDN
	HAL_WRITE_UINT8(INDEX_REG, LDR_INDEX);
	HAL_WRITE_UINT8(DATA_REG, GPIO_LDR_VALUE);
	
	//Write Interrupt number
	if(irq > 0 && irq <= 15) {
		HAL_WRITE_UINT8(INDEX_REG, INT_NUM_INDEX);
		HAL_WRITE_UINT8(DATA_REG, 0x10 | irq);
		printf("GPIO is interrupt %d.\n", irq);
		
		HAL_WRITE_UINT8(INDEX_REG, INT_TYPE_INDEX);
		HAL_WRITE_UINT8(DATA_REG, 0x00);
	}
	
	//Read GPIO port base address
	HAL_WRITE_UINT8(INDEX_REG, BASE_ADDR_MSB_INDEX);
	HAL_READ_UINT8(DATA_REG, temp);
	gpioBaseAddr = temp << 8;
	HAL_WRITE_UINT8(INDEX_REG, BASE_ADDR_LSB_INDEX);
	HAL_READ_UINT8(DATA_REG, temp);
	gpioBaseAddr |= temp;
	
	printf("GPIO ports base adress is 0x%04X\n", gpioBaseAddr);

  // Set GPIO04 as an input (without pull-up)
  //Select pin 04
  HAL_WRITE_UINT8(INDEX_REG, GPIO_PSR_INDEX);
  HAL_WRITE_UINT8(DATA_REG, 0x04 );
  //Set as a input with no pull-up, rising edge event, no debounce
  HAL_WRITE_UINT8(INDEX_REG, GPIO_PCR_INDEX);
  HAL_WRITE_UINT8(DATA_REG, 0x20 );
  //Enalbe interrupt on GPIO04
  HAL_WRITE_UINT8(INDEX_REG, GPIO_PERR_INDEX);
  HAL_WRITE_UINT8(DATA_REG, 0x01 );
  HAL_WRITE_UINT8((gpioBaseAddr + OFFSET_GPEVEN0), 0x10);


More information about the Soekris-tech mailing list