Skip to content

Commit

Permalink
fix RP2040 compile problems with earlehillpower
Browse files Browse the repository at this point in the history
  • Loading branch information
runger1101001 committed Apr 30, 2024
1 parent 26c631d commit 14f6726
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/drivers/hardware_specific/rp2040/rp2040_mcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
#pragma message("SimpleFOC: compiling for RP2040")
#pragma message("")


#if !defined(SIMPLEFOC_DEBUG_RP2040)
#define SIMPLEFOC_DEBUG_RP2040
#endif

#include "../../hardware_api.h"
#include "hardware/pwm.h"
#include "hardware/clocks.h"
#if defined(USE_ARDUINO_PINOUT)
#include <pinDefinitions.h>
#endif

#define _PWM_FREQUENCY 24000
#define _PWM_FREQUENCY_MAX 66000
Expand All @@ -35,7 +38,11 @@ uint16_t wrapvalues[NUM_PWM_SLICES];
// TODO add checks which channels are already used...

void setupPWM(int pin_nr, long pwm_frequency, bool invert, RP2040DriverParams* params, uint8_t index) {
#if defined(USE_ARDUINO_PINOUT)
uint pin = (uint)digitalPinToPinName(pin_nr); // we could check for -DBOARD_HAS_PIN_REMAP ?
#else
uint pin = (uint)pin_nr;
#endif
gpio_set_function(pin, GPIO_FUNC_PWM);
uint slice = pwm_gpio_to_slice_num(pin);
uint chan = pwm_gpio_to_channel(pin);
Expand Down

0 comments on commit 14f6726

Please sign in to comment.