Skip to content

Commit ec6a792

Browse files
authored
Merge pull request #1391 from bitcraze/tobba/bolt_m4_not_running
Fixed CF-BL and Bolt M4 PC15 conflict resulting in that Bolt M4 didn't spin.
2 parents 079f02e + 0237009 commit ec6a792

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

src/drivers/interface/motors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ typedef struct
223223
uint32_t gpioPowerswitchPerif;
224224
GPIO_TypeDef* gpioPowerswitchPort;
225225
uint16_t gpioPowerswitchPin;
226+
bool hasPC15ESCReset;
226227
uint32_t timPerif;
227228
TIM_TypeDef* tim;
228229
uint16_t timPolarity;

src/drivers/src/motors.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,20 @@ void motorsInit(const MotorPerifDef** motorMapSelect)
224224

225225
DEBUG_PRINT("Using %s motor driver\n", motorMap[0]->drvType == BRUSHED ? "brushed" : "brushless");
226226

227+
if (motorMap[MOTOR_M1]->hasPC15ESCReset)
228+
{
229+
MOTORS_RCC_GPIO_CMD(RCC_AHB1Periph_GPIOC, ENABLE);
230+
// Configure the GPIO for CF-BL ESC RST
231+
GPIO_StructInit(&GPIO_InitStructure);
232+
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
233+
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
234+
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
235+
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
236+
GPIO_Init(GPIOC, &GPIO_InitStructure);
237+
// Hold reset for all CF-BL ESC:s by pulling low.
238+
GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_RESET);
239+
}
240+
227241
for (i = 0; i < NBR_OF_MOTORS; i++)
228242
{
229243
//Clock the gpio and the timers
@@ -243,16 +257,6 @@ void motorsInit(const MotorPerifDef** motorMapSelect)
243257
GPIO_WriteBit(motorMap[i]->gpioPowerswitchPort, motorMap[i]->gpioPowerswitchPin, 1);
244258
}
245259

246-
// Configure the GPIO for CF-BL ESC RST
247-
GPIO_StructInit(&GPIO_InitStructure);
248-
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
249-
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
250-
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
251-
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
252-
GPIO_Init(GPIOC, &GPIO_InitStructure);
253-
// Hold reset for all CF-BL ESC:s by pulling low.
254-
GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_RESET);
255-
256260
// Configure the GPIO for the timer output
257261
GPIO_StructInit(&GPIO_InitStructure);
258262
GPIO_InitStructure.GPIO_Mode = MOTORS_GPIO_MODE;
@@ -283,9 +287,11 @@ void motorsInit(const MotorPerifDef** motorMapSelect)
283287
motorMap[i]->ocInit(motorMap[i]->tim, &TIM_OCInitStructure);
284288
motorMap[i]->preloadConfig(motorMap[i]->tim, TIM_OCPreload_Enable);
285289
}
290+
286291
#ifdef CONFIG_MOTORS_ESC_PROTOCOL_DSHOT
287292
motorsDshotDMASetup();
288293
#endif
294+
289295
// Start the timers
290296
for (i = 0; i < NBR_OF_MOTORS; i++)
291297
{
@@ -296,9 +302,12 @@ void motorsInit(const MotorPerifDef** motorMapSelect)
296302

297303
// Output zero power
298304
motorsStop();
299-
// Release reset for all CF-BL ESC:s after motor signal is activated
300-
GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_SET);
301305

306+
if (motorMap[MOTOR_M1]->hasPC15ESCReset)
307+
{
308+
// Release reset for all CF-BL ESC:s after motor signal is activated
309+
GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_SET);
310+
}
302311
}
303312

304313
void motorsDeInit(const MotorPerifDef** motorMapSelect)

src/drivers/src/motors_def.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,7 @@ static const MotorPerifDef MOTORS_PA1_TIM2_CH2_BRUSHLESS_OD =
378378
.gpioPinSource = GPIO_PinSource1,
379379
.gpioOType = GPIO_OType_OD,
380380
.gpioAF = GPIO_AF_TIM2,
381-
.gpioPowerswitchPerif = RCC_AHB1Periph_GPIOA,
382-
.gpioPowerswitchPort = GPIOA,
383-
.gpioPowerswitchPin = GPIO_Pin_0,
381+
.hasPC15ESCReset = true,
384382
.timPerif = RCC_APB1Periph_TIM2,
385383
.tim = TIM2,
386384
.timPolarity = TIM_OCPolarity_High,
@@ -408,9 +406,7 @@ static const MotorPerifDef MOTORS_PB11_TIM2_CH4_BRUSHLESS_OD =
408406
.gpioPinSource = GPIO_PinSource11,
409407
.gpioOType = GPIO_OType_OD,
410408
.gpioAF = GPIO_AF_TIM2,
411-
.gpioPowerswitchPerif = RCC_AHB1Periph_GPIOB,
412-
.gpioPowerswitchPort = GPIOB,
413-
.gpioPowerswitchPin = GPIO_Pin_12,
409+
.hasPC15ESCReset = true,
414410
.timPerif = RCC_APB1Periph_TIM2,
415411
.tim = TIM2,
416412
.timPolarity = TIM_OCPolarity_High,
@@ -438,9 +434,7 @@ static const MotorPerifDef MOTORS_PB11_TIM2_CH4_BRUSHLESS_OD =
438434
.gpioPinSource = GPIO_PinSource15,
439435
.gpioOType = GPIO_OType_OD,
440436
.gpioAF = GPIO_AF_TIM2,
441-
.gpioPowerswitchPerif = RCC_AHB1Periph_GPIOC,
442-
.gpioPowerswitchPort = GPIOC,
443-
.gpioPowerswitchPin = GPIO_Pin_8,
437+
.hasPC15ESCReset = true,
444438
.timPerif = RCC_APB1Periph_TIM2,
445439
.tim = TIM2,
446440
.timPolarity = TIM_OCPolarity_High,
@@ -469,9 +463,7 @@ static const MotorPerifDef MOTORS_PB10_TIM2_CH3_BRUSHLESS_OD =
469463
.gpioPinSource = GPIO_PinSource10,
470464
.gpioOType = GPIO_OType_OD,
471465
.gpioAF = GPIO_AF_TIM2,
472-
.gpioPowerswitchPerif = RCC_AHB1Periph_GPIOC,
473-
.gpioPowerswitchPort = GPIOC,
474-
.gpioPowerswitchPin = GPIO_Pin_15,
466+
.hasPC15ESCReset = true,
475467
.timPerif = RCC_APB1Periph_TIM2,
476468
.tim = TIM2,
477469
.timPolarity = TIM_OCPolarity_High,

0 commit comments

Comments
 (0)