@@ -3193,6 +3193,88 @@ def memory_write64(self, addr, data, zone=None):
31933193 words .append ((long_word >> 32 ) & bitmask ) # First 32-bits
31943194 return self .memory_write32 (addr , words , zone = zone )
31953195
3196+ @connection_required
3197+ def peripheral_write8 (self , addr , value ):
3198+ """Writes byte to peripheral register of target system.
3199+
3200+ Args:
3201+ self (JLink): the ``JLink`` instance
3202+ addr (int): start address to write to
3203+ value (int): the value to write to the register
3204+
3205+ Returns:
3206+ The value written to the register.
3207+
3208+ Raises:
3209+ JLinkException: on write error.
3210+ """
3211+ res = self ._dll .JLINKARM_WriteU8 (addr , value )
3212+ if res != 0 :
3213+ raise errors .JLinkWriteException ('Error writing to %d' % addr )
3214+ return value
3215+
3216+ @connection_required
3217+ def peripheral_write16 (self , addr , value ):
3218+ """Writes half-word to peripheral register of target system.
3219+
3220+ Args:
3221+ self (JLink): the ``JLink`` instance
3222+ addr (int): start address to write to
3223+ value (int): the value to write to the register
3224+
3225+ Returns:
3226+ The value written to the register.
3227+
3228+ Raises:
3229+ JLinkException: on write error.
3230+ """
3231+ res = self ._dll .JLINKARM_WriteU16 (addr , value )
3232+ if res != 0 :
3233+ raise errors .JLinkWriteException ('Error writing to %d' % addr )
3234+ return value
3235+
3236+ @connection_required
3237+ def peripheral_write32 (self , addr , value ):
3238+ """Writes word to peripheral register of target system.
3239+
3240+ Args:
3241+ self (JLink): the ``JLink`` instance
3242+ addr (int): start address to write to
3243+ value (int): the value to write to the register
3244+
3245+ Returns:
3246+ The value written to the register.
3247+
3248+ Raises:
3249+ JLinkException: on write error.
3250+ """
3251+ res = self ._dll .JLINKARM_WriteU32 (addr , value )
3252+ if res != 0 :
3253+ raise errors .JLinkWriteException ('Error writing to %d' % addr )
3254+ return value
3255+
3256+ @connection_required
3257+ def peripheral_write64 (self , addr , value ):
3258+ """Writes long word to peripheral register of target system.
3259+
3260+ Args:
3261+ self (JLink): the ``JLink`` instance
3262+ addr (int): start address to write to
3263+ value (long): the value to write to the register
3264+
3265+ Returns:
3266+ The value written to the register.
3267+
3268+ Raises:
3269+ JLinkException: on write error.
3270+ """
3271+ # Default type is uint32_t,so specify the parameter type of the C function, otherwise get "ArgumentError"
3272+ self ._dll .JLINKARM_WriteU64 .argtypes = [ctypes .c_uint32 , ctypes .c_uint64 ]
3273+ res = self ._dll .JLINKARM_WriteU64 (addr , value )
3274+ if res != 0 :
3275+ raise errors .JLinkWriteException ('Error writing to %d' % addr )
3276+ return value
3277+
31963278 @connection_required
31973279 def register_read (self , register_index ):
31983280 """Reads the value from the given register.
0 commit comments