1
0
forked from me/IronOS

Fix mixtake in I2C probe check

This commit is contained in:
Ben V. Brown
2020-05-30 18:35:15 +10:00
parent 441ac7f83a
commit 64d5e8b1af
4 changed files with 74 additions and 85 deletions

View File

@@ -30,7 +30,7 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
// RToS is active, run threading
// Get the mutex so we can use the I2C port
// Wait up to 1 second for the mutex
if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
if (xSemaphoreTake(I2CSemaphore, (TickType_t)500) == pdTRUE) {
#ifdef I2CUSESDMA
if (HAL_I2C_Mem_Read(&hi2c1, DevAddress, MemAddress,
I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
@@ -78,8 +78,7 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
// RToS is active, run threading
// Get the mutex so we can use the I2C port
// Wait up to 1 second for the mutex
if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
#ifdef I2CUSESDMA
if (xSemaphoreTake(I2CSemaphore, (TickType_t)500) == pdTRUE) {
if (HAL_I2C_Mem_Write(&hi2c1, DevAddress, MemAddress,
I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
@@ -87,13 +86,7 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
xSemaphoreGive(I2CSemaphore);
}
xSemaphoreGive(I2CSemaphore);
#else
if (HAL_I2C_Mem_Write(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT, pData,
Size, 5000) != HAL_OK) {
}
xSemaphoreGive(I2CSemaphore);
#endif
} else {
}
}
@@ -130,11 +123,9 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
bool FRToSI2C::probe(uint16_t DevAddress) {
uint8_t buffer[1];
if (Mem_Read(DevAddress, 0, buffer, 1)) {
//ACK'd
return true;
}
return false;
return HAL_I2C_Mem_Read(&hi2c1, DevAddress, 0x0F, I2C_MEMADD_SIZE_8BIT,
buffer, 1, 1000) == HAL_OK;
}
void FRToSI2C::I2C_Unstick() {

View File

@@ -7,7 +7,8 @@
#include "power.hpp"
#include "stdlib.h"
#include "task.h"
#include "I2C_Wrapper.hpp"
void postRToSInit() {
// Any after RTos setup
FRToSI2C::FRToSInit();
}

View File

@@ -10,9 +10,8 @@ extern "C" {
#include <MMA8652FC.hpp>
#include <gui.hpp>
#include <history.hpp>
#include <main.hpp>
#include "main.hpp"
#include <power.hpp>
#include "../../configuration.h"
#include "Buttons.hpp"
#include "LIS2DH12.hpp"
@@ -23,7 +22,7 @@ extern "C" {
#include "stdlib.h"
#include "string.h"
#include "unit.h"
extern uint8_t PCBVersion;
// File local variables
extern uint32_t currentTempTargetDegC;
extern uint8_t accelInit;
@@ -597,7 +596,7 @@ void showDebugMenu(void) {
/* StartGUITask function */
void startGUITask(void const *argument __unused) {
FRToSI2C::FRToSInit();
uint8_t tempWarningState = 0;
bool buttonLockout = false;
bool tempOnDisplay = false;

View File

@@ -23,12 +23,9 @@
uint8_t accelInit = 0;
uint32_t lastMovementTime = 0;
void startMOVTask(void const *argument __unused) {
OLED::setRotation(true);
OLED::setRotation(systemSettings.OrientationMode & 1);
postRToSInit();
power_probe();
while (pidTaskNotification == 0) osDelay(30); // Wait for PID to start
OLED::setRotation(systemSettings.OrientationMode & 1);
lastMovementTime = 0;
int16_t datax[MOVFilter] = { 0 };
int16_t datay[MOVFilter] = { 0 };
@@ -36,7 +33,8 @@ void startMOVTask(void const *argument __unused) {
uint8_t currentPointer = 0;
int16_t tx = 0, ty = 0, tz = 0;
int32_t avgx, avgy, avgz;
if (systemSettings.sensitivity > 9) systemSettings.sensitivity = 9;
if (systemSettings.sensitivity > 9)
systemSettings.sensitivity = 9;
Orientation rotation = ORIENTATION_FLAT;
for (;;) {
int32_t threshold = 1500 + (9 * 200);