]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/app/usbcan/can/can.h
skeleton of ul_usb1-can module (doesn't work yet)
[lincan.git] / embedded / app / usbcan / can / can.h
1 #ifndef SJA1000_CAN_H
2 #define SJA1000_CAN_H
3
4 #include <stdio.h>
5 #include <string.h>
6 #include <cpu_def.h>
7 #include <system_def.h>
8 #include <lt_timer.h>
9 #include <local_config.h>
10 #include <usb/usbdebug.h>
11 #include <usb/usb.h>
12 #include <usb/lpc.h>
13 #include <usb/usb_srq.h>
14 #include <mem_loc.h>
15 #include <hal_machperiph.h>
16
17
18 #include "main.h"
19 #include "sja1000p.h"
20 /* can.h
21  * Header file for the Linux CAN-bus driver.
22  * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
23  * Rewritten for new CAN queues by Pavel Pisa - OCERA team member
24  * email:pisa@cmp.felk.cvut.cz
25  * This software is released under the GPL-License.
26  * Version lincan-0.3  17 Jun 2004
27  */
28
29  /*
30                 NOP count for synchronizing with peripheral (SJA1000)
31  */
32  #define SJA1000_CLK (24000000) /* XTAL frequency */
33  #define SJA1000_PRESC (2)      /* embedded prescaler */
34  #define SJA1000_CCLK (SJA1000_CLK/SJA1000_PRESC)       /* SJA core frequency */
35  #define SJA1000_SCLK (PCLK/SJA1000_CCLK)       /* Clock count to synchronize with LPC */
36
37         volatile int slowdown;
38
39 /**
40  * struct can_baudparams_t - datatype for calling CONF_BAUDPARAMS IOCTL
41  * @flags: reserved for additional flags for chip configuration, should be written -1 or 0
42  * @baudrate: baud rate in Hz
43  * @sjw: synchronization jump width (0-3) prescaled clock cycles
44  * @sampl_pt: sample point in % (0-100) sets (TSEG1+1)/(TSEG1+TSEG2+2) ratio
45  *
46  * The structure is used to configure new set of parameters into CAN controller chip.
47  * If default value of some field should be preserved, fill field by value -1.
48  */
49 struct can_baudparams_t {
50         long flags;
51         long baudrate;
52         long sjw;
53         long sample_pt;
54 };
55
56 extern int can_init();
57 extern int can_autobaud(int tries);
58 extern int can_read(uint8_t address,uint8_t *data);
59 extern int can_write(uint8_t address,uint8_t *data);
60
61 extern int can_set_mask(int dual_mask,int count,uint8_t *mask,uint8_t *accept);
62
63 extern int can_poll();
64 extern int can_transmit_direct(uint8_t *data);
65 //int can_transmit(char ext_header,char rtr,int mask_size,uint8_t *mask,int numbytes,uint8_t *data);
66 extern int can_transmit(int ext_header,int rtr,uint8_t *mask,int numbytes,uint8_t *data);
67 //int can_receive(uint8_t *data);
68 extern int can_receive(uint8_t len,uint8_t *data);
69
70 #endif /* SJA1000_CAN_H */