Skip to content

Commit 20d191a

Browse files
committed
fix compile problems on different platforms
1 parent 8cd9886 commit 20d191a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/comms/i2c/I2CCommander.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ the run() method disables interrupts while the updates happen.
8383
*/
8484
bool I2CCommander::receiveRegister(uint8_t motorNum, uint8_t registerNum, int numBytes) {
8585
int val;
86-
float floatval;
8786
switch (registerNum) {
8887
case REG_MOTOR_ADDRESS:
8988
val = _wire->read(); // reading one more byte is definately ok, since numBytes>1
@@ -387,7 +386,8 @@ bool I2CCommander::sendRegister(uint8_t motorNum, uint8_t registerNum) {
387386
writeFloat(motors[motorNum]->current_limit);
388387
break;
389388
case REG_MOTION_DOWNSAMPLE:
390-
_wire->write((uint32_t)motors[motorNum]->motion_downsample);
389+
_wire->write((int)motors[motorNum]->motion_downsample); // TODO int will have different sizes on different platforms
390+
// but using uint32 doesn't compile clean on all, e.g. RP2040
391391
break;
392392

393393
case REG_ZERO_ELECTRIC_ANGLE:
@@ -403,11 +403,12 @@ bool I2CCommander::sendRegister(uint8_t motorNum, uint8_t registerNum) {
403403
writeFloat(motors[motorNum]->phase_resistance);
404404
break;
405405
case REG_POLE_PAIRS:
406-
_wire->write((uint32_t)motors[motorNum]->pole_pairs);
406+
_wire->write((int)motors[motorNum]->pole_pairs);
407407
break;
408408

409409
case REG_SYS_TIME:
410-
_wire->write(millis());
410+
// TODO how big is millis()? Same on all platforms?
411+
_wire->write((int)millis());
411412
break;
412413
case REG_NUM_MOTORS:
413414
_wire->write(numMotors);

src/drivers/drv8316/drv8316.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ enum DRV8316_PWMMode {
2121

2222

2323
enum DRV8316_SDOMode {
24-
OpenDrain = 0b0,
25-
PushPull = 0b1
24+
SDOMode_OpenDrain = 0b0,
25+
SDOMode_PushPull = 0b1
2626
};
2727

2828

src/encoders/stm32hwencoder/STM32HWEncoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,19 @@ void STM32HWEncoder::init() {
112112
gpio.Mode = GPIO_MODE_AF_PP;
113113
gpio.Pull = GPIO_NOPULL;
114114
gpio.Speed = GPIO_SPEED_FREQ_MEDIUM;
115+
#ifndef STM32F1xx_HAL_GPIO_H
115116
gpio.Alternate = pinmap_function(pinA, PinMap_PWM);
117+
#endif
116118
HAL_GPIO_Init(digitalPinToPort(_pinA), &gpio);
117119

118120
// lets assume pinB is on the same timer as pinA... otherwise it can't work but the API currently doesn't allow us to fail gracefully
119121
gpio.Pin = digitalPinToBitMask(_pinB);
120122
gpio.Mode = GPIO_MODE_AF_PP;
121123
gpio.Pull = GPIO_NOPULL;
122124
gpio.Speed = GPIO_SPEED_FREQ_MEDIUM;
125+
#ifndef STM32F1xx_HAL_GPIO_H
123126
gpio.Alternate = pinmap_function(digitalPinToPinName(_pinB), PinMap_PWM);
127+
#endif
124128
HAL_GPIO_Init(digitalPinToPort(_pinB), &gpio);
125129

126130
// set up timer for encoder

0 commit comments

Comments
 (0)