diff --git a/firmware/bootloader/src/dfu.h b/firmware/bootloader/src/dfu.h index fcaf5e9c44..05642df657 100644 --- a/firmware/bootloader/src/dfu.h +++ b/firmware/bootloader/src/dfu.h @@ -32,8 +32,8 @@ #define DFU_ACK_BYTE 0x79 // Acknowledge byte ID #define DFU_NACK_BYTE 0x1F // Not-Acknowledge byte ID -#define DFU_SR5_TIMEOUT_FIRST MS2ST(200) -#define DFU_SR5_TIMEOUT_NORMAL MS2ST(1000) +#define DFU_SR5_TIMEOUT_FIRST TIME_MS2I(200) +#define DFU_SR5_TIMEOUT_NORMAL TIME_MS2I(1000) #define MCU_REVISION_MASK 0xfff // MCU Revision ID is needed by DFU protocol diff --git a/firmware/console/binary/bluetooth.cpp b/firmware/console/binary/bluetooth.cpp index 724d61a63c..9492f86960 100644 --- a/firmware/console/binary/bluetooth.cpp +++ b/firmware/console/binary/bluetooth.cpp @@ -22,7 +22,7 @@ static char cmdPin[16]; static const int baudRates[] = { 0, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1 }; static const int baudRateIndexList[] = { 4 /*9600*/, 6 /*38400*/, 8 /*115200*/, 7, 5, 3, 2, 1, -1 }; -static const int btModuleTimeout = MS2ST(1000); +static const int btModuleTimeout = TIME_MS2I(1000); static ts_channel_s *tsChannel; diff --git a/firmware/console/binary/bluetooth.h b/firmware/console/binary/bluetooth.h index 141dc0c4f2..33362dc8f6 100644 --- a/firmware/console/binary/bluetooth.h +++ b/firmware/console/binary/bluetooth.h @@ -15,7 +15,7 @@ // The Bluetooth setup procedure will wait 10 seconds for the user to disconnect the UART cable. // This is required because the BT setup procedure reads a response from the module during the communication. // Thus any bytes sent from the Console Software may interfere with the procedure. -#define BLUETOOTH_COMMAND_TIMEOUT MS2ST(10000) +#define BLUETOOTH_COMMAND_TIMEOUT TIME_MS2I(10000) // Supported Bluetooth module types typedef enum { diff --git a/firmware/console/binary/tunerstudio_io.h b/firmware/console/binary/tunerstudio_io.h index 99a9a2a7dd..2f0027aac3 100644 --- a/firmware/console/binary/tunerstudio_io.h +++ b/firmware/console/binary/tunerstudio_io.h @@ -90,10 +90,10 @@ void startTsPort(ts_channel_s *tsChannel); bool stopTsPort(ts_channel_s *tsChannel); // that's 1 second -#define BINARY_IO_TIMEOUT MS2ST(1000) +#define BINARY_IO_TIMEOUT TIME_MS2I(1000) // that's 1 second -#define SR5_READ_TIMEOUT MS2ST(1000) +#define SR5_READ_TIMEOUT TIME_MS2I(1000) void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size); void sr5WriteCrcPacket(ts_channel_s *tsChannel, const uint8_t responseCode, const void *buf, const uint16_t size); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index d097b10fe5..4840da3287 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -222,7 +222,7 @@ static void scheduleNextSlowInvocation(void) { int periodMs = CONFIGB(generalPeriodicThreadPeriod); if (periodMs == 0) periodMs = 50; // this might happen while resetting configuration - chVTSetAny(&periodicSlowTimer, MS2ST(periodMs), (vtfunc_t) &periodicSlowCallback, engine); + chVTSetAny(&periodicSlowTimer, TIME_MS2I(periodMs), (vtfunc_t) &periodicSlowCallback, engine); } static void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { @@ -231,7 +231,7 @@ static void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { * not many reasons why we use ChibiOS timer and not say a dedicated thread here * the only down-side of a dedicated thread is the cost of thread stack */ - chVTSetAny(&periodicFastTimer, MS2ST(20), (vtfunc_t) &periodicFastCallback, engine); + chVTSetAny(&periodicFastTimer, TIME_MS2I(20), (vtfunc_t) &periodicFastCallback, engine); } static void resetAccel(void) { diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index 98cfdac576..21b09d672b 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -81,9 +81,9 @@ static void setInjectorEnabled(int id, int value) { static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, float onTimeMs, float offTimeMs, int count) { - int delaySt = delayMs < 1 ? 1 : MS2ST(delayMs); - int onTimeSt = onTimeMs < 1 ? 1 : MS2ST(onTimeMs); - int offTimeSt = offTimeMs < 1 ? 1 : MS2ST(offTimeMs); + int delaySt = delayMs < 1 ? 1 : TIME_MS2I(delayMs); + int onTimeSt = onTimeMs < 1 ? 1 : TIME_MS2I(onTimeMs); + int offTimeSt = offTimeMs < 1 ? 1 : TIME_MS2I(offTimeMs); if (delaySt < 0) { scheduleMsg(logger, "Invalid delay %.2f", delayMs); return; diff --git a/firmware/development/test/test.c b/firmware/development/test/test.c index ffd1c2e17f..2f8b6430ec 100644 --- a/firmware/development/test/test.c +++ b/firmware/development/test/test.c @@ -206,7 +206,7 @@ void test_cpu_pulse(unsigned duration) { systime_t start, end, now; start = chThdSelf()->p_time; - end = start + MS2ST(duration); + end = start + TIME_MS2I(duration); do { now = chThdSelf()->p_time; #if defined(SIMULATOR) @@ -252,7 +252,7 @@ static void tmr(void *p) { */ void test_start_timer(unsigned ms) { - systime_t duration = MS2ST(ms); + systime_t duration = TIME_MS2I(ms); test_timer_done = FALSE; chVTSet(&vt, duration, tmr, NULL); } diff --git a/firmware/ext/ffconf.h b/firmware/ext/ffconf.h index bd8659f69c..73631a0efe 100644 --- a/firmware/ext/ffconf.h +++ b/firmware/ext/ffconf.h @@ -246,7 +246,7 @@ #define FF_FS_REENTRANT 0 -#define FF_FS_TIMEOUT MS2ST(1000) +#define FF_FS_TIMEOUT TIME_MS2I(1000) #define FF_SYNC_t semaphore_t* /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs / module itself. Note that regardless of this option, file access to different diff --git a/firmware/global.h b/firmware/global.h index 304847f4f3..2ee4478ad9 100644 --- a/firmware/global.h +++ b/firmware/global.h @@ -135,5 +135,8 @@ void unlockAnyContext(void); } #endif +// a step towards ChibiOS18 +#define TIME_MS2I(x) MS2ST(x) + #endif /* GLOBAL_H_ */ diff --git a/firmware/hw_layer/can_hw.cpp b/firmware/hw_layer/can_hw.cpp index 1c17e4063b..af0bf88446 100644 --- a/firmware/hw_layer/can_hw.cpp +++ b/firmware/hw_layer/can_hw.cpp @@ -113,7 +113,7 @@ static void sendCanMessage2(int size) { } txmsg.DLC = size; // 1 second timeout - msg_t result = canTransmit(device, CAN_ANY_MAILBOX, &txmsg, MS2ST(1000)); + msg_t result = canTransmit(device, CAN_ANY_MAILBOX, &txmsg, TIME_MS2I(1000)); if (result == MSG_OK) { canWriteOk++; } else { @@ -234,7 +234,7 @@ static void canRead(void) { return; } // scheduleMsg(&logger, "Waiting for CAN"); - msg_t result = canReceive(device, CAN_ANY_MAILBOX, &rxBuffer, MS2ST(1000)); + msg_t result = canReceive(device, CAN_ANY_MAILBOX, &rxBuffer, TIME_MS2I(1000)); if (result == MSG_TIMEOUT) { return; } diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index b383ee7186..c87960dc73 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -156,7 +156,7 @@ static void rebootNow(void) { static void scheduleReboot(void) { scheduleMsg(&sharedLogger, "Rebooting in 5 seconds..."); lockAnyContext(); - chVTSetI(&resetTimer, MS2ST(5000), (vtfunc_t) rebootNow, NULL); + chVTSetI(&resetTimer, TIME_MS2I(5000), (vtfunc_t) rebootNow, NULL); unlockAnyContext(); } diff --git a/simulator/simulator/global.h b/simulator/simulator/global.h index 5459d55680..49f7f99fbf 100644 --- a/simulator/simulator/global.h +++ b/simulator/simulator/global.h @@ -93,6 +93,9 @@ void applyNewConfiguration(void); #define hal_lld_get_counter_value() 0 +// a step towards ChibiOS18 +#define TIME_MS2I(x) MS2ST(x) + #endif /* GLOBAL_H_ */