Closed CrasherCourse closed 11 years ago
I think we could pick a better name for waitForSPIF
. To match coding conventions, how about I2CWaitForTransmission
or something? Also, I kind of would like the buffer first.
Also, I don't think we'll ever have a situation where we send a byte without waiting for the transmission to complete. So let's move the waiting after byte transmissions to inside I2CSendByte
.
For the rest of style, can we move the waiting function to the bottom since it's not that interesting, forward declare each of the functions after the Code
banner, and fix the curly brace on I2CSendByte
's implementation?
Functionally: let's convert to using the slave's number as it's address. It will prevent a lot of pointer swapping in the PIC. After we do that, both of the global variables in I2C.h
are invalid.
Actually I named it waitForSPIF
because sending the start and stop condition will trigger the interrupt.
Meaning the function is used for more than waiting for a transmission.
Maybe someone has a better name for this or I just copy and paste the code to replace the function itself.
Technically it's "transmitting" START and STOP conditions as well, so the "wait for transmission" language works all right. Other suggestions welcome too.
Let's forward declare functions at the top of the code block and merge our wait function into sending a byte now (discussed above)
Thanks @CrasherCourse!
I actually put the waiting function into the header. Instead of declaring it at the top of the code block.
I still have the wait function after the start and stop transmissions since the don't call I2CsendByte
.
It all looks good! Our coding conventions say to re-declare all the functions again after the code banner, which is dumb. So you can leave them out and I'll change the coding conventions.
If you tidy up the I2C.h
bottom to look more like the Defines
section and remove the now-useless Global Variables
banner, this should be neat enough to merge.
Merging soon. Speak now or forever hold your peace.
Okay, I fixed the things I still wanted changed:
PLUS one important change: I2CSendByte
and I2CWaitForTransmission
aren't really user functions. As such, they aren't part of an API per se and don't belong in the header file— which was the original rationale behind placing the function declarations at the top of the code banner. Does this make sense?
Just remembered that old reasoning now!
@tylrtrmbl Makes perfect sense.
But now I got this DETACHED HEAD:
branch thing my Git Hub application and I can't go back to the I2Cfix
branch.
Also, the curly braces of I2CSend
should be aligned. I can't fix it at the moment do to stupid stuff.
Edit: Never mind just fixed that issue.
Now I can't sync for some reason (behind a commit?)
@tylrtrmbl you might want to put the finishing touches for me.
My local branch has become buggy and won't sync.
try git pull origin I2Cfix
at the command line
:smile: It worked!
Also, I accidentally learned how to do that smile icon.
I believe that these are all the changes we needed from hacky. Please notify me if there is something amiss.