bmp/pc platforms: Deduplicate code.
This commit is contained in:
parent
9ca401497c
commit
bd73adf9c7
|
@ -8,5 +8,5 @@ else ifneq (, $(findstring cygwin, $(SYS)))
|
||||||
LDFLAGS += -lusb-1.0 -lws2_32
|
LDFLAGS += -lusb-1.0 -lws2_32
|
||||||
endif
|
endif
|
||||||
VPATH += platforms/pc
|
VPATH += platforms/pc
|
||||||
SRC += timing.c cl_utils.c
|
SRC += timing.c cl_utils.c utils.c
|
||||||
CFLAGS +=-I ./target -I./platforms/pc
|
CFLAGS +=-I ./target -I./platforms/pc
|
||||||
|
|
|
@ -290,34 +290,7 @@ int platform_buffer_read(uint8_t *data, int size)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
|
||||||
#warning "This vasprintf() is dubious!"
|
|
||||||
int vasprintf(char **strp, const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
int size = 128, ret = 0;
|
|
||||||
|
|
||||||
*strp = malloc(size);
|
|
||||||
while(*strp && ((ret = vsnprintf(*strp, size, fmt, ap)) == size))
|
|
||||||
*strp = realloc(*strp, size <<= 1);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *platform_target_voltage(void)
|
const char *platform_target_voltage(void)
|
||||||
{
|
{
|
||||||
return "not supported";
|
return "not supported";
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_delay(uint32_t ms)
|
|
||||||
{
|
|
||||||
usleep(ms * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t platform_time_ms(void)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,4 @@ else ifneq (, $(findstring cygwin, $(SYS)))
|
||||||
LDFLAGS += -lusb-1.0 -lws2_32
|
LDFLAGS += -lusb-1.0 -lws2_32
|
||||||
endif
|
endif
|
||||||
VPATH += platforms/pc
|
VPATH += platforms/pc
|
||||||
SRC += cl_utils.c timing.c
|
SRC += cl_utils.c timing.c utils.c
|
||||||
|
|
|
@ -307,20 +307,6 @@ int platform_buffer_read(uint8_t *data, int maxsize)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
|
||||||
#warning "This vasprintf() is dubious!"
|
|
||||||
int vasprintf(char **strp, const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
int size = 128, ret = 0;
|
|
||||||
|
|
||||||
*strp = malloc(size);
|
|
||||||
while(*strp && ((ret = vsnprintf(*strp, size, fmt, ap)) == size))
|
|
||||||
*strp = realloc(*strp, size <<= 1);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *platform_target_voltage(void)
|
const char *platform_target_voltage(void)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -340,15 +326,3 @@ const char *platform_target_voltage(void)
|
||||||
|
|
||||||
return (char *)&construct[1];
|
return (char *)&construct[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_delay(uint32_t ms)
|
|
||||||
{
|
|
||||||
usleep(ms * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t platform_time_ms(void)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,5 +9,5 @@ else ifneq (, $(findstring cygwin, $(SYS)))
|
||||||
LDFLAGS += -lws2_32
|
LDFLAGS += -lws2_32
|
||||||
endif
|
endif
|
||||||
VPATH += platforms/pc
|
VPATH += platforms/pc
|
||||||
SRC += timing.c stlinkv2.c cl_utils.c
|
SRC += timing.c stlinkv2.c cl_utils.c utils.c
|
||||||
OWN_HL = 1
|
OWN_HL = 1
|
||||||
|
|
|
@ -69,29 +69,3 @@ int platform_buffer_read(uint8_t *data, int size)
|
||||||
(void) data;
|
(void) data;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
|
||||||
#warning "This vasprintf() is dubious!"
|
|
||||||
int vasprintf(char **strp, const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
int size = 128, ret = 0;
|
|
||||||
|
|
||||||
*strp = malloc(size);
|
|
||||||
while(*strp && ((ret = vsnprintf(*strp, size, fmt, ap)) == size))
|
|
||||||
*strp = realloc(*strp, size <<= 1);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void platform_delay(uint32_t ms)
|
|
||||||
{
|
|
||||||
usleep(ms * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t platform_time_ms(void)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Black Magic Debug project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||||
|
* Base on code:
|
||||||
|
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
||||||
|
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||||
|
* and others.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file deduplicates codes used in several pc-hosted platforms
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
|
#warning "This vasprintf() is dubious!"
|
||||||
|
int vasprintf(char **strp, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
int size = 128, ret = 0;
|
||||||
|
|
||||||
|
*strp = malloc(size);
|
||||||
|
while(*strp && ((ret = vsnprintf(*strp, size, fmt, ap)) == size))
|
||||||
|
*strp = realloc(*strp, size <<= 1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void platform_delay(uint32_t ms)
|
||||||
|
{
|
||||||
|
usleep(ms * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t platform_time_ms(void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
||||||
|
}
|
Loading…
Reference in New Issue