~cdwilson/python-msp430-tools/fix-bug-936695

« back to all changes in this revision

Viewing changes to msp430/bsl/target/fcdprog.py

Merge specialized BSL scripts (for special BSL circuits) from Christopher Wilson

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# Copyright (c) 2012 Christopher Wilson <cwilson@cdwilson.us>
 
5
# All Rights Reserved.
 
6
# Simplified BSD License (see LICENSE.txt for full text)
 
7
 
 
8
from msp430.bsl.target import SerialBSLTarget
 
9
 
 
10
 
 
11
class FCDProgTarget(SerialBSLTarget):
 
12
    """\
 
13
    Flying Camp Design MSP430 BSL Programmer target
 
14
    
 
15
    http://www.flyingcampdesign.com
 
16
    """
 
17
    
 
18
    def __init__(self):
 
19
        SerialBSLTarget.__init__(self)
 
20
 
 
21
    def add_extra_options(self):
 
22
        SerialBSLTarget.add_extra_options(self)
 
23
 
 
24
        # by default, invert TEST/TCK
 
25
        if self.parser.has_option("--invert-test"):
 
26
            option = self.parser.get_option("--invert-test")
 
27
            option.action = "store_false"
 
28
            option.default = True
 
29
            option.help = "do not invert RTS line (default inverted)"
 
30
            group = self.parser.get_option_group("--invert-test")
 
31
            self.parser.remove_option("--invert-test")
 
32
            group.add_option(option)
 
33
 
 
34
        # by default, invert RST
 
35
        if self.parser.has_option("--invert-reset"):
 
36
            option = self.parser.get_option("--invert-reset")
 
37
            option.action = "store_false"
 
38
            option.default = True
 
39
            option.help = "do not invert DTR line (default inverted)"
 
40
            group = self.parser.get_option_group("--invert-reset")
 
41
            self.parser.remove_option("--invert-reset")
 
42
            group.add_option(option)
 
43
 
 
44
        # by default, swap TEST/TCK and RST
 
45
        if self.parser.has_option("--swap-reset-test"):
 
46
            option = self.parser.get_option("--swap-reset-test")
 
47
            option.action = "store_false"
 
48
            option.default = True
 
49
            option.help = "do not exchange RST and TEST signals (DTR/RTS) (default swapped)"
 
50
            group = self.parser.get_option_group("--swap-reset-test")
 
51
            self.parser.remove_option("--swap-reset-test")
 
52
            group.add_option(option)
 
53
 
 
54
        # by default, use 38400 baud
 
55
        if self.parser.has_option("--speed"):
 
56
            option = self.parser.get_option("--speed")
 
57
            option.default = 38400
 
58
            option.help = "change baud rate (default %s)" % option.default
 
59
            group = self.parser.get_option_group("--speed")
 
60
            self.parser.remove_option("--speed")
 
61
            group.add_option(option)
 
62
 
 
63
 
 
64
def main():
 
65
    # run the main application
 
66
    bsl_target = FCDProgTarget()
 
67
    bsl_target.main()
 
68
 
 
69
if __name__ == '__main__':
 
70
    main()