#include <jtag/hla/hla_layout.h>
#include <jtag/hla/hla_transport.h>
#include <jtag/hla/hla_interface.h>
+#include <jtag/swim.h>
#include <target/target.h>
#include <transport/transport.h>
static int stlink_speed_swim(void *handle, int khz, bool query)
{
+ int retval;
+
/*
- we dont care what the khz rate is
we only have low and high speed...
before changing speed the SWIM_CSR HS bit
must be updated
*/
- if (khz == 0)
- stlink_swim_speed(handle, 0);
- else
- stlink_swim_speed(handle, 1);
- return khz;
+ if (!query) {
+ retval = stlink_swim_speed(handle, (khz < SWIM_FREQ_HIGH) ? 0 : 1);
+ if (retval != ERROR_OK)
+ LOG_ERROR("Unable to set adapter speed");
+ }
+
+ return (khz < SWIM_FREQ_HIGH) ? SWIM_FREQ_LOW : SWIM_FREQ_HIGH;
}
static int stlink_match_speed_map(const struct speed_map *map, unsigned int map_size, int khz, bool query)
#ifndef OPENOCD_JTAG_SWIM_H
#define OPENOCD_JTAG_SWIM_H
+#define SWIM_FREQ_LOW 363
+#define SWIM_FREQ_HIGH 800
+
struct swim_driver {
/**
* Send SRST (system reset) command to target.
retval = stm8_write_u8(target, SWIM_CSR, SAFE_MASK + SWIM_DM + HS);
if (retval != ERROR_OK)
return retval;
- jtag_config_khz(1);
+ jtag_config_khz(SWIM_FREQ_HIGH);
stm8->swim_configured = true;
/*
Now is the time to deassert reset if connect_under_reset.
# Set stm8l type
$_TARGETNAME configure -enable_stm8l
-# The khz rate does not apply here, only slow <0> and fast <1>
-adapter speed 1
+# Set low speed at debug entry
+adapter speed 363
reset_config srst_only
# Uncomment this line to enable interrupts while instruction step
#$_TARGETNAME configure -enable_step_irq
-# The khz rate does not apply here, only slow <0> and fast <1>
-adapter speed 1
+# Set low speed at debug entry
+adapter speed 363
reset_config srst_only