/* project specific includes */
#include <helper/binarybuffer.h>
#include <helper/bits.h>
+#include <helper/system.h>
#include <jtag/interface.h>
#include <jtag/hla/hla_layout.h>
#include <jtag/hla/hla_transport.h>
* Map the relevant features, quirks and workaround for specific firmware
* version of stlink
*/
-#define STLINK_F_HAS_TRACE BIT(0)
-#define STLINK_F_HAS_SWD_SET_FREQ BIT(1)
-#define STLINK_F_HAS_JTAG_SET_FREQ BIT(2)
-#define STLINK_F_HAS_MEM_16BIT BIT(3)
-#define STLINK_F_HAS_GETLASTRWSTATUS2 BIT(4)
-#define STLINK_F_HAS_DAP_REG BIT(5)
-#define STLINK_F_QUIRK_JTAG_DP_READ BIT(6)
-#define STLINK_F_HAS_AP_INIT BIT(7)
-#define STLINK_F_HAS_DPBANKSEL BIT(8)
-#define STLINK_F_HAS_RW8_512BYTES BIT(9)
-#define STLINK_F_FIX_CLOSE_AP BIT(10)
+#define STLINK_F_HAS_TRACE BIT(0) /* v2>=j13 || v3 */
+#define STLINK_F_HAS_GETLASTRWSTATUS2 BIT(1) /* v2>=j15 || v3 */
+#define STLINK_F_HAS_SWD_SET_FREQ BIT(2) /* v2>=j22 */
+#define STLINK_F_HAS_JTAG_SET_FREQ BIT(3) /* v2>=j24 */
+#define STLINK_F_QUIRK_JTAG_DP_READ BIT(4) /* v2>=j24 && v2<j32 */
+#define STLINK_F_HAS_DAP_REG BIT(5) /* v2>=j24 || v3 */
+#define STLINK_F_HAS_MEM_16BIT BIT(6) /* v2>=j26 || v3 */
+#define STLINK_F_HAS_AP_INIT BIT(7) /* v2>=j28 || v3 */
+#define STLINK_F_FIX_CLOSE_AP BIT(8) /* v2>=j29 || v3 */
+#define STLINK_F_HAS_DPBANKSEL BIT(9) /* v2>=j32 || v3>=j2 */
+#define STLINK_F_HAS_RW8_512BYTES BIT(10) /* v3>=j6 */
/* aliases */
#define STLINK_F_HAS_TARGET_VOLT STLINK_F_HAS_TRACE
* based on the length (0x1a = 26) we could easily decide if we have to fixup the serial
* and then we have just to convert the raw data into printable characters using sprintf
*/
-static char *stlink_usb_get_alternate_serial(libusb_device_handle *device,
+static char *stlink_usb_get_alternate_serial(struct libusb_device_handle *device,
struct libusb_device_descriptor *dev_desc)
{
int usb_retval;
if (retval != ERROR_OK)
return retval;
- data = data ? : &dummy;
+ data = data ? data : &dummy;
if (stlink_dap_handle->version.flags & STLINK_F_QUIRK_JTAG_DP_READ
&& stlink_dap_handle->st_mode == STLINK_MODE_DEBUG_JTAG) {
/* Quirk required in JTAG. Read RDBUFF to get the data */
if (retval != ERROR_OK)
return retval;
}
- data = data ? : &dummy;
+ data = data ? data : &dummy;
retval = stlink_read_dap_register(stlink_dap_handle, ap->ap_num, reg,
data);
dap->stlink_flush_ap_write = false;