Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added return to function enterShipMode #635

Merged
merged 1 commit into from
May 17, 2023

Conversation

alessandromrc
Copy link
Contributor

I've added the code that actually checks if the value has been written and then returns its value to resolve this issue: "warning: no return statement in function returning non-void".

I've added the code that actually checks if the value has been written and then returns its value to resolve this issue: "warning: no return statement in function returning non-void"
@sebromero
Copy link
Collaborator

Thank you for your pull request. While this works, I think I would prefer to fix this in the PMIC driver code that should return the success / failure status:

bool BQ25120A::writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
{
  cd = 1;
  nicla::i2c_mutex.lock();
  Wire1.beginTransmission(address);
  Wire1.write(subAddress);
  Wire1.write(data);
  uint8_t result = Wire1.endTransmission();
  nicla::i2c_mutex.unlock();
  cd = 0;
  return result == 0;
}

Then in the enterShipMode function could just piggy back on that return status:

bool nicla::enterShipMode()
{
  //    STATUS reg:
  //    | B7 | B6 |      B5     | B4 | B3 | B2 | B1 | B0 |
  //    | RO | RO | EN_SHIPMODE | RO | RO | RO | RO | RO |

  uint8_t status_reg = _pmic.getStatus();
  status_reg |= 0x20;
  return _pmic.writeByte(BQ25120A_ADDRESS, BQ25120A_STATUS, status_reg);
}

@facchinm Thoughts?

@facchinm
Copy link
Member

enterShipMode() should immediately "kill" the board if I remember correctly, so the return is not going to be taken into consideration (except to silence the compiler 🙂 )

@alessandromrc
Copy link
Contributor Author

@facchinm I would add it in every case, firstly to silence the compiler like you said but we actually don't know what might be going to happen on the microcontroller that might cause issues.

@sebromero sebromero merged commit d149870 into arduino:main May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants