can--installing can interrupt handler

Gedare Bloom gedare at rtems.org
Mon Apr 30 17:28:46 UTC 2012


Hi,

I can't say much but it looks like you are checking for success by saying
if (!status) {
  // fatal error
}

which won't work as you expect because RTEMS_SUCCESSFUL is 0. You might try
if (status) {
 // fatal error
}
or better yet
if(status != RTEMS_SUCCESSFUL) {
 // fatal error
}

Good luck
-Gedare

On Mon, Apr 30, 2012 at 11:27 AM, zhoupeng <zpeng563 at 126.com> wrote:
> 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;
> }
>
>
>
> ________________________________
> 网易Lofter,专注兴趣,分享创作!
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
>




More information about the users mailing list