]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - embedded/app/usbcan/main.c
embedded: reintroduce missing emulated bus initialization for UL_USB1 board.
[lincan.git] / embedded / app / usbcan / main.c
index 6a5b3d4aa494dd2c1f818350979e9361c57dc17a..14fbe288e98c5eb5bf7b1b3c841e744a49dcb951 100644 (file)
@@ -67,8 +67,8 @@
 #include "./usb/usb_defs.h"
 #include "./usb/usb_vend.h"
 
 #include "./usb/usb_defs.h"
 #include "./usb/usb_vend.h"
 
-
-#include "can/lpc17xx_can.h"
+extern int can_lmc1_register(struct hwspecops_t *hwspecops);
+extern int ul_usb1_register(struct hwspecops_t *hwspecops);
 
 #define MASK_EP1RX  0x01
 #define MASK_EP1TX  0x02
 
 #define MASK_EP1RX  0x01
 #define MASK_EP1TX  0x02
@@ -156,19 +156,6 @@ int sys_err(){
   }
 }
 
   }
 }
 
-/***********************************************************************
- * Microsecond delay routine
- ***********************************************************************/
-/*
-void udelay(long time)
-{
-  volatile long ticks=(time * CCLK) / 2000000;
-  do{
-    ticks--;
-  } while(ticks>0);
-}
-*/
-
 /***********************************************************************
  * Routine for visible LED blinking (on USB transmission)
  ***********************************************************************/
 /***********************************************************************
  * Routine for visible LED blinking (on USB transmission)
  ***********************************************************************/
@@ -227,14 +214,10 @@ int main(void)
        }
 
 
        }
 
 
-       //***********************************************************************
+       // ***********************************************************************
        // * CAN device initialization - device side (adapted from LinCAN setup.c)
        // ***********************************************************************
 
        // * CAN device initialization - device side (adapted from LinCAN setup.c)
        // ***********************************************************************
 
-//     useless with lpc17xx (defined in can_lpcbusemu.c)
-//     can_init();
-
-
        DEBUGMSG("Initiating CAN device initialization\n");
        baudrate[0]=1000;
 
        DEBUGMSG("Initiating CAN device initialization\n");
        baudrate[0]=1000;
 
@@ -263,12 +246,12 @@ int main(void)
 
        
 
 
        
 
-       // DEBUG
-       //ul_usb1_register(candev->hwspecops);  //(defined in ul_usb1.c)
-       // register for another board:
+#ifdef CONFIG_OC_LINCAN_CARD_ul_usb1
+       ul_usb1_register(candev->hwspecops);
+#endif
+#ifdef CONFIG_OC_LINCAN_CARD_can_lmc1
        can_lmc1_register(candev->hwspecops);
        can_lmc1_register(candev->hwspecops);
-
-       
+#endif
 
        bd=baudrate[0];
        if (candev->hwspecops->init_hw_data(candev)){
 
        bd=baudrate[0];
        if (candev->hwspecops->init_hw_data(candev)){
@@ -301,13 +284,17 @@ int main(void)
        }
 
 
        }
 
 
-       if (candev->hwspecops->request_io(candev))
+       if (candev->hwspecops->request_io(candev)) {
+               CANMSG("Error to request IO\n");
                sys_err();
                sys_err();
+       }
        candev->flags|=CANDEV_IO_RESERVED;
 
 
        candev->flags|=CANDEV_IO_RESERVED;
 
 
-       if (candev->hwspecops->reset(candev))
+       if (candev->hwspecops->reset(candev)) {
+               CANMSG("Error to reset chip\n");
                sys_err();
                sys_err();
+       }
 
 
        for(chipnr=0; chipnr<candev->nr_all_chips; chipnr++) {
 
 
        for(chipnr=0; chipnr<candev->nr_all_chips; chipnr++) {
@@ -429,9 +416,11 @@ int main(void)
                usb_check_events(&usb_device);
                usb_control_response(&usb_device);
 
                usb_check_events(&usb_device);
                usb_control_response(&usb_device);
 
-// useless with lpc17xx:
-//             if (!(IO0PIN&P0_SJA1000_INT_PIN)) //INT PIN is inverted
-//                     chip->chipspecops->irq_handler(0,chip);
+#ifdef CONFIG_OC_LINCAN_CARD_ul_usb1
+               /* polled IRQ mode for ul_usb1 board*/
+               if (!(IO0PIN&P0_SJA1000_INT_PIN)) /* INT PIN is inverted */
+                       chip->chipspecops->irq_handler(0,chip);
+#endif
 
                if (usb_device.ep_events & MASK_EP1RX) {  //EP1RX - data waiting to receive
                        
 
                if (usb_device.ep_events & MASK_EP1RX) {  //EP1RX - data waiting to receive