void prepareTouchScreen() {
ADC_Init(LPC_ADC, 400000);
/* Configure X1: */LPC_IOCON ->P0_24 = PIN_GPIO; /* X1 is a GPIO pin */
LPC_GPIO0 ->DIR |= (1 << 24); /* it's output */
LPC_GPIO0 ->SET = (1 << 24); /* and is set high */
/* Configure Y1: */LPC_IOCON ->P0_23 = PIN_GPIO; /* Y1 is a GPIO pin */
LPC_GPIO0 ->DIR |= (1 << 23); /* it's output */
LPC_GPIO0 ->SET = (1 << 23); /* and is set high */
/* Configure X2: */LPC_IOCON ->P0_22 = PIN_OD; /* simulated open drain (high impedance) mode */
LPC_GPIO0 ->DIR |= (1 << 22); /* this pin is always output */
LPC_GPIO0 ->SET = (1 << 22); /* and is set high (not sinking current) */
/* Configure Y2: */LPC_IOCON ->P0_21 = PIN_OD; /* simulated open drain (high impedance) mode */
LPC_GPIO0 ->DIR |= (1 << 21); /* this pin is always output */
LPC_GPIO0 ->SET = (1 << 21); /* and is set high (not sinking current) */
LOG("Touch Screen Prepared");
} |
inline uint16_t startTouchscreenADC(uint8_t aDirection) {
LOG(__PRETTY_FUNCTION__);
/* Prepare pins: */
if (aDirection) {
LPC_IOCON ->P0_24 = PIN_ADC; /* X1 = ADC */
LPC_IOCON ->P0_23 = PIN_GPIO; /* Y1 = GPIO pin */
LPC_GPIO0 ->CLR = (1 << 22); /* set X2 low (now sinking current) */
LPC_GPIO0 ->SET = (1 << 21); /* set Y2 high (now high impedance) */
LOG("direction = 1");
} else {
LPC_IOCON ->P0_24 = PIN_GPIO; /* X1 = GPIO pin */
LPC_IOCON ->P0_23 = PIN_ADC; /* Y1 = ADC */
LPC_GPIO0 ->SET = (1 << 22); /* set X2 high (now high impedance) */
LPC_GPIO0 ->CLR = (1 << 21); /* set Y2 low (now sinking current) */
LOG("direction = 0");
}
ADC_ChannelCmd(LPC_ADC, 1 - aDirection, DISABLE);
ADC_ChannelCmd(LPC_ADC, aDirection, ENABLE);
LOG("direction changed");
LPC_ADC ->INTEN = (LPC_ADC ->INTEN & ~0x03) | (1 << aDirection); /* enable interrupt for this direction */
LPC_ADC->CR = ADC_CR_START_MODE_SEL(ADC_CR_START_NOW) | ADC_CR_PDN | ADC_CR_CH_SEL(aDirection);
LOG("finished conversion");
return (ADC_DR_RESULT(LPC_ADC->DR[aDirection]));
}
|
prepareTouchScreen();
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority(ADC_IRQn, ((0x01<<3)|0x01));
LPC_ADC->INTEN = 0; /* disable ADC interrupts */
NVIC_ClearPendingIRQ(ADC_IRQn); /* clear ADC_IRQ pending bit in the NVIC */
NVIC_EnableIRQ(ADC_IRQn); /* enable ADC_IRQ in the NVIC */
startTouchscreenADC(0);
while(1){
}
Finally my ADC handler is:
I am expecting to see: LOG("Handler accessed"); If I touch the touchscreen and the Handler is called. What I do see is on my terminal is: Quote: Touch Screen Prepared startTouchscreenADC direction = 0 direction changed finished conversion Can anyone see why Im not getting anything back when I touch the touchscreen? Im not sure why its not going into the handler. Im trying to setup JTAG debugging now to see if I can get anything but any help would be greatly appreciated. Alex |