Repository navigation
Add MCP25625T and MCP251863T SPI CAN drivers - #57
Draft
jsphuebner with Copilot wants to merge 3 commits into
Draft
jsphuebner with Copilot wants to merge 3 commits into
jsphuebner with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: jsphuebner <3882041+jsphuebner@users.noreply.github.com>
Co-authored-by: jsphuebner <3882041+jsphuebner@users.noreply.github.com>
Co-authored-by: jsphuebner <3882041+jsphuebner@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
CanHardwaredrivers for the MCP25625T (CAN 2.0) and MCP251863T (CAN FD) SPI controllers. Each driver is a single header and source file with no external driver library. TheCanHardwareinterface is unchanged, and chip-specific features such as FD mode sit outside it.Both drivers are untested. Only a syntax check against stub headers was done, because libopencm3 isn't available in this environment.
(uint32_t spi, DigIo& cs, baudrate).spiis a libopencm3 SPI base address, which must already be configured for mode 0, MSB first, 8 bit. CS is active low.Stm32Can(sendBuffer,sendCnt,SENDBUFFER_LEN). Frames that don't fit in the chip's TX buffers are queued and drained byHandleTx(). The sameDISABLE/ENABLE_CAN_USER_INTERRUPTSguards are used.HandleInterrupt()(RX, then TX drain) from the INT pin handler or a poll loop.MCP25625_OSC_HZ(default 16 MHz) orMCP251863_SYSCLK_HZ(default 40 MHz).mcp25625_can.{h,cpp}userIds/userMasksare matched in software.ConfigureFilters()does nothing.SetListenOnly().mcp251863_can.{h,cpp}ConfigureFilters()programs the 32 hardware filters (a standard or extended match, with an optional mask) fromuserIds/userMasks.EnableFd(),SetDataBaudrate(),SendFd()(up to 64 bytes, optional BRS) andSetFdRxCallback(). Frames longer than 8 bytes go to the callback if set, otherwise they are truncated to 8 bytes.SetListenOnly()is also available.Review focus
C1CON,NBTCFG,DBTCFG,TDCFIFOCON,FIFOSTAandFIFOUA, including the+0x400RAM offsetFLTOBJandMASKlayout