<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><DIV>hello,</DIV>
<DIV>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".</DIV>
<DIV>who can tell how to solve this problem.Thank you!</DIV>
<DIV>Best wish!</DIV>
<DIV>zhoupeng</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><SPAN style="COLOR: #ff0000"><SPAN style="FONT-SIZE: 24px"><SPAN style="COLOR: #ff0000">Some code about Interrupt:</SPAN></SPAN></SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: 24px"></SPAN>/* <BR> *Handle an CAN interrupt. <BR> */<BR>static void<BR>can_interrupt_handler (rtems_irq_hdl_param ignored)<BR>{</DIV>
<DIV>#ifdef DEBUG_CAN<BR> printk("\n!***********!\n");<BR>#endif<BR> printk("\n!###########!\n");<BR> unsigned char buf[13]; /*beautiful*/<BR> int intrkind;<BR> log_flag = 1;<BR> <BR> intrkind=read_sja(3);<BR> <BR> if((intrkind & 0x01) == 0){/*ÖжόĎæÆ÷œÓÊÕλûÓб»ÖÃ룬ŒÈûÓвúÉúœÓÊÕÖжÏ*/<BR> goto out;<BR> }</DIV>
<DIV> Receive(buf); /*ÕâÀïÖ»ÄÜœÓÊÕÒ»Ö¡ÊýŸÝ£¬Èç¹ûœÓÊÕfifo·Ç¿Õ£¬Öжϱ£³Ö£¡ÊýŸÝÈ¡×ߺó£¬fifoÊÇ·ñ»áÇå¿ÕÈ¡×ߵIJ¿·Ö*/<BR>// printk("int1 : %2x %2x %2x %2x %2x\n",buf[0],buf[1],buf[2],buf[3],buf[4]);<BR> if(log_flag)<BR> in_rd_buf(buf); //buffer this frame<BR>out:<BR> write_sja(1,4); //Release sja receive buffer of FIFO. if there are data in FIFO, INT signal will be set<BR>// *(volatile unsigned long*)(MCF_MBAR + 0x20) |= 0x80000000;//clear pending bit<BR> //clear interrupt<BR> printk("\n!***********!\n");<BR>}</DIV>
<DIV>/* <BR> *Turn CAN interrupts on. <BR> */<BR>static void<BR>isr_on(const rtems_irq_connect_data *unused)<BR>{<BR> return;<BR>}</DIV>
<DIV>/* <BR> *Turn CAN interrupts off. See can_interrupt_on. <BR> */<BR>static void<BR>isr_off(const rtems_irq_connect_data *unused)<BR>{<BR> return;<BR>}</DIV>
<DIV>/* <BR> *Return whether CAN interrupts are on. <BR> */<BR>static int<BR>isr_is_on(const rtems_irq_connect_data *irq)<BR>{<BR> return BSP_irq_enabled_at_i8259s(irq->name);<BR>}</DIV>
<DIV>/*<BR> * Interrupt structure for can<BR> */<BR>static rtems_irq_connect_data can_isr_data =<BR>{<BR> CAN_IRQ_VECTOR,<BR> can_interrupt_handler,<BR> 0,<BR> isr_on,<BR> isr_off,<BR> isr_is_on};</DIV>
<DIV><BR>rtems_device_driver<BR>CAN_initialize(rtems_device_major_number major,<BR> rtems_device_minor_number minor,<BR> void *arg)<BR>{<BR> rtems_status_code status;<BR> <BR> /*<BR> * Set CAN2 BASEADDRESS AND INTERRUPT NUMBER<BR> */<BR> outport_byte(BASE+0,6);<BR> outport_byte(BASE+1,0xD4);<BR> outport_byte(BASE+0,7);<BR> outport_byte(BASE+1,0x00);<BR> outport_byte(BASE+0,13);<BR> outport_byte(BASE+1,0xC0);<BR> <BR> /*<BR> * DO device-specific initialization<BR> */<BR> SJA_init();<BR> status = BSP_install_rtems_irq_handler( &can_isr_data );<BR> if( !status )<BR> {<BR> printk("Error installing can interrupt handler!\n");<BR> rtems_fatal_error_occurred(status);<BR> }<BR> <BR> /*<BR> * init read buffer<BR> */<BR> init_rd_buf();<BR> <BR> /*<BR> * Register the device<BR> */<BR> status = rtems_io_register_name ("/dev/CAN", major, 0);<BR> if (status != RTEMS_SUCCESSFUL)<BR> {<BR> printk("Error registering CAN device!\n");<BR> rtems_fatal_error_occurred (status);<BR> }<BR> printk("Device: /dev/CAN initialized.\n");<BR> <BR> return RTEMS_SUCCESSFUL;<BR>} </DIV>
<DIV> </DIV></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"><hr/>
<a href="http://www.lofter.com" target="_blank">网易Lofter,专注兴趣,分享创作!</a>
</span></span>