1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
pmantoine
31833972cd AFTEROVERLOAD fix 2024-05-31 11:36:02 +10:00
pmantoine
03a2d01484 I2C volatiles for critical region state 2024-05-31 11:31:36 +10:00
4 changed files with 10 additions and 11 deletions

View File

@ -228,7 +228,6 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
case OPCODE_AT:
case OPCODE_ATTIMEOUT2:
case OPCODE_AFTER:
case OPCODE_AFTEROVERLOAD:
case OPCODE_IF:
case OPCODE_IFNOT: {
int16_t pin = (int16_t)operand;

View File

@ -1,6 +1,6 @@
/*
* © 2023, Neil McKechnie. All rights reserved.
* © 2022 Paul M Antoine
* © 2022-2024 Paul M Antoine
*
* This file is part of CommandStation-EX
*
@ -519,14 +519,14 @@ private:
// State is set to I2C_STATE_FREE when the interrupt handler has finished
// the current request and is ready to complete.
uint8_t state = I2C_STATE_FREE;
uint8_t volatile state = I2C_STATE_FREE;
// CompletionStatus may be set by the interrupt handler at any time but is
// not written to the I2CRB until the state is I2C_STATE_FREE.
uint8_t completionStatus = I2C_STATUS_OK;
uint8_t overallStatus = I2C_STATUS_OK;
uint8_t volatile completionStatus = I2C_STATUS_OK;
uint8_t volatile overallStatus = I2C_STATUS_OK;
I2CRB * currentRequest = NULL;
I2CRB * volatile currentRequest = NULL;
uint8_t txCount = 0;
uint8_t rxCount = 0;
uint8_t bytesToSend = 0;

View File

@ -1,6 +1,6 @@
/*
* © 2023, Neil McKechnie
* © 2022 Paul M Antoine
* © 2022-2024, Paul M Antoine
* All rights reserved.
*
* This file is part of CommandStation-EX
@ -245,8 +245,8 @@ void I2CManagerClass::checkForTimeout() {
I2CRB *t = queueHead;
if (state==I2C_STATE_ACTIVE && t!=0 && t==currentRequest && _timeout > 0) {
// Check for timeout
int32_t elapsed = micros() - startTime;
if (elapsed > (int32_t)_timeout) {
uint32_t elapsed = micros() - startTime;
if (elapsed > _timeout) {
#ifdef DIAG_IO
//DIAG(F("I2CManager Timeout on %s"), t->i2cAddress.toString());
#endif

View File

@ -117,11 +117,11 @@ void I2CManagerClass::I2C_setClock(uint32_t i2cClockSpeed) {
// while (s->CR1 & I2C_CR1_STOP); // Prevents lockup by guarding further
// writes to CR1 while STOP is being executed!
// Should never happen, but wait for up to 500us only.
unsigned long startTime = micros();
uint32_t startTime = micros();
bool timeout = false;
while ((s->CR1 & I2C_CR1_STOP) != 0)
{
if ((int32_t)(micros() - startTime) >= 500) {
if ((micros() - startTime) >= 500) {
timeout = true;
s->CR1 &= ~I2C_CR1_STOP;
break;