]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - embedded/app/usbcan/main.c
Receiving CAN messages with usage of queue system from LinCAN - first version. Attemp...
[lincan.git] / embedded / app / usbcan / main.c
index 6053645608fc458720b3441d0ae185eb88134e61..ad7fe36db6caf5891c3f317f9a9c9d195e7097fa 100644 (file)
@@ -109,7 +109,7 @@ typedef void (*FNC)(); //function ptr
 /***********************************************************************
  * global variables
  ***********************************************************************/
-
+volatile uint32_t cnt;
 
 usb_device_t usb_device;
 
@@ -209,8 +209,9 @@ int main(void)
        int chipnr,bd;
        int i,size,m=0;
 
+       cnt=0;
+
        CANMSG("Starting USBCAN module firmware...\n");
-       
 
 //     volatile int i=0;
        bootloader_run=0;
@@ -229,7 +230,7 @@ int main(void)
                sys_err();
        }
 
-// !!! DEBUG - first version, only transmitting CAN messages with usage of queue system from LinCAN
+// !!! DEBUG - transmitting and receiving CAN messages with usage of queue system from LinCAN - first version! 
 
 
        //***********************************************************************
@@ -437,6 +438,10 @@ int main(void)
 //             if (!(IO0PIN&P0_SJA1000_INT_PIN)) //INT PIN is inverted
 //                     chip->chipspecops->irq_handler(0,chip);
 
+//             if (CAN1SR & CAN_SR_RBS)
+//                     chip->chipspecops->irq_handler(0,chip);
+
+
                if (usb_device.ep_events & MASK_EP1RX) {  //EP1RX - data waiting to receive
                        
                        if (canque_get_inslot(qends, &qedge, &slot, 0)>=0){ //Free slot obtained
@@ -502,8 +507,7 @@ int main(void)
                        }*/
                }
 
-               // DEBUG - only transmitting CAN messages, no reading (yet)
-               /*
+               
                if(usb_device.ep_events & MASK_EP1TX){ //EP1TX - data transmitted
                        if(canque_test_outslot(qends, &qedge, &slot)>=0){
                                DEBUGMSG("CAN message ready to send over usb\n");
@@ -530,13 +534,17 @@ int main(void)
                                }
                                usb_udev_write_endpoint(&eps[1],ep1_tx_buff,16);
 
+                               //printf("ID: %d\n", msgid);
+
                                canque_free_outslot(qends, qedge, slot);
                                timer_tx_off=50;                //rozsviceni diod pri vysilani
                                CLR_OUT_PIN(LED_PORT,LED1_BIT);
                                usb_device.ep_events &= ~MASK_EP1TX;
+
                        }
+                       
                }
-               */
+               
 
                //if (usb_can_send && )