@@ -2629,6 +2629,201 @@ def jtag_flush(self):
2629
2629
"""
2630
2630
self ._dll .JLINKARM_WriteBits ()
2631
2631
2632
+ @interface_required (enums .JLinkInterfaces .JTAG )
2633
+ @open_required
2634
+ def jtag_store_instruction (self , instr , ir_len ):
2635
+ """Stores the specified JTAG instruction in the internal output buffer to
2636
+ be written to the instruction register of the JTAG device.
2637
+
2638
+ The necessary bits to place the TAP controller into the Shift-IR state
2639
+ are automatically added in order to form the complete command
2640
+ sequence for the given instruction.
2641
+
2642
+ Data in the output buffer is not flushed until TDO data is required, or
2643
+ ``jtag_sync_bits()`` or ``jtag_sync_bytes()`` is called.
2644
+
2645
+ Args:
2646
+ self (JLink): the ``JLink`` instance.
2647
+ instr (int): JTAG protocol command bits.
2648
+ ir_len (int): instruction register length.
2649
+
2650
+ Returns:
2651
+ Bit position in input buffer after instruction transmission.
2652
+ """
2653
+ buf = ctypes .c_uint8 (instr )
2654
+ return self ._dll .JLINKARM_JTAG_StoreInst (ctypes .byref (buf ), ir_len )
2655
+
2656
+ @interface_required (enums .JLinkInterfaces .JTAG )
2657
+ @open_required
2658
+ def jtag_store_data (self , data , dr_len ):
2659
+ """Stores the specified JTAG data in the internal output buffer to be
2660
+ written to the data register of the JTAG device.
2661
+
2662
+ The necessary bits to place the TAP controller into the Shift-DR state
2663
+ are automatically added in order to form a complete data transmission.
2664
+
2665
+ Data in the output buffer is not flushed until TDO data is required, or
2666
+ ``jtag_sync_bits()`` or ``jtag_sync_bytes()`` is called.
2667
+
2668
+ Args:
2669
+ self (JLink): the ``JLink`` instance.
2670
+ data (list): list of bits to transfer.
2671
+ dr_len (int): data register length.
2672
+
2673
+ Returns:
2674
+ Bit position in input buffer after instruction transmission.
2675
+
2676
+ Raises:
2677
+ TypeError: If passed data is not bytes or a list of integers.
2678
+ """
2679
+ buf = data
2680
+ if isinstance (buf , list ):
2681
+ 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 ))
2684
+
2685
+ return self ._dll .JLINKARM_JTAG_StoreData (buf , len (data ) * dr_len )
2686
+
2687
+ @interface_required (enums .JLinkInterfaces .JTAG )
2688
+ @connection_required
2689
+ def jtag_get_device_info (self , index = 0 ):
2690
+ """Retrieves the JTAG related information for the JTAG device on the scan chain.
2691
+
2692
+ Args:
2693
+ self (JLink): the ``JLink`` instance.
2694
+ index (int): index of the device on the scan chain.
2695
+
2696
+ Returns:
2697
+ A ``JLinkJTAGDeviceInfo`` describing the requested device.
2698
+
2699
+ Raises:
2700
+ ValueError: if index is less than 0 or >= number of devices on the scan chain.
2701
+ """
2702
+ if index < 0 :
2703
+ raise ValueError ('Invalid index provided, must be > 0.' )
2704
+
2705
+ info = structs .JLinkJTAGDeviceInfo ()
2706
+ res = self ._dll .JLINKARM_JTAG_GetDeviceInfo (index , ctypes .byref (info ))
2707
+ if res == - 1 :
2708
+ raise ValueError ('Invalid index provided, no device found.' )
2709
+
2710
+ info .DeviceId = self ._dll .JLINKARM_JTAG_GetDeviceId (index )
2711
+ return info
2712
+
2713
+ @interface_required (enums .JLinkInterfaces .JTAG )
2714
+ @open_required
2715
+ def jtag_read (self , offset , num_bits ):
2716
+ """Reads the specified number of bits from the JTAG input buffer.
2717
+
2718
+ Note:
2719
+ If there is data in the output buffer, then ``num_bits`` of data will
2720
+ be transmitted.
2721
+
2722
+ Args:
2723
+ self (JLink): the ``JLink`` instance.
2724
+ offset (int): bit position within the input buffer to read from.
2725
+ num_bits (int): total number of bits to read.
2726
+
2727
+ Returns:
2728
+ List of bytes containing the TDO data. This function may return more
2729
+ bytes than expected due to no context around the data size. The
2730
+ caller should pull bits as appopriate starting from the first returned
2731
+ byte.
2732
+ """
2733
+ # The smallest data length is 4 bits, so we use that as a divider. If
2734
+ # the data length is actually 7 and the user specifies 7, we will
2735
+ # return two integers, but that is fine, so the caller ultimately knows
2736
+ # the data length they need.
2737
+ buf_size = num_bits // 4
2738
+ if (num_bits % 4 ) > 0 :
2739
+ buf_size += 1
2740
+ buf = (ctypes .c_uint8 * buf_size )()
2741
+ self ._dll .JLINKARM_JTAG_GetData (ctypes .byref (buf ), offset , num_bits )
2742
+ return list (buf )
2743
+
2744
+ @interface_required (enums .JLinkInterfaces .JTAG )
2745
+ @open_required
2746
+ def jtag_read8 (self , offset ):
2747
+ """Reads a 8-bit integer from the JTAG input buffer.
2748
+
2749
+ Note:
2750
+ If there is data in the output buffer, this function will force a
2751
+ transmission.
2752
+
2753
+ Args:
2754
+ self (JLink): the ``JLink`` instance.
2755
+ offset (int): bit position within the input buffer to read from.
2756
+
2757
+ Returns:
2758
+ The read 8-bit integer from the input buffer.
2759
+ """
2760
+ return self ._dll .JLINKARM_JTAG_GetU8 (offset )
2761
+
2762
+ @interface_required (enums .JLinkInterfaces .JTAG )
2763
+ @open_required
2764
+ def jtag_read16 (self , offset ):
2765
+ """Reads a 16-bit integer from the JTAG input buffer.
2766
+
2767
+ Note:
2768
+ If there is data in the output buffer, this function will force a
2769
+ transmission.
2770
+
2771
+ Args:
2772
+ self (JLink): the ``JLink`` instance.
2773
+ offset (int): bit position within the input buffer to read from.
2774
+
2775
+ Returns:
2776
+ The read 16-bit integer from the input buffer.
2777
+ """
2778
+ return self ._dll .JLINKARM_JTAG_GetU16 (offset )
2779
+
2780
+ @interface_required (enums .JLinkInterfaces .JTAG )
2781
+ @open_required
2782
+ def jtag_read32 (self , offset ):
2783
+ """Reads a 32-bit integer from the JTAG input buffer.
2784
+
2785
+ Note:
2786
+ If there is data in the output buffer, this function will force a
2787
+ transmission.
2788
+
2789
+ Args:
2790
+ self (JLink): the ``JLink`` instance.
2791
+ offset (int): bit position within the input buffer to read from.
2792
+
2793
+ Returns:
2794
+ The read 32-bit integer from the input buffer.
2795
+ """
2796
+ return self ._dll .JLINKARM_JTAG_GetU32 (offset )
2797
+
2798
+ @interface_required (enums .JLinkInterfaces .JTAG )
2799
+ @open_required
2800
+ def jtag_sync_bits (self ):
2801
+ """Flushes the internal output buffer to the JTAG device.
2802
+
2803
+ Args:
2804
+ self (JLink): the ``JLink`` instance.
2805
+
2806
+ Returns:
2807
+ ``None``
2808
+ """
2809
+ self ._dll .JLINKARM_JTAG_SyncBits ()
2810
+
2811
+ @interface_required (enums .JLinkInterfaces .JTAG )
2812
+ @open_required
2813
+ def jtag_sync_bytes (self ):
2814
+ """Flushes the data content in the internal output buffer to the JTAG device.
2815
+
2816
+ This function will add the necessary bits to ensure the transmitted
2817
+ data is byte-aligned.
2818
+
2819
+ Args:
2820
+ self (JLink): the ``JLink`` instance.
2821
+
2822
+ Returns:
2823
+ ``None``
2824
+ """
2825
+ self ._dll .JLINKARM_JTAG_SyncBytes ()
2826
+
2632
2827
@interface_required (enums .JLinkInterfaces .SWD )
2633
2828
@connection_required
2634
2829
def swd_read8 (self , offset ):
0 commit comments