Hi guys,
I've been playing with Joep's i2c lib in order to migrate one of my DC motor
controller board (and I migrate everything under jallib). During this, we
talked about a i2C hardware slave ISR we could provide. I wrote two libs and
one sample (test) yesterday, and I'd like to have your feedback on it
Description:
- i2c_hw_slave.jal: common procedures like, init, read and write
- i2c_hw_slave_isr.jal: ISR, requires 6 callbacks to be defined
- test_i2c_hw_slave_echo.jal (and 16f88_i2c_hw_slave_echo.jal): a simple
slave, showing how to implement ISR's callbacks. It just echo a char + 1
(receice "a", send "b")
Just some thoughts (some would require feeback):
1. I've written two libs: i2c_hw_slave.jal and i2c_hw_slave_isr.jal. Only
i2c_hw_slave_isr.jal (the ISR) is required by client code. I could have merge
them, but I thought it might be useful to keep the init/read/write functions
apart from ISR, for other purpose (like implementing a i2c slave, but not
using states). What's your point ?
2. In i2c_hw_slave.jal, the init procedure (i2c_hw_slave_init) enables
interrupts (global, peripherals and i2c). While this is required by ISR, I
really wonder if it's a good idea for a lib to enable interrupts while user
did not require it. Of course, when using an ISR, user know (should)
interrupts will be enabled. Maybe I could enable them in ISR. Your point ?
3. In the ISR, once a state is detected, the corresponding procedure is
called, then the callback. Ex:
- state 5 is detected
- i2c_hw_slave_proceed_state_(5) is called
- i2c_hw_slave_on_master_hangsup(), the corresponding user's callback, is
called
I could have make the corresponding callback directly called (state 5 =>
i2c_hw_slave_on_master_hangsup) but it appears there is some small but
important logic users shouldn't care about, but still needs to be implemented
(ex: for state 5, needs CKP = 1, for state 1, *must* read buffer, ...)
As an example, I've migrated my i2c sort-of echo sample to jallib. I've
written a test, and you can give a try to the ready-to-compile
16f88_i2c_hw_slave_echo.jal.
Joep, you were talking about using a buffer. As I said (and thought, but
correct me if I'm wrong), it's a higher level than that. Maybe you could
implement this layer on top on this one.
Cheers,
Seb
--
Sébastien LELONG
http://www.sirloon.net
http://sirbot.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---