#include <lpciap.h>
#include <lpciap_kvpb.h>
-#include "can/can.h"
-#include "can/sja1000p.h"
+#include "./can/can.h"
+#include "./can/sja1000p.h"
+#include "./can/main.h"
+
+#include "./can/can_sysdep.h"
+#include "./can/modparms.h"
+#include "./can/devcommon.h"
+
+#include "./can/ul_usb1.h"
+//#include "./can/setup.h"
#define MASK_EP1RX 0x01
#define MASK_EP1TX 0x02
int processlocal;
+int baudrate[MAX_TOT_CHIPS];
+struct canhardware_t canhardware;
+struct canhardware_t *hardware_p=&canhardware;
+struct canchip_t *chips_p[MAX_TOT_CHIPS];
+struct msgobj_t *objects_p[MAX_TOT_MSGOBJS];
+
+
/**
SOMETHING BAD HAPPENED
*/
/***********************************/
int main(void)
{
+ struct candevice_t *candev;
+ struct canchip_t *chip;
+ int chipnr,bd;
+
// volatile int i=0;
bootloader_run=0;
/***********************************/
SET_OUT_PIN(LED_PORT,LED_ERR);
CLR_OUT_PIN(LED_PORT,LED_GP);
- //********************
- // USB init
- memset( &usb_device, 0, sizeof( usb_device));
- usb_device.id = 1;
- usb_device.init = usb_lpc_init;
- usb_debug_set_level(DEBUG_LEVEL_NONE);
+ /// *************************
+ /// CAN device initialization
+
+ baudrate[0]=1000;
+
+ canqueue_kern_initialize();
+
+ hardware_p->nr_boards=1;
+
+ candev=(struct candevice_t *)malloc(sizeof(struct candevice_t));
+ if (candev==NULL) sys_err();
+ memset(candev, 0, sizeof(struct candevice_t));
+
+ hardware_p->candevice[0]=candev;
+ candev->candev_idx=0;
+ candev->io_addr=0;
+ candev->dev_base_addr=0;
+
+ candev->hwspecops=(struct hwspecops_t *)malloc(sizeof(struct hwspecops_t));
+ if (candev->hwspecops==NULL) sys_err();
+ memset(candev->hwspecops, 0, sizeof(struct hwspecops_t));
+
+ ul_usb1_register(candev->hwspecops);
+
+ bd=baudrate[0];
+ if (candev->hwspecops->init_hw_data(candev)) sys_err();
+ /* Alocate and initialize the chip structures */
+ for (chipnr=0; chipnr < candev->nr_all_chips; chipnr++) {
+/* if(chipnr<irqnum)
+ irqsig=irq[*irq_param_idx_p+chipnr];*/
+ if (init_chip_struct(candev, chipnr, 0, bd*1000)) sys_err();
+ }
+ if (candev->hwspecops->request_io(candev))
+ sys_err();
+ candev->flags|=CANDEV_IO_RESERVED;
+ if (candev->hwspecops->reset(candev))
+ sys_err();
+ for(chipnr=0; chipnr<candev->nr_all_chips; chipnr++) {
+ if((chip=candev->chip[chipnr])==NULL)
+ continue;
+
+ if(chip->chipspecops->attach_to_chip(chip)<0) {
+// CANMSG("Initial attach to the chip HW failed\n");
+ sys_err();
+ }
+
+ 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();
+ }*/
+ }
+
+ if (candev->flags & CANDEV_PROGRAMMABLE_IRQ)
+ if (candev->hwspecops->program_irq(candev)){
+// CANMSG("Error to program board interrupt\n");
+ sys_err();
+ }
+
+
+
+ /// ***************************************
+ /// CAN device initialization - client side
+
+ ///*********
+ /// USB init
+
+ memset( &usb_device, 0, sizeof( usb_device));
+ usb_device.id = 1;
+ usb_device.init = usb_lpc_init;
+ usb_debug_set_level(DEBUG_LEVEL_NONE);
usb_device.cntep = 3;
usb_device.ep = eps;
// usb_device.vendor_fnc=usb_loader;
- usb_init(&usb_device);
- usb_connect(&usb_device);
+ usb_init(&usb_device);
+ usb_connect(&usb_device);
can_init();
usb_can_send=1;