mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Remove old delay blocking workaround
This commit is contained in:
parent
df3024cdfb
commit
c4cc9a969b
2 changed files with 3 additions and 16 deletions
|
@ -266,13 +266,13 @@ int CAN_init() {
|
||||||
|
|
||||||
bool CAN_write_frame(const CAN_frame_t *p_frame) {
|
bool CAN_write_frame(const CAN_frame_t *p_frame) {
|
||||||
if (sem_tx_complete == NULL) {
|
if (sem_tx_complete == NULL) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the frame to the controller
|
// Write the frame to the controller
|
||||||
CAN_write_frame_phy(p_frame);
|
CAN_write_frame_phy(p_frame);
|
||||||
|
|
||||||
return xSemaphoreTake(sem_tx_complete, 20) == pdTRUE ? 1 : 0;
|
return xSemaphoreTake(sem_tx_complete, 20) == pdTRUE ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAN_stop() {
|
int CAN_stop() {
|
||||||
|
|
|
@ -6,20 +6,7 @@ int ESP32CAN::CANInit() {
|
||||||
return CAN_init();
|
return CAN_init();
|
||||||
}
|
}
|
||||||
bool ESP32CAN::CANWriteFrame(const CAN_frame_t* p_frame) {
|
bool ESP32CAN::CANWriteFrame(const CAN_frame_t* p_frame) {
|
||||||
static unsigned long start_time;
|
return CAN_write_frame(p_frame);
|
||||||
bool result = false;
|
|
||||||
if (tx_ok) {
|
|
||||||
result = CAN_write_frame(p_frame);
|
|
||||||
tx_ok = result;
|
|
||||||
if (!tx_ok) {
|
|
||||||
start_time = millis();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((millis() - start_time) >= 20) {
|
|
||||||
tx_ok = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ESP32CAN::CANStop() {
|
int ESP32CAN::CANStop() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue