reducing code duplication with prod code & fixing simulator

This commit is contained in:
rusefi 2019-10-29 16:57:55 -04:00
parent f6bebd7eb7
commit 469a2f1fd9
3 changed files with 6 additions and 19 deletions

View File

@ -265,12 +265,15 @@ efitick_t getTimeNowNt(void) {
}
#endif /* EFI_PROD_CODE */
#if ! EFI_UNIT_TEST
/**
* number of SysClock ticks in one ms
*/
#define TICKS_IN_MS (CH_CFG_ST_FREQUENCY / 1000)
// todo: this overflows pretty fast!
efitimems_t currentTimeMillis(void) {
// todo: migrate to getTimeNowUs? or not?
@ -281,8 +284,7 @@ efitimems_t currentTimeMillis(void) {
efitimesec_t getTimeNowSeconds(void) {
return currentTimeMillis() / 1000;
}
#endif /* EFI_PROD_CODE */
#endif /* EFI_UNIT_TEST */
static void resetAccel(void) {
engine->engineLoadAccelEnrichment.resetAE();
@ -837,6 +839,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20191018;
return 20191028;
}
#endif /* EFI_UNIT_TEST */

View File

@ -16,16 +16,6 @@ efitimeus_t getTimeNowUs(void) {
return chVTGetSystemTimeX() * (1000000 / CH_CFG_ST_FREQUENCY);
}
// todo; reduce code duplication with prod code?
efitimems_t currentTimeMillis(void) {
return chVTGetSystemTimeX() / 1000;
}
// todo; reduce code duplication with prod code?
efitimesec_t getTimeNowSeconds(void) {
return currentTimeMillis() / CH_CFG_ST_FREQUENCY;
}
static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) {
printToConsole((char*)bp);
return CONSOLE_PORT->vmt->write(CONSOLE_PORT, bp, n);

View File

@ -76,11 +76,6 @@ void applyNewConfiguration(void);
}
#endif /* __cplusplus */
/**
* number of SysClock ticks in one ms
*/
#define TICKS_IN_MS (CH_FREQUENCY / 1000)
#define hal_lld_get_counter_value() 0
#endif /* GLOBAL_H_ */