From 7b230c04b3d4be2ac4d78414efe201dc11415c7c Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Wed, 3 Apr 2013 23:17:59 +0200 Subject: Add dev2 support. This is used for APBTeam dev2 board. Black Magic runs on computer system and communicates with dev2 over usb, giving simple orders. --- src/platforms/dev2/platform.h | 95 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/platforms/dev2/platform.h (limited to 'src/platforms/dev2/platform.h') diff --git a/src/platforms/dev2/platform.h b/src/platforms/dev2/platform.h new file mode 100644 index 0000000..c35c839 --- /dev/null +++ b/src/platforms/dev2/platform.h @@ -0,0 +1,95 @@ +/* + * This file is part of the Black Magic Debug project. + * + * Copyright (C) 2011 Black Sphere Technologies Ltd. + * Written by Gareth McMullin + * + * 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 . + */ + +#ifndef __PLATFORM_H +#define __PLATFORM_H + +#include +#include + +#ifndef WIN32 +# include +#else +# define alloca __builtin_alloca +#endif + +/* All communications are big endian. */ + +/* Reset communication and set all pins as input. */ +#define DEV2_OP_RESET_SYNC 0xa5 +/* Set port width (1 byte argument) and period (4 bytes, in ns unit). + * Port width will determine the size of a port argument (1 byte for 8, 2 + * bytes for 16...). Period is the pause between two output changes, 0 means + * as fast as possible. */ +#define DEV2_OP_SETUP 0xaa + +/* Set complete port direction, 1 is output. */ +#define DEV2_OP_DIR 0xb0 +/* Set direction as output for selected pins. */ +#define DEV2_OP_DIR_OUT 0xb1 +/* Set direction as input for selected pins. */ +#define DEV2_OP_DIR_IN 0xb2 +/* Set complete output port value. */ +#define DEV2_OP_OUT 0xb4 +/* Set pins in output port. */ +#define DEV2_OP_OUT_SET 0xb5 +/* Reset pins in output port. */ +#define DEV2_OP_OUT_RESET 0xb6 +/* Toggle pins in output port. */ +#define DEV2_OP_OUT_TOGGLE 0xb7 +/* Change pins (mask as first argument, value as second argument). */ +#define DEV2_OP_OUT_CHANGE 0xb8 +/* Request port input. */ +#define DEV2_OP_IN 0xb9 + + +/* Pins definition. */ +#define TDI_PIN 0x80 +#define TMS_PIN 0x01 +#define TCK_PIN 0x02 +#define TDO_PIN 0x40 +#define SWDIO_PIN TMS_PIN +#define SWCLK_PIN TCK_PIN +#undef TRST_PIN +#undef SRST_PIN + +#define SET_RUN_STATE(state) +#define SET_IDLE_STATE(state) +#define SET_ERROR_STATE(state) + +#define PLATFORM_FATAL_ERROR(error) abort() +#define PLATFORM_SET_FATAL_ERROR_RECOVERY() + +#define DEBUG(...) platform_debug(__VA_ARGS__) + +#define morse(x, y) do { if (x) fprintf(stderr,"%s\n", x); } while (0) +#define morse_msg 0 + +int platform_init(int argc, char **argv); +const char *platform_target_voltage(void); +void platform_delay(uint32_t delay); + +void platform_buffer_flush(void); +int platform_buffer_write(const uint8_t *data, int size); +int platform_buffer_read(uint8_t *data, int size); +void platform_debug(const char *fmt, ...); + +#endif + -- cgit v1.2.3