@@ -2631,7 +2631,7 @@ def jtag_flush(self):
26312631
26322632 @interface_required (enums .JLinkInterfaces .JTAG )
26332633 @open_required
2634- def jtag_store_instruction (self , instr , num_bits ):
2634+ def jtag_store_instruction (self , instr , ir_len ):
26352635 """Stores the specified JTAG instruction in the internal output buffer to
26362636 be written to the instruction register of the JTAG device.
26372637
@@ -2645,17 +2645,17 @@ def jtag_store_instruction(self, instr, num_bits):
26452645 Args:
26462646 self (JLink): the ``JLink`` instance.
26472647 instr (int): JTAG protocol command bits.
2648- num_bits (int): Number of bits in the given instruction .
2648+ ir_len (int): instruction register length .
26492649
26502650 Returns:
26512651 Bit position in input buffer after instruction transmission.
26522652 """
26532653 buf = ctypes .c_uint8 (instr )
2654- return self ._dll .JLINKARM_JTAG_StoreInst (ctypes .byref (buf ), num_bits )
2654+ return self ._dll .JLINKARM_JTAG_StoreInst (ctypes .byref (buf ), ir_len )
26552655
26562656 @interface_required (enums .JLinkInterfaces .JTAG )
26572657 @open_required
2658- def jtag_store_data (self , data , num_bits ):
2658+ def jtag_store_data (self , data , dr_len ):
26592659 """Stores the specified JTAG data in the internal output buffer to be
26602660 written to the data register of the JTAG device.
26612661
@@ -2668,16 +2668,21 @@ def jtag_store_data(self, data, num_bits):
26682668 Args:
26692669 self (JLink): the ``JLink`` instance.
26702670 data (list): list of bits to transfer.
2671- num_bits (int): number of bits to to transfer per integer in ``data`` .
2671+ dr_len (int): data register length .
26722672
26732673 Returns:
26742674 Bit position in input buffer after instruction transmission.
2675+
2676+ Raises:
2677+ TypeError: If passed data is not bytes or a list of integers.
26752678 """
26762679 buf = data
26772680 if isinstance (buf , list ):
26782681 buf = bytes (buf )
2682+ elif not any (isinstance (buf , t ) for t in [bytes , bytearray ]):
2683+ raise TypeError ('Expected to be given bytes / list: given %s' % type (buf ))
26792684
2680- return self ._dll .JLINKARM_JTAG_StoreData (buf , len (data ) * num_bits )
2685+ return self ._dll .JLINKARM_JTAG_StoreData (buf , len (data ) * dr_len )
26812686
26822687 @interface_required (enums .JLinkInterfaces .JTAG )
26832688 @open_required
@@ -2730,7 +2735,7 @@ def jtag_read(self, offset, num_bits):
27302735 # return two integers, but that is fine, so the caller ultimately knows
27312736 # the data length they need.
27322737 buf_size = num_bits // 4
2733- if (buf_size % 4 ) > 0 :
2738+ if (num_bits % 4 ) > 0 :
27342739 buf_size += 1
27352740 buf = (ctypes .c_uint8 * buf_size )()
27362741 self ._dll .JLINKARM_JTAG_GetData (ctypes .byref (buf ), offset , num_bits )
0 commit comments