Hi,
I’m getting an invalid use of void expression error.
if(*edge_capture_ptr == 1) {
handle_interrupt(&edge_capture_ptr);
*edge_capture_ptr = 0;
}
Hi,
I’m getting an invalid use of void expression error.
if(*edge_capture_ptr == 1) {
handle_interrupt(&edge_capture_ptr);
*edge_capture_ptr = 0;
}
That error indicates that you have a void function that returns a value. i.e.
void myFunction() {
int myValue = 1;
return myValue;
}
You either get rid of the return statement or declare the function with a return value like this:
int myFunction() { }
If that doesn’t resolve your issue, you will need to provide more code for a better diagnosis.
this is method
void handle_interrupt(int *switch_edgecaptue_value)
{
switch(switch_edgecaptue_value)
{
case 0:
//setting switch timer based on position set
switch_timer =9000000;
printf("sw_ display_hexa_value %d\n",switch_edgecaptue_value);
break;
case 1:
//setting switch timer based on position set
switch_timer = 600000;
printf("sw_ display_hexa_value %d\n",switch_edgecaptue_value);
break;
case 2:
//setting switch timer based on position set
switch_timer = 200000;
printf("sw_ display_hexa_value %d\n",switch_edgecaptue_value);
break;
case 4:
//setting switch timer based on position set
switch_timer = 10000;
printf("sw_ display_hexa_value %d\n",switch_edgecaptue_value);
break;
case 8:
//setting switch timer based on position set
switch_timer = 1000;
printf("sw_ display_hexa_value %d\n",switch_edgecaptue_value);
break;
case 16:
//setting switch timer based on position set
switch_timer = 900;
printf("sw_ display_hexa_value %d\n",switch_edgecaptue_value);
break;
default:
printf("default button is %d\n",switch_edgecaptue_value);
switch_timer = 2500000;
break;
}
}
void init_pio()
{
/* Recast the edge_capture pointer to match the alt_irq_register()
function* prototype. */
void* edge_capture_ptr = (void*) &edge_capture;
/* Enable first four interrupts. */
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(KEY0_BASE, 0x1);
/* Reset the edge capture register. */
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(SWITCH_0_BASE, 0x1F);
//start of logic
start:
display_hexa_value = 1;
for(i=0;i<16;i++)
{
//Display display_hexa_value on Red LED
IOWR_ALTERA_AVALON_PIO_DATA(LEDS_BASE, display_hexa_value);
//printf("display_hexa_value is %d\t",display_hexa_value);
//shift by 1
display_hexa_value = display_hexa_value << 1;
//Delay
usleep(switch_timer);
/* Register the interrupt handler. */
alt_irq_register( KEY0_IRQ, edge_capture_ptr, handle_button_interrupts );
/* Register the interrupt handler. */
alt_irq_register( SWITCH_0_IRQ, edge_capture_ptr, handle_button_interrupts_switches );
//checking if display_hexa_value is resetted to 1 in above registers
// call interrupt routine
if(*edge_capture_ptr == 1) {
handle_interrupt(*edge_capture_ptr)
*edge_capture_ptr = 0;
}
if (display_hexa_value == 0x0001)
{
i = 0;
}
}
for(j=0;j<16;j++)
{
//Display display_hexa_value on Red LED
IOWR_ALTERA_AVALON_PIO_DATA(LEDS_BASE, display_hexa_value);
//printf("display_hexa_value is %d\t",display_hexa_value);
//shift by 1
display_hexa_value = display_hexa_value >> 1;
//Delay
usleep(switch_timer);
/* Register the interrupt handler. */
alt_irq_register( KEY0_IRQ, edge_capture_ptr, handle_button_interrupts );
/* Register the interrupt handler. */
alt_irq_register( SWITCH_0_IRQ, edge_capture_ptr, handle_button_interrupts_switches );
//checking if display_hexa_value is resetted to 1 in above registers
// call interrupt routine
if(*edge_capture_ptr == 1) {
handle_interrupt(*edge_capture_ptr);
*edge_capture_ptr = 0;
}
if (display_hexa_value == 0x0001)
{
goto start;
}
}
/*
for(i=0;i<32;i++)
{
if(i<16)
{
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE, display_hexa_value);
//printf("display_hexa_value is %d\n",display_hexa_value);
display_hexa_value = display_hexa_value << 1;
usleep(switch_timer);
alt_irq_register( KEY_IRQ, edge_capture_ptr, handle_button_interrupts );
alt_irq_register( SWITCHES_IRQ, edge_capture_ptr, handle_button_interrupts_switches );
if(display_hexa_value == 1)
{
i=0;
}
}
if(i>=16 && i<32)
{
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE, display_hexa_value);
//printf("display_hexa_value is %d\n",display_hexa_value);
display_hexa_value = display_hexa_value >> 1;
usleep(switch_timer);
alt_irq_register( KEY_IRQ, edge_capture_ptr, handle_button_interrupts );
alt_irq_register( SWITCHES_IRQ, edge_capture_ptr, handle_button_interrupts_switches );
if(display_hexa_value == 1)
{
i=0;
}
}
display_hexa_value = 1;
}
*/
//display_hexa_value = 1;
}
Im Facing an issues in
/ call interrupt routine
if(*edge_capture_ptr == 1) {
handle_interrupt(*edge_capture_ptr)
*edge_capture_ptr = 0;
}
That’s because you’ve declared edge_capture_ptr
as void *
.
void* edge_capture_ptr = (void*) &edge_capture;
You can’t test or set a void *
because the compiler has no idea of the size of the data you want to test or set. In order to use *edge_capture_ptr in an if test or as the left side of a assignment operation, you need to specify a non-zero size. For example:
uint8_t* edge_capture_ptr = (uint8_t*) &edge_capture;
That’s just an example, you need to set it to the size that it actually is, not arbitrarily one 8-bit byte, of course.