Skip to content

Commit fb88707

Browse files
author
Richard Unger
committed
renesas small fixes
1 parent c99cc6d commit fb88707

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/drivers/hardware_specific/renesas/renesas.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "communication/SimpleFOCDebug.h"
1414
#include "FspTimer.h"
1515

16+
#define GPT_OPEN (0x00475054ULL)
17+
1618
/*
1719
We use the GPT timers, there are 2 channels (32 bit) + 6 channels (16 bit)
1820
Each channel has 2 outputs (GTIOCAx and GTIOCBx) which can be complimentary.
@@ -202,6 +204,7 @@ bool configureTimerPin(RenesasHardwareDriverParams* params, uint8_t index, bool
202204
t->timer_cfg.p_context = nullptr;
203205
t->timer_cfg.p_extend = &(t->ext_cfg);
204206
t->timer_cfg.cycle_end_ipl = BSP_IRQ_DISABLED;
207+
t->timer_cfg.cycle_end_irq = FSP_INVALID_VECTOR;
205208

206209
t->ext_cfg.p_pwm_cfg = &(t->pwm_cfg);
207210
t->pwm_cfg.trough_ipl = BSP_IRQ_DISABLED;
@@ -256,6 +259,14 @@ bool configureTimerPin(RenesasHardwareDriverParams* params, uint8_t index, bool
256259
t->ext_cfg.gtior_setting.gtior_b.obdflt = active_high ? 0x00 : 0x01;
257260
}
258261

262+
// lets stop the timer in case its running
263+
if (GPT_OPEN == t->ctrl.open) {
264+
if (R_GPT_Stop(&(t->ctrl)) != FSP_SUCCESS) {
265+
SIMPLEFOC_DEBUG("DRV: timer stop failed");
266+
return false;
267+
}
268+
}
269+
259270
memset(&(t->ctrl), 0, sizeof(gpt_instance_ctrl_t));
260271
err = R_GPT_Open(&(t->ctrl),&(t->timer_cfg));
261272
if ((err != FSP_ERR_ALREADY_OPEN) && (err != FSP_SUCCESS)) {
@@ -294,7 +305,7 @@ bool configureTimerPin(RenesasHardwareDriverParams* params, uint8_t index, bool
294305
bool startTimerChannels(RenesasHardwareDriverParams* params, int num_channels) {
295306
uint32_t mask = 0;
296307
for (int i = 0; i < num_channels; i++) {
297-
RenesasTimerConfig* t = params->timer_config[i];
308+
// RenesasTimerConfig* t = params->timer_config[i];
298309
// if (R_GPT_Start(&(t->ctrl)) != FSP_SUCCESS) {
299310
// SIMPLEFOC_DEBUG("DRV: timer start failed");
300311
// return false;

0 commit comments

Comments
 (0)