jlink: write_data -> writeTMSTDI. Fix behaviour
This commit is contained in:
parent
fc07ddf076
commit
5692482152
|
|
@ -192,6 +192,46 @@ int Jlink::flush()
|
||||||
return ll_write(NULL);
|
return ll_write(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Jlink::writeTMSTDI(const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
|
||||||
|
uint32_t numbits)
|
||||||
|
{
|
||||||
|
// use pointer to access all vectors
|
||||||
|
const uint8_t *tms_ptr = tms;
|
||||||
|
const uint8_t *tdi_ptr = tdi;
|
||||||
|
uint8_t *tdo_ptr = tdo;
|
||||||
|
|
||||||
|
uint32_t xfer_len = 0;
|
||||||
|
|
||||||
|
while (numbits > 0) {
|
||||||
|
// if bits to send are greater than internal buffer
|
||||||
|
// limits to buffer size
|
||||||
|
if (numbits > (BUF_SIZE * 8))
|
||||||
|
xfer_len = BUF_SIZE * 8;
|
||||||
|
else // or direct xfer
|
||||||
|
xfer_len = numbits;
|
||||||
|
// convert size in Byte
|
||||||
|
uint16_t numbytes = (xfer_len + 7) >> 8;
|
||||||
|
|
||||||
|
// copy buffers to internals
|
||||||
|
memcpy(_tms, tms_ptr, numbytes);
|
||||||
|
memcpy(_tdi, tdi_ptr, numbytes);
|
||||||
|
// save size to transmit
|
||||||
|
_num_bits = xfer_len;
|
||||||
|
// send
|
||||||
|
if (!ll_write(tdo_ptr))
|
||||||
|
return false;
|
||||||
|
// decrement bits to send
|
||||||
|
numbits -= xfer_len;
|
||||||
|
// move pointers
|
||||||
|
tms_ptr += numbytes;
|
||||||
|
tdi_ptr += numbytes;
|
||||||
|
if (tdo)
|
||||||
|
tdo_ptr += numbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Jlink::ll_write(uint8_t *tdo)
|
bool Jlink::ll_write(uint8_t *tdo)
|
||||||
{
|
{
|
||||||
if (_num_bits == 0)
|
if (_num_bits == 0)
|
||||||
|
|
@ -576,19 +616,6 @@ void Jlink::read_config()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Jlink::write_data(const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
|
|
||||||
uint16_t numbits)
|
|
||||||
{
|
|
||||||
if (numbits > (BUF_SIZE * 8))
|
|
||||||
numbits = BUF_SIZE * 8;
|
|
||||||
uint16_t numbytes = (numbits +7) >> 8;
|
|
||||||
|
|
||||||
memcpy(_tms, tms, numbytes);
|
|
||||||
memcpy(_tdi, tdi, numbytes);
|
|
||||||
_num_bits = numbits;
|
|
||||||
return ll_write(tdo);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Jlink::jlink_search_interface(libusb_device *dev,
|
bool Jlink::jlink_search_interface(libusb_device *dev,
|
||||||
libusb_device_descriptor *desc, int *interface_idx,
|
libusb_device_descriptor *desc, int *interface_idx,
|
||||||
int *config_idx, int *alt_idx)
|
int *config_idx, int *alt_idx)
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,17 @@ class Jlink: public JtagInterface {
|
||||||
*/
|
*/
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief access ll_write outer this class / directly receives
|
||||||
|
* fully filled tms, tdi buffers, and optionnally tdo
|
||||||
|
* \param[in] tms: tms buffer
|
||||||
|
* \param[in] tdi: tdi buffer
|
||||||
|
* \param[out] tdo: tdo buffer
|
||||||
|
* \param[in] numbits: tms/tdi/tdo buffer size (in bit)
|
||||||
|
*/
|
||||||
|
bool writeTMSTDI(const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
|
||||||
|
uint32_t numbits);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief send a serie of clock cycle with constant TMS and TDI
|
* \brief send a serie of clock cycle with constant TMS and TDI
|
||||||
* \param[in] tms: tms state
|
* \param[in] tms: tms state
|
||||||
|
|
@ -88,16 +99,6 @@ class Jlink: public JtagInterface {
|
||||||
bool get_result();
|
bool get_result();
|
||||||
bool max_mem_block(uint32_t *max_mem);
|
bool max_mem_block(uint32_t *max_mem);
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief test method to access ll_write outer this class
|
|
||||||
* \param[in] tms: tms buffer
|
|
||||||
* \param[in] tdi: tdi buffer
|
|
||||||
* \param[out] tdo: tdo buffer
|
|
||||||
* \param[in] numbits: tms/tdi/tdo buffer size (in bit)
|
|
||||||
*/
|
|
||||||
bool write_data(const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
|
|
||||||
uint16_t numbits);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Jlink EMU_CMD code
|
// Jlink EMU_CMD code
|
||||||
enum {
|
enum {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue