mirror of
https://github.com/pine64/blisp.git
synced 2025-01-21 21:20:14 +00:00
Adding RTS & DTS mechanism (not working yet)
This commit is contained in:
parent
7f69a80f0e
commit
6e036df085
21
include/blisp_util.h
Normal file
21
include/blisp_util.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef _BLISP_UTIL_H
|
||||
#define _BLISP_UTIL_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
static void sleep_ms(int milliseconds){
|
||||
#ifdef WIN32
|
||||
Sleep(milliseconds);
|
||||
#else
|
||||
struct timespec ts;
|
||||
ts.tv_sec = milliseconds / 1000;
|
||||
ts.tv_nsec = (milliseconds % 1000) * 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
10
lib/blisp.c
10
lib/blisp.c
@ -3,6 +3,7 @@
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <blisp_util.h>
|
||||
|
||||
#define DEBUG
|
||||
|
||||
@ -138,6 +139,15 @@ blisp_device_handshake(struct blisp_device* device, bool in_ef_loader) {
|
||||
uint8_t handshake_buffer[600];
|
||||
struct sp_port* serial_port = device->serial_port;
|
||||
|
||||
if (!in_ef_loader && !device->is_usb) {
|
||||
sp_set_rts(serial_port, SP_RTS_ON);
|
||||
sp_set_dtr(serial_port, SP_DTR_ON);
|
||||
sleep_ms(50);
|
||||
sp_set_rts(serial_port, SP_RTS_OFF);
|
||||
sleep_ms(100);
|
||||
sp_set_dtr(serial_port, SP_DTR_OFF);
|
||||
}
|
||||
|
||||
uint32_t bytes_count = device->chip->handshake_byte_multiplier * (float)device->current_baud_rate / 10.0f;
|
||||
if (bytes_count > 600) bytes_count = 600;
|
||||
memset(handshake_buffer, 'U', bytes_count);
|
||||
|
Loading…
Reference in New Issue
Block a user