andysworkshop / stm32plus

The C++ library for the STM32 F0, F100, F103, F107 and F4 microcontrollers
http://www.andybrown.me.uk
Other
745 stars 224 forks source link

My initial commit for CAN support. … #141

Closed Elektroman2 closed 8 years ago

Elektroman2 commented 9 years ago

Tested: sending, receiving, SilentMode, LoopbackMode. Tested ONLY ON STM32F103C8T6 #139

andysworkshop commented 9 years ago

I'll definitely review this soon... but it looks like it breaks the build due to MCUs that don't have the CAN peripheral. I can fix this during the review if you're not confident to do it.

Elektroman2 commented 9 years ago

I used eclipse to build the lib, but I didn't copied the config files, just the include folder, (as I think now, also forget to copy the src folder, but the interrupt handler needs it). It also needs modifications for other microcontroller families, but currently I can only test with this custom board. So I ask you to do the necessary modifications, and feel free to modify it anywhere, if you think it's not OK.

hellow554 commented 9 years ago

Please make sure, that you only add and commit files, that are necessary for the project. You added some *.orig files. Please remove them

andysworkshop commented 9 years ago

I've pulled a local copy of this and will start reviewing it.

Elektroman2 commented 9 years ago

Hurray :) My next idea is One-Wire interface over GPIO, and DS18x20 sensor over 1-Wire, but first the CAN :)

Elektroman2 commented 9 years ago

Well, I only used the datasheet and the reference guide to get the right calculation, I will write a comment for it. My version contains that version what i sent you in email.

andysworkshop commented 9 years ago

Well, I only used the datasheet and the reference guide to get the right calculation, I will write a comment for it. My version contains that version what i sent you in email

That's fine. I just wanted to know that it's come from a good source and has been tested before I accept it.

It also needs modifications for other microcontroller families, but currently I can only test with this custom board.

I'll organise the source so it only builds on the F1 for now. F4 and F0 support can be added later.

Elektroman2 commented 9 years ago

Of course I tested. I tested first(without modification), then seen, there is no change in the returned value (constant 25 °C) but I slightly heated the chip with my solder iron. After that I looked whats happening in the library.

andysworkshop commented 9 years ago

Great, thanks. I'll revisit the algorithms in the F0/F4 ADC code and see if they need your modifications as well.

mikepurvis commented 9 years ago

This generally looks great— any thought given to supporting the secondary "slave" CAN2 peripheral available on some MCUs? I believe they're independent apart from the filter banks, so that's the piece to watch for.

andysworkshop commented 9 years ago

Do we need to clear it in CanInterruptHandler.cpp or the application interrupt handler can do it?

A pending flag should be cleared in CanInterruptHandler.cpp. Check the other peripheral interrupt handlers for reference.

Elektroman2 commented 9 years ago

Dear Mike, Currently i don't have device with 2 CAN interface, and I don't think I will need it in the near future. I took a quick look on the RefMan of the STM32F4x7. As I see, the slave is almost the same as the master, it only differs in CAN filtering. If you need 2 CAN devices, you can simple modify(expand) what I wrote.

andysworkshop commented 9 years ago

I noticed that you did add some CAN2 support in the pull request (for the connectivity line) but because it wasn't complete I removed it. If we can be clear on the differences between CAN1 and CAN2 then I'm happy to make the changes.

andysworkshop commented 9 years ago

B|y the way I noticed that you updated your branch with an example. I hope to get a chance to integrate that into the repo tomorrow.