can--installing can interrupt handler
zhoupeng
zpeng563 at 126.com
Mon Apr 30 15:27:58 UTC 2012
hello,
These day , I work on a can device driver. When i debug this can device driver on PC104(i386) .I found my device driver can not work well. Specifically when I run a test programe with this device driver, I find this driver can't install because of "installing can interrupt handler".
who can tell how to solve this problem.Thank you!
Best wish!
zhoupeng
Some code about Interrupt:
/*
*Handle an CAN interrupt.
*/
static void
can_interrupt_handler (rtems_irq_hdl_param ignored)
{
#ifdef DEBUG_CAN
printk("\n!***********!\n");
#endif
printk("\n!###########!\n");
unsigned char buf[13]; /*beautiful*/
int intrkind;
log_flag = 1;
intrkind=read_sja(3);
if((intrkind & 0x01) == 0){/*ÖжόĎæÆ÷œÓÊÕλûÓб»ÖÃ룬ŒÈûÓвúÉúœÓÊÕÖжÏ*/
goto out;
}
Receive(buf); /*ÕâÀïÖ»ÄÜœÓÊÕÒ»Ö¡ÊýŸÝ£¬Èç¹ûœÓÊÕfifo·Ç¿Õ£¬Öжϱ£³Ö£¡ÊýŸÝÈ¡×ߺó£¬fifoÊÇ·ñ»áÇå¿ÕÈ¡×ߵIJ¿·Ö*/
// printk("int1 : %2x %2x %2x %2x %2x\n",buf[0],buf[1],buf[2],buf[3],buf[4]);
if(log_flag)
in_rd_buf(buf); //buffer this frame
out:
write_sja(1,4); //Release sja receive buffer of FIFO. if there are data in FIFO, INT signal will be set
// *(volatile unsigned long*)(MCF_MBAR + 0x20) |= 0x80000000;//clear pending bit
//clear interrupt
printk("\n!***********!\n");
}
/*
*Turn CAN interrupts on.
*/
static void
isr_on(const rtems_irq_connect_data *unused)
{
return;
}
/*
*Turn CAN interrupts off. See can_interrupt_on.
*/
static void
isr_off(const rtems_irq_connect_data *unused)
{
return;
}
/*
*Return whether CAN interrupts are on.
*/
static int
isr_is_on(const rtems_irq_connect_data *irq)
{
return BSP_irq_enabled_at_i8259s(irq->name);
}
/*
* Interrupt structure for can
*/
static rtems_irq_connect_data can_isr_data =
{
CAN_IRQ_VECTOR,
can_interrupt_handler,
0,
isr_on,
isr_off,
isr_is_on};
rtems_device_driver
CAN_initialize(rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg)
{
rtems_status_code status;
/*
* Set CAN2 BASEADDRESS AND INTERRUPT NUMBER
*/
outport_byte(BASE+0,6);
outport_byte(BASE+1,0xD4);
outport_byte(BASE+0,7);
outport_byte(BASE+1,0x00);
outport_byte(BASE+0,13);
outport_byte(BASE+1,0xC0);
/*
* DO device-specific initialization
*/
SJA_init();
status = BSP_install_rtems_irq_handler( &can_isr_data );
if( !status )
{
printk("Error installing can interrupt handler!\n");
rtems_fatal_error_occurred(status);
}
/*
* init read buffer
*/
init_rd_buf();
/*
* Register the device
*/
status = rtems_io_register_name ("/dev/CAN", major, 0);
if (status != RTEMS_SUCCESSFUL)
{
printk("Error registering CAN device!\n");
rtems_fatal_error_occurred (status);
}
printk("Device: /dev/CAN initialized.\n");
return RTEMS_SUCCESSFUL;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20120430/29d3e25a/attachment.html>
More information about the users
mailing list