]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - embedded/app/usbcan/can/can.h
skeleton of ul_usb1-can module (doesn't work yet)
[lincan.git] / embedded / app / usbcan / can / can.h
diff --git a/embedded/app/usbcan/can/can.h b/embedded/app/usbcan/can/can.h
new file mode 100644 (file)
index 0000000..38c68dd
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef        SJA1000_CAN_H
+#define SJA1000_CAN_H
+
+#include <stdio.h>
+#include <string.h>
+#include <cpu_def.h>
+#include <system_def.h>
+#include <lt_timer.h>
+#include <local_config.h>
+#include <usb/usbdebug.h>
+#include <usb/usb.h>
+#include <usb/lpc.h>
+#include <usb/usb_srq.h>
+#include <mem_loc.h>
+#include <hal_machperiph.h>
+
+
+#include "main.h"
+#include "sja1000p.h"
+/* can.h
+ * Header file for the Linux CAN-bus driver.
+ * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
+ * Rewritten for new CAN queues by Pavel Pisa - OCERA team member
+ * email:pisa@cmp.felk.cvut.cz
+ * This software is released under the GPL-License.
+ * Version lincan-0.3  17 Jun 2004
+ */
+
+ /*
+               NOP count for synchronizing with peripheral (SJA1000)
+ */
+ #define SJA1000_CLK (24000000)        /* XTAL frequency */
+ #define SJA1000_PRESC (2)     /* embedded prescaler */
+ #define SJA1000_CCLK (SJA1000_CLK/SJA1000_PRESC)      /* SJA core frequency */
+ #define SJA1000_SCLK (PCLK/SJA1000_CCLK)      /* Clock count to synchronize with LPC */
+
+       volatile int slowdown;
+
+/**
+ * struct can_baudparams_t - datatype for calling CONF_BAUDPARAMS IOCTL
+ * @flags: reserved for additional flags for chip configuration, should be written -1 or 0
+ * @baudrate: baud rate in Hz
+ * @sjw: synchronization jump width (0-3) prescaled clock cycles
+ * @sampl_pt: sample point in % (0-100) sets (TSEG1+1)/(TSEG1+TSEG2+2) ratio
+ *
+ * The structure is used to configure new set of parameters into CAN controller chip.
+ * If default value of some field should be preserved, fill field by value -1.
+ */
+struct can_baudparams_t {
+       long flags;
+       long baudrate;
+       long sjw;
+       long sample_pt;
+};
+
+extern int can_init();
+extern int can_autobaud(int tries);
+extern int can_read(uint8_t address,uint8_t *data);
+extern int can_write(uint8_t address,uint8_t *data);
+
+extern int can_set_mask(int dual_mask,int count,uint8_t *mask,uint8_t *accept);
+
+extern int can_poll();
+extern int can_transmit_direct(uint8_t *data);
+//int can_transmit(char ext_header,char rtr,int mask_size,uint8_t *mask,int numbytes,uint8_t *data);
+extern int can_transmit(int ext_header,int rtr,uint8_t *mask,int numbytes,uint8_t *data);
+//int can_receive(uint8_t *data);
+extern int can_receive(uint8_t len,uint8_t *data);
+
+#endif /* SJA1000_CAN_H */