diff options
author | Ben V. Brown <[email protected]> | 2021-01-17 20:13:02 +1100 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2021-01-17 20:13:02 +1100 |
commit | 2425902fbc36f85ae429b5457004ee608f712add (patch) | |
tree | a4fb66369fc31fb69800591d17ba1180f9f561b1 | |
parent | cb34fb56e3d0cffac1950f11b12a3d357e7afcf5 (diff) | |
download | IronOS-2425902fbc36f85ae429b5457004ee608f712add.tar.gz IronOS-2425902fbc36f85ae429b5457004ee608f712add.zip |
Hotfix: BMA Accel wedges I2C if probed too fast after bootv2.14.1
Only an issue on Pinecil as it boots much faster than Miniware units.
-rw-r--r-- | source/Core/BSP/Pine64/I2C_Wrapper.cpp | 10 | ||||
-rw-r--r-- | source/Core/BSP/Pine64/IRQ.h | 6 | ||||
-rw-r--r-- | source/Core/BSP/Pine64/Model_Config.h | 6 | ||||
-rw-r--r-- | source/Core/BSP/Pine64/Pins.h | 6 | ||||
-rw-r--r-- | source/Core/BSP/Pine64/Setup.h | 6 | ||||
-rw-r--r-- | source/Core/BSP/Pine64/UnitSettings.h | 6 | ||||
-rw-r--r-- | source/Core/Threads/GUIThread.cpp | 3 | ||||
-rw-r--r-- | source/Core/Threads/MOVThread.cpp | 12 |
8 files changed, 25 insertions, 30 deletions
diff --git a/source/Core/BSP/Pine64/I2C_Wrapper.cpp b/source/Core/BSP/Pine64/I2C_Wrapper.cpp index 180a71b6..c54380c0 100644 --- a/source/Core/BSP/Pine64/I2C_Wrapper.cpp +++ b/source/Core/BSP/Pine64/I2C_Wrapper.cpp @@ -385,18 +385,10 @@ bool FRToSI2C::lock() { if (I2CSemaphore == nullptr) {
return false;
}
- if (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) {
- return true;
- }
return xSemaphoreTake(I2CSemaphore, TICKS_SECOND) == pdTRUE;
}
-void FRToSI2C::unlock() {
- if (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) {
- return;
- }
- xSemaphoreGive(I2CSemaphore);
-}
+void FRToSI2C::unlock() { xSemaphoreGive(I2CSemaphore); }
bool FRToSI2C::writeRegistersBulk(const uint8_t address, const I2C_REG *registers, const uint8_t registersLength) {
for (int index = 0; index < registersLength; index++) {
diff --git a/source/Core/BSP/Pine64/IRQ.h b/source/Core/BSP/Pine64/IRQ.h index be2891d0..b3d27122 100644 --- a/source/Core/BSP/Pine64/IRQ.h +++ b/source/Core/BSP/Pine64/IRQ.h @@ -5,8 +5,8 @@ * Author: Ralim
*/
-#ifndef BSP_MINIWARE_IRQ_H_
-#define BSP_MINIWARE_IRQ_H_
+#ifndef BSP_PINE64_IRQ_H_
+#define BSP_PINE64_IRQ_H_
#include "BSP.h"
#include "I2C_Wrapper.hpp"
@@ -53,4 +53,4 @@ extern volatile uint8_t i2c_process_flag; #ifdef __cplusplus
}
#endif
-#endif /* BSP_MINIWARE_IRQ_H_ */
+#endif /* BSP_PINE64_IRQ_H_ */
diff --git a/source/Core/BSP/Pine64/Model_Config.h b/source/Core/BSP/Pine64/Model_Config.h index 0c8577cf..d0ac1e36 100644 --- a/source/Core/BSP/Pine64/Model_Config.h +++ b/source/Core/BSP/Pine64/Model_Config.h @@ -5,8 +5,8 @@ * Author: Ralim
*/
-#ifndef BSP_MINIWARE_MODEL_CONFIG_H_
-#define BSP_MINIWARE_MODEL_CONFIG_H_
+#ifndef BSP_PINE64_MODEL_CONFIG_H_
+#define BSP_PINE64_MODEL_CONFIG_H_
/*
* Lookup for mapping features <-> Models
*/
@@ -29,4 +29,4 @@ #define BATTFILTERDEPTH 32
#endif
-#endif /* BSP_MINIWARE_MODEL_CONFIG_H_ */
+#endif /* BSP_PINE64_MODEL_CONFIG_H_ */
diff --git a/source/Core/BSP/Pine64/Pins.h b/source/Core/BSP/Pine64/Pins.h index d143cfb1..d6590081 100644 --- a/source/Core/BSP/Pine64/Pins.h +++ b/source/Core/BSP/Pine64/Pins.h @@ -5,8 +5,8 @@ * Author: Ralim
*/
-#ifndef BSP_MINIWARE_PINS_H_
-#define BSP_MINIWARE_PINS_H_
+#ifndef BSP_PINE64_PINS_H_
+#define BSP_PINE64_PINS_H_
#include "gd32vf103_gpio.h"
#define KEY_B_Pin BIT(1)
@@ -50,4 +50,4 @@ #define FUSB302_IRQ_Pin BIT(5)
#define FUSB302_IRQ_GPIO_Port GPIOB
-#endif /* BSP_MINIWARE_PINS_H_ */
+#endif /* BSP_PINE64_PINS_H_ */
diff --git a/source/Core/BSP/Pine64/Setup.h b/source/Core/BSP/Pine64/Setup.h index 9ad2e1c6..d3d6e12d 100644 --- a/source/Core/BSP/Pine64/Setup.h +++ b/source/Core/BSP/Pine64/Setup.h @@ -5,8 +5,8 @@ * Author: Ben V. Brown
*/
-#ifndef SETUP_H_
-#define SETUP_H_
+#ifndef PINE_SETUP_H_
+#define PINE_SETUP_H_
#include "gd32vf103_libopt.h"
#include <stdint.h>
@@ -21,4 +21,4 @@ void setupFUSBIRQ(); #endif
extern const uint8_t holdoffTicks;
extern const uint8_t tempMeasureTicks;
-#endif /* SETUP_H_ */
+#endif /* PINE_SETUP_H_ */
diff --git a/source/Core/BSP/Pine64/UnitSettings.h b/source/Core/BSP/Pine64/UnitSettings.h index 46f76091..20fadb8b 100644 --- a/source/Core/BSP/Pine64/UnitSettings.h +++ b/source/Core/BSP/Pine64/UnitSettings.h @@ -5,7 +5,7 @@ * Author: Ralim
*/
-#ifndef BSP_MINIWARE_UNITSETTINGS_H_
-#define BSP_MINIWARE_UNITSETTINGS_H_
+#ifndef BSP_PINE64_UNITSETTINGS_H_
+#define BSP_PINE64_UNITSETTINGS_H_
-#endif /* BSP_MINIWARE_UNITSETTINGS_H_ */
+#endif /* BSP_PINE64_UNITSETTINGS_H_ */
diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index c59513d5..1a1dbbf3 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -749,7 +749,7 @@ void showWarnings() { // In this case though, we dont want to nag the user _too_ much // So only show first 2 times while (DetectedAccelerometerVersion == ACCELEROMETERS_SCANNING) { - osDelay(1); + osDelay(5); } // Display alert if accelerometer is not detected if (DetectedAccelerometerVersion == NO_DETECTED_ACCELEROMETER) { @@ -800,7 +800,6 @@ void startGUITask(void const *argument __unused) { ButtonState buttons = getButtonState(); if (buttons) ticks = xTaskGetTickCount(); // make timeout now so we will exit - OLED::refresh(); GUIDelay(); } diff --git a/source/Core/Threads/MOVThread.cpp b/source/Core/Threads/MOVThread.cpp index 17fdca54..fb4d23df 100644 --- a/source/Core/Threads/MOVThread.cpp +++ b/source/Core/Threads/MOVThread.cpp @@ -12,6 +12,7 @@ #include "LIS2DH12.hpp"
#include "MMA8652FC.hpp"
#include "MSA301.h"
+#include "Model_Config.h"
#include "QC3.h"
#include "SC7A20.hpp"
#include "Settings.h"
@@ -25,8 +26,9 @@ #define MOVFilter 8
uint8_t accelInit = 0;
TickType_t lastMovementTime = 0;
-void detectAccelerometerVersion() {
- DetectedAccelerometerVersion = 99;
+
+void detectAccelerometerVersion() {
+ DetectedAccelerometerVersion = ACCELEROMETERS_SCANNING;
#ifdef ACCEL_MMA
if (MMA8652FC::detect()) {
if (MMA8652FC::initalize()) {
@@ -44,7 +46,7 @@ void detectAccelerometerVersion() { #endif
#ifdef ACCEL_BMA
if (BMA223::detect()) {
- // Setup the ST Accelerometer
+ // Setup the BMA223 Accelerometer
if (BMA223::initalize()) {
DetectedAccelerometerVersion = 3;
}
@@ -68,7 +70,8 @@ void detectAccelerometerVersion() { #endif
{
// disable imu sensitivity
- systemSettings.sensitivity = 0;
+ systemSettings.sensitivity = 0;
+ DetectedAccelerometerVersion = NO_DETECTED_ACCELEROMETER;
}
}
inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz, Orientation &rotation) {
@@ -107,6 +110,7 @@ inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz, Orientation }
}
void startMOVTask(void const *argument __unused) {
+ osDelay(TICKS_100MS / 5);// This is here as the BMA doesnt start up instantly and can wedge the I2C bus if probed too fast after boot
detectAccelerometerVersion();
osDelay(TICKS_100MS / 2); // wait ~50ms for setup of accel to finalise
lastMovementTime = 0;
|