Skip to content

Commit 614a7e1

Browse files
committed
bugfix for #188
1 parent 4c1c66b commit 614a7e1

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Therefore this is an attempt to:
2727
> - bugfixing
2828
> - leonardo
2929
> - mega2560
30+
> - inline current sense without driver #188
3031
> - `initFOC` fails if current sense not initialised
3132
> - driver and cs have to be well initialised for `initFOC` to start
3233
> - `cs.init()` and `driver.init()` return `1` if well initialised and `0` if failed

src/common/base_classes/CurrentSense.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CurrentSense{
2828
// variables
2929
bool skip_align = false; //!< variable signaling that the phase current direction should be verified during initFOC()
3030

31-
BLDCDriver* driver; //!< driver link
31+
BLDCDriver* driver = nullptr; //!< driver link
3232
bool initialized = false; // true if current sense was successfully initialized
3333
void* params = 0; //!< pointer to hardware specific parameters of current sensing
3434

src/current_sense/InlineCurrentSense.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ InlineCurrentSense::InlineCurrentSense(float _shunt_resistor, float _gain, int _
2121

2222
// Inline sensor init function
2323
int InlineCurrentSense::init(){
24+
// if no linked driver its fine in this case
25+
// at least for init()
26+
void* drv_params = driver ? driver->params : nullptr;
2427
// configure ADC variables
25-
params = _configureADCInline(driver->params,pinA,pinB,pinC);
28+
params = _configureADCInline(drv_params,pinA,pinB,pinC);
2629
// if init failed return fail
2730
if (params == SIMPLEFOC_CURRENT_SENSE_INIT_FAILED) return 0;
2831
// calibrate zero offsets

0 commit comments

Comments
 (0)