-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino Wrapper - Need a little more clarity on usage #2
Comments
Cool!
Yep!
No. The data callback is called when there is data available to the application. The first function does not only initialize twi, it also takes over
It's C, so arrays and lengths are always zero-based.
That's incorrect. The idle_callback is called frequently when sleep is
Yes it's a bool, but there is no sense in using a bool, because an
When sleep is on, the cpu uses much less energy, but it may miss a STOP
I am not familiar with Arduino indeed, and I am not planning to change |
Thanks for writing me back! You've answered a lot! For now, what I have working is buggy at best. I still really don't understand the *idle_callback usage. When would I use it? How is it used? Any simple example? Again, touching back on *data_callback: -if data is being requested(master requests data/ master reads), the program must then define the following in the code: Maybe you have a simple example of data_callback as well? something the sends and receives 2 bytes. This is funny behavior, but currently I can detect the detect the device on the bus, but it hangs when I attempt to read data 1 byte of data.If I unplug the ATTiny and plug it back it back in during a read request, it will return the byte. The returned byte is either 0 or the correct value. btw, I'm studying usitwislave.c around line 242 //process read request from master Thanks! |
I am using to reset the watchdog and also make led blink, so you can see
You might want to have a look here: http://github.com/eriksl/attiny861_1 Also have all conditions been met to be able to communicate i2c at all:
|
regarding hardware setup: Using external pull-ups and that are correctly sized and I'm running at 8mhz internal, but calibrated. I'm reading through your code main.c here: static void process_input(uint8_t if_input_buffer_length, const uint8_t *if_input_buffer, If I have any questions, I'll post back. Thanks! |
Okay. The clock doesn't need to be calibrated though, it's not even
And what is exactly your question? |
Thanks for the quick reply. I'm actually reading your code now. When I'm finished reading, I'll post my questions(s). Thanks! |
Hey Erik,
I'm in the process of writing a wrapper for your updated library for Arduino and with the ATtiny Tiny Cores. Anyway, I've got something primitive actually working with your library, but I'm looking for more clarification on implementation so I can better experiment and document the wrapper code I'm making. From what I've incovered, your code seems much simpler in terms of implementation which I like.
Regarding clarification:
For instance:
calling usi_twi_slave(I2C address, use_sleep,*data_callback, *idle_callback);
this Initializes the TWI. That seems like that's the only thing needed to get this code running.
Usage of data_callback((uint8_t input_buffer_length, const uint8_t *input_buffer,
uint8_t *output_buffer_length, uint8_t *output_buffer);)
Things I want to clarify:
dataOut[2] = {b1,b2};
output_buffer=dataOut;
What happens when sleep is enabled and when it's disabled? Other effects of the I2C.
I have only used 0 in my testing.
Just in case, If you're not familiar with arduino..There are two main blocks that are needed so it compiles correctly.
void setup(){}//This is where you initialize things. Only runs once
and
void loop(){} //This code loops
--So Implementing your code in arduino would look something like this:--
void setup()
{
usi_twi_slave(a,b,callback,idle);
}
void loop()
{
//do nothing or do something
}
static void twi_callback(byte input_buffer_length,
const byte *input_buffer,
byte *output_buffer_length,
byte *output_buffer)
{
//do stuff here prepare data to send out or process incoming data.
}
void idle_callback()
{
//idle task?
}
Thanks for all your help and I'm happy to further clarify my questions if needed.
The text was updated successfully, but these errors were encountered: