Fix errors when building for non-native platforms.

This commit is contained in:
Gareth McMullin 2015-03-02 23:27:42 -08:00
parent 83b83ca48f
commit 9a8dbdeff7
6 changed files with 36 additions and 2 deletions

View File

@ -28,6 +28,7 @@
#include "gpio.h"
#include "morse.h"
#include "timing.h"
#include "target.h"
#include <setjmp.h>

View File

@ -86,10 +86,20 @@ platform_init(void)
cdcacm_init();
}
void platform_timeout_set(uint32_t ms)
{
timeout_counter = ms / 10;
}
bool platform_timeout_is_expired(void)
{
return timeout_counter == 0;
}
void platform_delay(uint32_t delay)
{
timeout_counter = delay * 10;
while(timeout_counter);
platform_timeout_set(delay);
while (platform_timeout_is_expired());
}
const char *platform_target_voltage(void)

View File

@ -18,6 +18,8 @@
#define __PLATFORM_H
#include "gdb_packet.h"
#include "target.h"
#include "morse.h"
#include <setjmp.h>

View File

@ -21,6 +21,7 @@
#include "gdb_if.h"
#include <assert.h>
#include <sys/time.h>
struct ftdi_context *ftdic;
@ -258,3 +259,21 @@ void platform_delay(uint32_t delay)
usleep(delay * 100000);
}
static uint32_t timeout_time;
static uint32_t time_ms(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
void platform_timeout_set(uint32_t ms)
{
timeout_time = time_ms() + ms;
}
bool platform_timeout_is_expired(void)
{
return time_ms() > timeout_time;
}

View File

@ -27,6 +27,7 @@
#include "gdb_packet.h"
#include "gpio.h"
#include "timing.h"
#include "target.h"
#include <libopencm3/cm3/common.h>
#include <libopencm3/stm32/f1/memorymap.h>

View File

@ -27,6 +27,7 @@
#include "gdb_packet.h"
#include "gpio.h"
#include "timing.h"
#include "target.h"
#include <setjmp.h>