//#include "./can/ul_usb1.h"
-//#include "./can/setup.h"
+#include "./can/setup.h"
#include "./usb/usb_defs.h"
#include "./usb/usb_vend.h"
-// DEBUG CAN
+
#include "can/lpc17xx_can.h"
-// DEBUG CAN - end
#define MASK_EP1RX 0x01
#define MASK_EP1TX 0x02
/***********************************************************************
* global variables
***********************************************************************/
-volatile uint32_t cnt;
usb_device_t usb_device;
int chipnr,bd;
int i,size,m=0;
- cnt=0;
-
CANMSG("Starting USBCAN module firmware...\n");
// volatile int i=0;
sys_err();
}
-// !!! DEBUG - transmitting and receiving CAN messages with usage of queue system from LinCAN - first version!
-
//***********************************************************************
// * CAN device initialization - device side (adapted from LinCAN setup.c)
// ***********************************************************************
- // DEBUG
- //can_init(); // only for successful compiling (defined in can_lpcbusemu.c)
+// useless with lpc17xx (defined in can_lpcbusemu.c)
+// can_init();
DEBUGMSG("Initiating CAN device initialization\n");
// DEBUG
- //ul_usb1_register(candev->hwspecops); // only for successful compiling (defined in ul_usb1.c)
- // register for another board
+ //ul_usb1_register(candev->hwspecops); //(defined in ul_usb1.c)
+ // register for another board:
can_lmc1_register(candev->hwspecops);
chip->flags |= CHIP_ATTACHED;
-// Interrupts from chip are served in main cycle
-// if(can_chip_setup_irq(chip)<0) {
-// CANMSG("Error to setup chip IRQ\n");
-// sys_err();
-// }
+ // used with lpc17xx:
+ if(can_chip_setup_irq(chip)<0) {
+ CANMSG("Error to setup chip IRQ\n");
+ sys_err();
+ }
+
}
if (candev->flags & CANDEV_PROGRAMMABLE_IRQ)
usb_check_events(&usb_device);
usb_control_response(&usb_device);
-// DEBUG
+// useless with lpc17xx:
// 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
slot->msg=canmsg;
canque_put_inslot(qends, qedge, slot);
- //CAN_send(&canmsg);
+
}
else
canque_abort_inslot(qends,qedge,slot);
}
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);