On Apr 19, 11:35 am, Joep Suijs <[email protected]> wrote:
>
> I'd say this 30 lines of code are the init function of your library,
> and this init function might take a few parameters or there are some
> constants you need to define before you include the can libarary. But
> I expect this is too simple and you will explain in more detail why ;)
>
OK, here are more details. I count 42 bytes of parameters would be
required in an all-purpose init routine. By the way, I am using this
ECAN module in the 'legacy' mode. If/when I implement some of the
'enhanced' features, it will only make things more complicated.
Here is the code in question. My running commentary is left margin.
'the JAL code' is indented (I hope)
JSG says not allowed to touch specific pins?
pin_B2 = high -- set CANTX high for recessive level
pin_B2_direction = output
pin_B3_direction = input
puts device in configuration mode
can_reset()
this one would be really tough to make friendly interface for. sets a
bunch of parameters about the canbus. baudrate is just one item. 3
bytes of parameters.
can_set_config(4, 0x9E, 3)
CAN module I/O control. 1 byte of parameter.
CIOCON = 0x20; -- TXCAN, high when recessive
2 bytes of parameters to set up receivers
RXB0CON = 0x04 -- rollover/ double-buffer
RXB1CON = 0x00 -- all valid frames go to buffer #1.
filter: RXB0 will match all msgs by default. note this would take 12
bytes of parameters
can_set_rxb0_mask(0,0,0,0)
can_set_rxb0_filter0(0xff, 0xff, 0xff, 0xff)
can_set_rxb0_filter1(0xff, 0xff, 0xff, 0xff)
disable RXB1 filter since we're rolling over. 20 bytes of parameters.
can_set_rxb1_mask(0xff,0xff,0xff,0xff)
can_set_rxb1_filter2(0xff, 0xff, 0xff, 0xff)
can_set_rxb1_filter3(0xff, 0xff, 0xff, 0xff)
can_set_rxb1_filter4(0xff, 0xff, 0xff, 0xff)
can_set_rxb1_filter5(0xff, 0xff, 0xff, 0xff)
set up transmitter. 3 bytes of parameters
TXB0CON = 0;
TXB1CON = 0;
TXB2CON = 0;
final mode. could be 'normal' or 'listen-only'. 1 byte
CANCON = 0; -- normal mode
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.