CAN Bus Library for STM32F103

Can someone help me port this library?
watswat5
Posts: 1
Joined: Mon May 04, 2015 9:04 pm

CAN Bus Library for STM32F103

Postby watswat5 » Mon May 04, 2015 9:19 pm

I'm looking for a working CAN library for the stm32f103. I know it has the hardware for it, but looking at some example code (found here: https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/open-source-hardware), I'm totally lost.

Can someone create a CAN library similar to the MCP2515 library for Arduino? That library is intuitive and easy to use, even for users who know almost nothing about CAN.

The MCP2515 Library can be found here: https://github.com/coryjfowler/MCP_CAN_lib

Phono
Posts: 61
Joined: Tue May 05, 2015 6:08 am

Re: CAN Bus Library for STM32F103

Postby Phono » Tue May 05, 2015 9:08 pm

Hi,
the maple world already has a CAN library that eventually worked with some effort and various contributions, including mine.
you can have a look here : http://forums.leaflabs.com/topic.php?id=802
I think I will try to port it to Arduino when I have the time to do it. So far, the Maple version works pretty well.

phantom_tss
Posts: 5
Joined: Thu Jul 23, 2015 2:02 pm

Re: CAN Bus Library for STM32F103

Postby phantom_tss » Thu Jul 23, 2015 5:11 pm

I need this :roll:

User avatar
RogerClark
Posts: 5465
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: CAN Bus Library for STM32F103

Postby RogerClark » Thu Jul 23, 2015 9:25 pm

you probably need to see if you can contact the author of this link

http://akb77.com/g/files/media/Maple.Ha ... 0.0.12.rar

as its been over a year since anyone was active on the maple forum, discussing this, and there may also be updates in the forum not incorporated into this code.

It may not even compile

phantom_tss
Posts: 5
Joined: Thu Jul 23, 2015 2:02 pm

Re: CAN Bus Library for STM32F103

Postby phantom_tss » Fri Jul 24, 2015 8:08 am

Can I use this library for stm32f103cbt6 board?

User avatar
RogerClark
Posts: 5465
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: CAN Bus Library for STM32F103

Postby RogerClark » Fri Jul 24, 2015 8:29 am

I've just downloaded that file, and its more than just a library, it has replacement for some core files including RCC and USB, so basically I suspect its not going to work.

i.e Its unlikely that you can just replace the rcc.c and usb.c files with the ones from that download, as almost certainly rcc.c has been updated since those files were crated (in 2012) and I suspect so has usb.c

You'd need to diff those files against the ones shipped as part of the maple IDE back in 2012 (the IDE can still be download), and determine what changes were made by the author, then you'd need to apply the same changes to the current copies of usb.c and rcc.c and .h

Without actually doing all that myself, I have no idea how easy or complex, it would be to merge in the changes.


Please feel free to work out what needs to be updated and preferably send me a pull request when you've updated the core.
But I don't have time to add CAN support at the moment, and I'm not even sure I have any CAN devices to test with, even if I did have time to look at this.

Thanks

Roger

phantom_tss
Posts: 5
Joined: Thu Jul 23, 2015 2:02 pm

Re: CAN Bus Library for STM32F103

Postby phantom_tss » Fri Jul 24, 2015 12:01 pm

Thanks a lot :)

peppeve
Posts: 20
Joined: Sat Jul 25, 2015 9:01 am

Re: CAN Bus Library for STM32F103

Postby peppeve » Sat Jul 25, 2015 9:08 am

I'm interested too to this library, i try to build a Nmea2000 interface with maple mini (arduino uno is too slow for handle all data on the can bus). Please keep me updated about this.

Phono
Posts: 61
Joined: Tue May 05, 2015 6:08 am

Re: CAN Bus Library for STM32F103

Postby Phono » Sat Jul 25, 2015 11:38 am

Hi,
I am sorry I had no time yet to work on this port. If you browse the thread in the Maple forum (http://forums.leaflabs.com/topic.php?id=802), you will find mentions of changes in USB and RCC.
This is because in the stm32f103cbt6 used in Maple and Olimexino boards, the USB and the CAN are mutually exclusive, since they use a shared portion or the memory (which is a pity, for you cannot debug a CAN application by writing information to the SerialUSB channel).
In addition, the CAN and the USB share a common interrupt vector.
In the original library, they had forgotten to add the switch to route the interrupt either to the USB or to the CAN processing. Which I added.
The drawback is that I had to declare an identifier in the core, which belongs to the CAN library. So far, I have to include the CAN library in every project, even if it does not use the CAN, just because the lacking identifier would produce a compile error.
In my contribution in the forum, you will see the lines that are changed in both USB.c and RCC.c and .h.
Roger Clark is right saying these files are likely to have changed since the version I used; but if you only do the mentioned changes in the current core files, I guess it will work.
If by the way you find a means to relieve the user from the need to include the CAN library when it is not needed, It would be great.
Regards,
Jean-Marc

User avatar
RogerClark
Posts: 5465
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: CAN Bus Library for STM32F103

Postby RogerClark » Sat Jul 25, 2015 12:34 pm

Jean-Marc

Did you try using a weak reference to a dummy identifer?

The core code does this quite a lot for default ISRs


Return to “Libary request”

Who is online

Users browsing this forum: And_Ru and 1 guest