-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Add support for CAN RxCallbacks #1068
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
Conversation
mp_int_t fifo = mp_obj_get_int(fifo_in); | ||
|
||
|
||
if (callback_in == mp_const_none){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, and in other places, missing space between ')' & '{'.
5628a34
to
82637ea
Compare
@PappaPeppar thanks! There are a few things I'll clean up and fix (like putting pyb_can_obj_all in root pointer section), but main thing is to discuss how to call the callback function. Things like ExtInt and Timer only need one callback, when the event happens. Things like UART can have many callbacks: when data is received, when tx buffer is half empty, when tx buffer is completely empty. DAC can have callback when buffer is half empty, SPI can have callback when DMA transfer is finished. Etc. Basically a callback is an interrupt request. So how do we want to name the functions that set up the callbacks? Do we want to use individual names, like callback, rxcallback, txemptycallback, dmacallback, etc; or do we want one name (callback) with an argument to set the callback type? Eg can.callback('rx', lambda:...)? Could use short codes like 'txhe' for tx buf half empty. This would scale a bit better than adding many functions. Any other ideas or comments? |
First a short recap on the hardware capabilities in the area. The hardware supports three types of interrupts. Receive, Transmit and Error/Status information.
There is one Tx interrupt for each bus controller. There is one Error/Status interrupt for each bus controller. I would like to keep these events as separate callbacks.
Regarding naming: rxcallback and txcallback are obvious to me, but I guess other might have other opinions. I have not thought much about a name for the third callback, errcallback might be a candidate. |
Some style changes, put pyb_can_obj_all in global state structure, and merged in f80f1a7. |
…-merge Micropython 25ae98f merge
This patch adds support for adding callbacks to a can class that will be called when a message is received.