2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file tunerstudio_io.h
|
2020-05-25 09:55:26 -07:00
|
|
|
* @file TS protocol commands and methods are here
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* @date Mar 8, 2015
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2020-04-01 16:00:56 -07:00
|
|
|
#pragma once
|
2018-09-16 19:25:17 -07:00
|
|
|
#include "global.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-09-23 11:06:22 -07:00
|
|
|
#if EFI_USB_SERIAL
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "usbconsole.h"
|
2020-09-23 11:06:22 -07:00
|
|
|
#endif // EFI_USB_SERIAL
|
2020-09-09 11:35:01 -07:00
|
|
|
|
|
|
|
#if EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "pin_repository.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
TS_PLAIN = 0,
|
|
|
|
TS_CRC = 1
|
|
|
|
} ts_response_format_e;
|
|
|
|
|
2020-06-21 13:37:33 -07:00
|
|
|
struct ts_channel_s {
|
2020-08-06 19:05:26 -07:00
|
|
|
#if ! EFI_UNIT_TEST
|
2020-06-21 17:47:46 -07:00
|
|
|
BaseChannel * channel = nullptr;
|
2020-08-06 19:05:26 -07:00
|
|
|
#endif
|
2015-08-22 10:01:35 -07:00
|
|
|
/**
|
2017-06-20 21:16:19 -07:00
|
|
|
* See 'blockingFactor' in rusefi.ini
|
2015-08-22 10:01:35 -07:00
|
|
|
*/
|
2020-11-14 16:21:29 -08:00
|
|
|
char scratchBuffer[BLOCKING_FACTOR + 30];
|
2020-06-21 13:37:33 -07:00
|
|
|
|
2020-06-21 20:31:41 -07:00
|
|
|
#if TS_UART_DMA_MODE || PRIMARY_UART_DMA_MODE || TS_UART_MODE
|
2020-06-21 13:37:33 -07:00
|
|
|
UARTDriver *uartp = nullptr;
|
|
|
|
#endif // TS_UART_DMA_MODE
|
|
|
|
};
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#define CRC_VALUE_SIZE 4
|
|
|
|
// todo: double-check this
|
|
|
|
#define CRC_WRAPPING_SIZE (CRC_VALUE_SIZE + 3)
|
|
|
|
|
2017-05-23 10:10:43 -07:00
|
|
|
void startTsPort(ts_channel_s *tsChannel);
|
2017-06-04 05:48:53 -07:00
|
|
|
bool stopTsPort(ts_channel_s *tsChannel);
|
2017-05-23 10:10:43 -07:00
|
|
|
|
|
|
|
// that's 1 second
|
2019-01-28 17:00:17 -08:00
|
|
|
#define BINARY_IO_TIMEOUT TIME_MS2I(1000)
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-05-23 11:54:40 -07:00
|
|
|
// that's 1 second
|
2019-01-28 17:00:17 -08:00
|
|
|
#define SR5_READ_TIMEOUT TIME_MS2I(1000)
|
2017-05-23 11:37:03 -07:00
|
|
|
|
|
|
|
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size);
|
2020-11-15 09:36:07 -08:00
|
|
|
void sr5WriteCrcPacketSmall(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size);
|
|
|
|
void sr5WriteCrcPacketLarge(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size);
|
2020-11-15 04:14:50 -08:00
|
|
|
void sr5WriteCrcPacket(ts_channel_s *tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size);
|
2017-05-23 11:37:03 -07:00
|
|
|
void sr5SendResponse(ts_channel_s *tsChannel, ts_response_format_e mode, const uint8_t * buffer, int size);
|
2020-08-05 22:15:41 -07:00
|
|
|
void sendOkResponse(ts_channel_s *tsChannel, ts_response_format_e mode);
|
2017-05-23 11:37:03 -07:00
|
|
|
int sr5ReadData(ts_channel_s *tsChannel, uint8_t * buffer, int size);
|
2017-05-30 11:08:12 -07:00
|
|
|
int sr5ReadDataTimeout(ts_channel_s *tsChannel, uint8_t * buffer, int size, int timeout);
|
2019-04-01 11:18:21 -07:00
|
|
|
bool sr5IsReady(ts_channel_s *tsChannel);
|
2020-09-11 02:50:48 -07:00
|
|
|
void sr5FlushData(ts_channel_s *tsChannel);
|
2015-07-10 06:01:56 -07:00
|
|
|
|