<commit_before># Parallel JTAG programmer for the MSP430 embedded proccessor.
#
# (C) 2002-2004 <NAME> <<EMAIL>>
# this is distributed under a free software license, see license.txt
#
# http://mspgcc.sf.net
#
# Requires Python 2+ and the binary extension _parjtag or ctypes
# and MSP430mspgcc.dll/libMSP430mspgcc.so and HIL.dll/libHIL.so
#
# $Id: jtag.py,v 1.9 2005/06/14 10:15:26 cliechti Exp $

import sys

#erase modes
ERASE_SEGMENT = 0       #Erase a segment.
ERASE_MAIN    = 1       #Erase all MAIN memory.
ERASE_ALL     = 2       #Erase all MAIN and INFORMATION memory.

#Configurations of the MSP430 driver
VERIFICATION_MODE = 0   #Verify data downloaded to FLASH memories.
RAMSIZE_OPTION    = 1   #Change RAM used to download and program flash blocks
DEBUG_OPTION      = 2   #Set debug level. Enables debug outputs.
FLASH_CALLBACK    = 3   #Set a callback for progress report during flash write void f(WORD count, WORD total)

#reset methods
PUC_RESET = 1 << 0      #Power up clear (i.e., a "soft") reset.
RST_RESET = 1 << 1      #RST/NMI (i.e., "hard") reset.
VCC_RESET = 1 << 2      #Cycle Vcc (i.e., a "power on") reset.
ALL_RESETS = PUC_RESET + RST_RESET + VCC_RESET

DEBUG = 0

#exceptions
class JTAGException(Exception): pass

#1st try the ctypes implementation, if thats not available try to use the C extension
try:
    import ctypes
except ImportError:
    try:
        import _parjtag
    except ImportError:
        raise ImportError("Can't find neither _parjtag nor ctypes. No JTAG backend available.")
    else:
        backend = "_parjtag so/dll"
else:
    backend = "ctypes"
    
    STATUS_OK   = 0
    TRUE        = 1
    FALSE       = 0
    WRITE       = 0
    READ        = 1
    if sys.platform == 'win32':
        MSP430mspgcc = ctypes.windll.MSP430mspgcc
    else:
        MSP430mspgcc = ctypes.cdll.MSP430mspgcc
    
    MSP430_Initialize               = MSP430mspgcc.MSP430_Initialize
    MSP430_Initialize.argtypes      = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_long)]
    MSP430_Initialize.restype       = ctypes.c_int
    try:
        MSP430_Open                     = MSP430mspgcc.MSP430_Open
        MSP430_Open.argtypes            = []
        MSP430_Open.restype             = ctypes.c_int
    except AttributeError:
        if DEBUG:
            sys.stderr.write('MSP430_Open not found in library, using dummy.\n')
        #TI's USB-FET lib does not have this function
        def MSP430_Open():
            return STATUS_OK
    MSP430_Close                    = MSP430mspgcc.MSP430_Close
    MSP430_Close.argtypes           = [ctypes.c_long]
    MSP430_Close.restype            = ctypes.c_int
    MSP430_Configure                = MSP430mspgcc.MSP430_Configure
    MSP430_Configure.argtypes       = [ctypes.c_long, ctypes.c_long]
    MSP430_Configure.restype        = ctypes.c_int
    MSP430_VCC                      = MSP430mspgcc.MSP430_VCC
    MSP430_VCC.argtypes             = [ctypes.c_long]
    MSP430_VCC.restype              = ctypes.c_int
    MSP430_Reset                    = MSP430mspgcc.MSP430_Reset
    MSP430_Reset.argtypes           = [ctypes.c_long, ctypes.c_long, ctypes.c_long]<commit_msg>- make ctypes backend working on linux - location of libraries are passed in env variables<commit_after># Parallel JTAG programmer for the MSP430 embedded proccessor.
#
# (C) 2002-2004 <NAME> <<EMAIL>>
# this is distributed under a free software license, see license.txt
#
# http://mspgcc.sf.net
#
# Requires Python 2+ and the binary extension _parjtag or ctypes
# and MSP430mspgcc.dll/libMSP430mspgcc.so and HIL.dll/libHIL.so
#
# $Id: jtag.py,v 1.10 2005/09/25 02:30:44 cliechti Exp $

import sys

#erase modes
ERASE_SEGMENT = 0       #Erase a segment.
ERASE_MAIN    = 1       #Erase all MAIN memory.
ERASE_ALL     = 2       #Erase all MAIN and INFORMATION memory.

#Configurations of the MSP430 driver
VERIFICATION_MODE = 0   #Verify data downloaded to FLASH memories.
RAMSIZE_OPTION    = 1   #Change RAM used to download and program flash blocks
DEBUG_OPTION      = 2   #Set debug level. Enables debug outputs.
FLASH_CALLBACK    = 3   #Set a callback for progress report during flash write void f(WORD count, WORD total)

#reset methods
PUC_RESET = 1 << 0      #Power up clear (i.e., a "soft") reset.
RST_RESET = 1 << 1      #RST/NMI (i.e., "hard") reset.
VCC_RESET = 1 << 2      #Cycle Vcc (i.e., a "power on") reset.
ALL_RESETS = PUC_RESET + RST_RESET + VCC_RESET

DEBUG = 0

#exceptions
class JTAGException(Exception): pass

#1st try the ctypes implementation, if thats not available try to use the C extension
try:
    import ctypes
except ImportError:
    try:
        import _parjtag
    except ImportError:
        raise ImportError("Can not find neither _parjtag nor ctypes. No JTAG backend available.")
    else:
        backend = "_parjtag so/dll"
else:
    backend = "ctypes"
    
    STATUS_OK   = 0
    TRUE        = 1
    FALSE       = 0
    WRITE       = 0
    READ        = 1
    if sys.platform == 'win32':
        MSP430mspgcc = ctypes.windll.MSP430mspgcc
    else:
        import os
        MSP430mspgcc = ctypes.cdll.LoadLibrary(os.path.join(os.environ['LIBMSPGCC_PATH'], 'libMSP430mspgcc.so'))
    
    MSP430_Initialize               = MSP430mspgcc.MSP430_Initialize
    MSP430_Initialize.argtypes      = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_long)]
    MSP430_Initialize.restype       = ctypes.c_int
    try:
        MSP430_Open                 = MSP430mspgcc.MSP430_Open
        MSP430_Open.argtypes        = []
        MSP430_Open.restype         = ctypes.c_int
    except AttributeError:
        if DEBUG:
            sys.stderr.write('MSP430_Open not found in library, using dummy.\n')
        #TI's USB-FET lib does not have this function
        def MSP430_Open():
            return STATUS_OK
    MSP430_Close                    = MSP430mspgcc.MSP430_Close
    MSP430_Close.argtypes           = [ctypes.c_long]
    MSP430_Close.restype            = ctypes.c_int
    MSP430_Configure                = MSP430mspgcc.MSP430_Configure
    MSP430_Configure.argtypes       = [ctypes.c_long, ctypes.c_long]
    MSP430_Configure.restype        = ctypes.c_int
    MSP430_VCC                      = MSP430mspgcc.MSP430_VCC
    MSP430_VCC.argtypes             = [ctypes.c_long]
    MSP430_VCC.restype              = ctypes.c_int
    MSP430_Reset                    = MSP430mspgcc.MSP430_Reset
    MSP430_Reset.argtypes           = [ctypes.c_long, ctypes.c_long, ctypes.c_long]
{'fraction_non_alphanumeric': 0.07812742210509999, 'fraction_numerical': 0.0509998449852736, 'mean_word_length': 2.3604166666666666, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4461457', 'n_tokens_mistral': 2473, 'n_tokens_neox': 2212, 'n_words': 571}