Files
wideband/firmware/console/binary/tunerstudio_io_serial.cpp
rusefillc ccb790f532 Steal tunerstudio files from RusEFI (#71)
* Steal tunerstudio files from RusEFI

(cherry picked from commit dcba04fbd31700f5ca4ef4f12a6e220c5713c7d0)

* Steal crc32 files from RusEFI

(cherry picked from commit bfe88b5297c6fc90c8e647e4144c91edafef25f9)

* fix TS steal

(cherry picked from commit a77b9761da4c185359bb2d7e10abd6a8e69c740d)

* fix crc32

(cherry picked from commit cdb4df09f69c2494316c2b12f97dbe19f6bdb598)

* TS stealed from RE

(cherry picked from commit ff470e134036372425da44e9e0fb98737f31c9e9)

* Steal TS

(cherry picked from commit d11406edc2d6b3c1567ce800e207038745a162e7)

* Steal Thread Controller

(cherry picked from commit 2aa5bbd57150e0d5b51e2e88752bdc8697698861)

* Update TunerStudio protocol files

(cherry picked from commit 58f14216ec6e7fc4408e52ccc28a4f912e340b05)

* byteswap.h

(cherry picked from commit 581d647fd49890af4628f0ff5b51e9f193efcac4)

* bugfix

* one more file to compile, another file not ready - removing from this PR

* removing more from this PR

Co-authored-by: Andrey Gusakov <dron0gus@gmail.com>
Co-authored-by: rusefillc <sdfsdfqsf2334234234>
2022-06-29 01:29:40 -07:00

62 lines
1.4 KiB
C++

/**
* Implementation for hardware-serial TunerStudio ports
*/
#include "tunerstudio_io.h"
#include "hal.h"
#if HAL_USE_SERIAL
void SerialTsChannel::start(uint32_t baud) {
SerialConfig cfg = {
.speed = baud,
.cr1 = 0,
.cr2 = USART_CR2_STOP1_BITS | USART_CR2_LINEN,
.cr3 = 0
};
sdStart(m_driver, &cfg);
}
void SerialTsChannel::stop() {
sdStop(m_driver);
}
void SerialTsChannel::write(const uint8_t* buffer, size_t size, bool) {
chnWriteTimeout(m_driver, buffer, size, BINARY_IO_TIMEOUT);
}
size_t SerialTsChannel::readTimeout(uint8_t* buffer, size_t size, int timeout) {
return chnReadTimeout(m_driver, buffer, size, timeout);
}
#endif // HAL_USE_SERIAL
#if (HAL_USE_UART == TRUE) && (UART_USE_WAIT == TRUE)
void UartTsChannel::start(uint32_t baud) {
m_config.txend1_cb = NULL;
m_config.txend2_cb = NULL;
m_config.rxend_cb = NULL;
m_config.rxchar_cb = NULL;
m_config.rxerr_cb = NULL;
m_config.timeout_cb = NULL;
m_config.speed = baud;
m_config.cr1 = 0;
m_config.cr2 = 0/*USART_CR2_STOP1_BITS*/ | USART_CR2_LINEN;
m_config.cr3 = 0;
uartStart(m_driver, &m_config);
}
void UartTsChannel::stop() {
uartStop(m_driver);
}
void UartTsChannel::write(const uint8_t* buffer, size_t size, bool) {
uartSendTimeout(m_driver, &size, buffer, BINARY_IO_TIMEOUT);
}
size_t UartTsChannel::readTimeout(uint8_t* buffer, size_t size, int timeout) {
uartReceiveTimeout(m_driver, &size, buffer, timeout);
return size;
}
#endif // HAL_USE_UART