Ejemplo n.º 1
0
        public virtual EDapConnectPortModeByte connect(EDapConnectPortModeByte mode = EDapConnectPortModeByte.DEFAULT)
        {
            List <byte> cmd = new List <byte>
            {
                (byte)EDapCommandByte.DAP_CONNECT,
                (byte)mode
            };

            this.anInterface.write(cmd);
            List <byte> resp = this.anInterface.read();

            if (resp[0] != (byte)EDapCommandByte.DAP_CONNECT)
            {
                // Response is to a different command
                throw new DeviceError();
            }
            if (resp[1] == 0)
            {
                // DAP connect failed
                throw new CommandError();
            }
            if (resp[1] == 1)
            {
                Trace.TraceInformation("DAP SWD MODE initialized");
            }
            if (resp[1] == 2)
            {
                Trace.TraceInformation("DAP JTAG MODE initialized");
            }
            Debug.Assert(Enum.IsDefined(typeof(EDapConnectPortModeByte), (EDapConnectPortModeByte)resp[1]));
            return((EDapConnectPortModeByte)resp[1]);
        }
Ejemplo n.º 2
0
        // ------------------------------------------- #
        //             Target access functions
        // ------------------------------------------- #
        public void connect(EDapConnectPortModeByte port = EDapConnectPortModeByte.DEFAULT)
        {
            //Debug.Assert(port is PORT);
            EDapConnectPortModeByte actual_port = this._protocol.connect(port);

            this._dap_port = actual_port;
            // set clock frequency
            this._protocol.setSWJClock(this._frequency);
            // configure transfer
            this._protocol.transferConfigure();
        }
Ejemplo n.º 3
0
        public virtual void clear_sticky_err()
        {
            EDapConnectPortModeByte mode = this.link.get_swj_mode();

            if (mode == EDapConnectPortModeByte.SWD)
            {
                this.link.write_reg(REG_APnDP_A3_A2.DP_0x0, 1 << 2);
            }
            else if (mode == EDapConnectPortModeByte.JTAG)
            {
                this.link.write_reg(DP_REG["CTRL_STAT"], CTRLSTAT_STICKYERR);
            }
            else
            {
                Debug.Assert(false);
            }
        }