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

CAN support #139

Closed andysworkshop closed 8 years ago

andysworkshop commented 9 years ago

CAN is a major peripheral on the STM32 family and we don't yet support it in stm32plus.

andysworkshop commented 9 years ago

@Elektroman2 I've reviewed your pull request and have commited it to a new branch can-support. Can you verify that it still works for you?

Also, are you planning to commit a simple CAN bus example?

Elektroman2 commented 9 years ago

Of course I will publish a simple example soon. Currently I'm using it in a more complex project. I tried to build your last version, unfortunatly it failed.

In file included from /home/elektroman/projects/ARMWorkspace/stm32plus/include/config/can.h:28:0, from ../PowerSupply.cpp:18: /home/elektroman/projects/ARMWorkspace/stm32plus/include/can/CanPeripheral.h: In instantiation of 'stm32plus::CanPeripheral<TPinPackage, TPeripheralName>::CanPeripheral(const stm32plus::CanPeripheral<TPinPackage, TPeripheralName>::Parameters&) [with TPinPackage = stm32plus::Can1DefaultPinPackage; stm32plus::PeripheralName TPeripheralName = (stm32plus::PeripheralName)58u]': /home/elektroman/projects/ARMWorkspace/stm32plus/include/can/f1/Can1.h:50:42: required from 'stm32plus::Can1<Features>::Can1(const stm32plus::CanPeripheral<stm32plus::Can1DefaultPinPackage, (stm32plus::PeripheralName)58u>::Parameters&) [with Features = {stm32plus::Can1InterruptFeature, stm32plus::CanFilterBypassFeature}]' ../PowerSupply.cpp:153:74: required from here /home/elektroman/projects/ARMWorkspace/stm32plus/include/can/CanPeripheral.h:123:75: error: incomplete type 'stm32plus::PeripheralTraits<(stm32plus::PeripheralName)58u>' used in nested name specifier : Can((CAN_TypeDef * )PeripheralTraits<TPeripheralName>::PERIPHERAL_BASE) { ^ /home/elektroman/projects/ARMWorkspace/stm32plus/include/can/CanPeripheral.h: In instantiation of 'void stm32plus::CanPeripheral<TPinPackage, TPeripheralName>::initialisePeripheral() [with TPinPackage = stm32plus::Can1DefaultPinPackage; stm32plus::PeripheralName TPeripheralName = (stm32plus::PeripheralName)58u]': /home/elektroman/projects/ARMWorkspace/stm32plus/include/can/f1/Can1.h:52:6: required from 'stm32plus::Can1<Features>::Can1(const stm32plus::CanPeripheral<stm32plus::Can1DefaultPinPackage, (stm32plus::PeripheralName)58u>::Parameters&) [with Features = {stm32plus::Can1InterruptFeature, stm32plus::CanFilterBypassFeature}]' ../PowerSupply.cpp:153:74: required from here /home/elektroman/projects/ARMWorkspace/stm32plus/include/can/CanPeripheral.h:168:86: error: incomplete type 'stm32plus::PeripheralTraits<(stm32plus::PeripheralName)58u>' used in nested name specifier CAN_Init((CAN_TypeDef *)PeripheralTraits<TPeripheralName>::PERIPHERAL_BASE,&_init); ^ make: *** [PowerSupply.o] Error 1

andysworkshop commented 9 years ago

Too hard to tell the root cause without seeing the line in your source that causes the error. However, this sort of thing compiles cleanly for me. Please compare to yours:

#include "config/can.h"

typedef Can1<CanFilterBypassFeature,CanLoopbackModeFeature,Can1InterruptFeature> MyCan;

MyCan::Parameters p;
MyCan can(p);
Elektroman2 commented 9 years ago

I found it, I will send everything tomorrow. ( I messed up things with git :( )

andysworkshop commented 8 years ago

thanks to @spiralray we've now got F4 support and I'm about ready to merge can-support to master unless anyone's got any objections...

andysworkshop commented 8 years ago

can-support is now merged to master. F0 support will complete this feature but I'll close this issue now and track F0 support under a new issue.