Skip to content

Commit

Permalink
fixes for STM32 (#1011)
Browse files Browse the repository at this point in the history
resolves #1010
* compute `F_CPU` at runtime for STM32 in `startWrite()`
* fix scanner examples `min()`/`max()` calls
  • Loading branch information
2bndy5 authored Dec 4, 2024
1 parent 8aa7103 commit c98d41f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,11 @@ bool RF24::startWrite(const void* buf, uint8_t len, const bool multicast)
ce(HIGH);
#if !defined(F_CPU) || F_CPU > 20000000
delayMicroseconds(10);
#endif
#ifdef ARDUINO_ARCH_STM32
if (F_CPU > 20000000) {
delayMicroseconds(10);
}
#endif
ce(LOW);
return !(status & _BV(TX_FULL));
Expand Down
4 changes: 2 additions & 2 deletions examples/scanner/scanner.ino
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void loop(void) {
if (Serial.available()) {
int8_t c = Serial.parseInt();
if (c >= 0) {
c = min(125, max(0, c)); // clamp channel to supported range
c = min((int8_t)125, c); // clamp channel to supported range
constCarrierMode = 1;
radio.stopListening();
delay(2);
Expand Down Expand Up @@ -199,7 +199,7 @@ void loop(void) {
// Print out channel measurements, clamped to a single hex digit
for (int i = 0; i < num_channels; ++i) {
if (values[i])
Serial.print(min(0xf, values[i]), HEX);
Serial.print(min((uint8_t)0xf, values[i]), HEX);
else
Serial.print(F("-"));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/scannerGraphic/scannerGraphic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct ChannelHistory {
sum += history[i];
}
history[cacheMax - 1] = value;
maxPeak = max(sum * 2, maxPeak); // sum * 2 to allow half-step decay
maxPeak = max((uint8_t)(sum * 2), maxPeak); // sum * 2 to allow half-step decay
return sum;
}

Expand Down

0 comments on commit c98d41f

Please sign in to comment.