Misc. improvements (#12747)

* Make ExtUI respect MAXTEMP limits
  - Temperatures are now clamped by MAXTEMP limits rather than arbitrary values.
* Speed up USB init, add status
  - Speed up USB initialization
  - Show status message if init failed
* Enable status messages for EXTENSIBLE_UI
* Adjust max limit to MAX_TEMP - 15
* Misc. tweaks to formatting, const, etc.
This commit is contained in:
Marcio Teixeira
2019-01-01 14:17:48 -07:00
committed by Scott Lahteine
parent 4f2473053c
commit 60cb36bef3
12 changed files with 188 additions and 209 deletions

View File

@@ -112,7 +112,7 @@ uint8_t const SD_CARD_TYPE_SD1 = 1, // Standard capacity V1
* \brief Raw access to SD and SDHC flash memory cards.
*/
class Sd2Card {
public:
public:
Sd2Card() : errorCode_(SD_CARD_ERROR_INIT_NOT_CALLED), type_(0) {}
@@ -124,15 +124,15 @@ class Sd2Card {
* Set SD error code.
* \param[in] code value for error code.
*/
void error(uint8_t code) {errorCode_ = code;}
inline void error(const uint8_t code) { errorCode_ = code; }
/**
* \return error code for last error. See Sd2Card.h for a list of error codes.
*/
int errorCode() const {return errorCode_;}
inline int errorCode() const { return errorCode_; }
/** \return error data for last error. */
int errorData() const {return status_;}
inline int errorData() const { return status_; }
/**
* Initialize an SD flash memory card with default clock rate and chip
@@ -140,8 +140,8 @@ class Sd2Card {
*
* \return true for success or false for failure.
*/
bool init(uint8_t sckRateID = SPI_FULL_SPEED,
pin_t chipSelectPin = SD_CHIP_SELECT_PIN);
bool init(const uint8_t sckRateID=SPI_FULL_SPEED, const pin_t chipSelectPin=SD_CHIP_SELECT_PIN);
bool readBlock(uint32_t block, uint8_t* dst);
/**
@@ -163,12 +163,13 @@ class Sd2Card {
*
* \return true for success or false for failure.
*/
bool readCSD(csd_t* csd) { return readRegister(CMD9, csd); }
inline bool readCSD(csd_t* csd) { return readRegister(CMD9, csd); }
bool readData(uint8_t* dst);
bool readStart(uint32_t blockNumber);
bool readStop();
bool setSckRate(uint8_t sckRateID);
bool setSckRate(const uint8_t sckRateID);
/**
* Return the card type: SD V1, SD V2 or SDHC
* \return 0 - SD V1, 1 - SD V2, or 3 - SDHC.
@@ -176,10 +177,10 @@ class Sd2Card {
int type() const {return type_;}
bool writeBlock(uint32_t blockNumber, const uint8_t* src);
bool writeData(const uint8_t* src);
bool writeStart(uint32_t blockNumber, uint32_t eraseCount);
bool writeStart(uint32_t blockNumber, const uint32_t eraseCount);
bool writeStop();
private:
private:
uint8_t chipSelectPin_,
errorCode_,
spiRate_,
@@ -187,17 +188,17 @@ class Sd2Card {
type_;
// private functions
uint8_t cardAcmd(uint8_t cmd, uint32_t arg) {
inline uint8_t cardAcmd(const uint8_t cmd, const uint32_t arg) {
cardCommand(CMD55, 0);
return cardCommand(cmd, arg);
}
uint8_t cardCommand(uint8_t cmd, uint32_t arg);
uint8_t cardCommand(const uint8_t cmd, const uint32_t arg);
bool readData(uint8_t* dst, uint16_t count);
bool readRegister(uint8_t cmd, void* buf);
bool readData(uint8_t* dst, const uint16_t count);
bool readRegister(const uint8_t cmd, void* buf);
void chipDeselect();
void chipSelect();
void type(uint8_t value) { type_ = value; }
inline void type(const uint8_t value) { type_ = value; }
bool waitNotBusy(const millis_t timeout_ms);
bool writeData(uint8_t token, const uint8_t* src);
bool writeData(const uint8_t token, const uint8_t* src);
};