Hi kristoffer,
Thanks for the help! I just wanted to let you and anyone else interested in adding motor/pwm outputs know that I was able to get it to work. The steps I did to do it are as follows:
1. Make copies of piezo.h, piezo.c (in drivers), and buzzdeck.c (in deck/drivers/src) and name them along the lines of wheel_driver.h, wheel_driver.c, and wheeldeck.c
2. Change all "piezo"s in wheel_driver.h and wheel_driver.c to "wheel" or whatever. Then go through the timer and port definitions of wheel_driver.c to change them to be what you want (aka modify the names or change the timer or channel). piezo.c makes PWM outputs on TIM5_CH3 and TIM5_CH4. I did not change this for myself. Note that TIM5_CH3 is mapped to TX2 and TIM5_CH4 is mapped to RX2 on the expansion deck. Next, under the comment "// Configure OC3" add the line
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
so that OC3 is not inverted from OC4. Unless you want it to be inverted.
The function piezoSetRatio(uint8_t ratio) sets the PWM duty cycle of the two outputs. You may want to modify this function to take two ratios so that you can give each motor its own duty cycle.
3. Next modify buzzdeck.c (now named wheeldeck.c or whatever). I combined code from buzzdeck.c, this forum post on making digital I/O (
viewtopic.php?t=1690) and this tutorial on adding LEDs (
https://www.hackster.io/evoggy/flying-t ... ght-8be87d).
4. Add to the Makefile:
#Drivers
PROJ_OBJ_CF2 += wheel_driver.o
#DECK API
PROJ_OBJ_CF2 += wheelDeck.o
5. Make a config.mk file in tools/make and add this line to it:
CFLAGS += -DDECK_FORCE=wheelDeck
"wheelDeck" is whatever you have named your deck.
This should work once it's compiled. For reference, I have the code on github here
https://github.com/braraki/crazyflie-firmware