Beispiel #1
0
def test_fw_1():
    cc = AvrGcc(mcu=mcu)
    cc.build('int main(){}')
    fw = Firmware(cc.output)

    avr = Avr(mcu=mcu, firmware=fw, f_cpu=8000000)
    eq_(avr.f_cpu, 8000000)
    eq_(avr.mcu, 'atmega48')
Beispiel #2
0
def test_background_thread():
    cc = AvrGcc(mcu=mcu)
    cc.build('int main(){}')
    fw = Firmware(cc.output)
    avr = Avr(mcu=mcu, firmware=fw, f_cpu=8000000)    
    eq_(avr.state, cpu_Running, "mcu is not running")
    avr.goto_cycle(100)
    eq_(avr.state, cpu_Running, "mcu is not running")
    avr.terminate()
Beispiel #3
0
def test_background_thread():
    cc = AvrGcc(mcu=mcu)
    cc.build('int main(){}')
    fw = Firmware(cc.output)
    avr = Avr(mcu=mcu, firmware=fw, f_cpu=8000000)
    eq_(avr.state, cpu_Running, "mcu is not running")
    avr.goto_cycle(100)
    eq_(avr.state, cpu_Running, "mcu is not running")
    avr.terminate()
Beispiel #4
0
def test_headers():
    cc = AvrGcc()
    cc.build(
        '''
    #include "x.h"
    int main()
    {
    return DEF;
    }
    ''', {'x.h': '#define DEF 3'})
Beispiel #5
0
def test_fw_1():
    cc = AvrGcc(mcu=mcu)
    cc.build('int main(){}')
    fw = Firmware(cc.output)

    avr = Avr(mcu=mcu, firmware=fw, f_cpu=8000000)
    eq_(avr.f_cpu, 8000000)
    eq_(avr.frequency, avr.f_cpu)
    eq_(avr.mcu, 'atmega48')
    avr.terminate()
Beispiel #6
0
def test_fw_3():
    cc = AvrGcc(mcu=mcu)
    cc.build('int main(){}')
    fw = Firmware(cc.output)

    avr = Avr(mcu=mcu, f_cpu=8000000)
    avr.load_firmware(fw)
    eq_(avr.f_cpu, 8000000)
    eq_(avr.frequency, avr.f_cpu)
    eq_(avr.mcu, 'atmega48')
    avr.terminate()
Beispiel #7
0
def test_fcpu():
    cc = AvrGcc()
    cc.f_cpu = 1111
    cc.build('''
#include <util/delay.h>
#if( F_CPU != 1111)
#error F_CPU
#endif
int main ()
{
    long f = F_CPU;
}
    ''')
Beispiel #8
0
def test():
    cc = AvrGcc()
    assert len(cc.version()) > 0

    cc.build(cc.minprog)
    size = cc.size()
    assert size.program_bytes > 0
    assert size.program_percentage > 0

    eq_(size.data_bytes, 0)
    eq_(size.data_percentage, 0)

    cc.build('volatile int x=5; int main(){return x;}')
    size = cc.size()
    assert size.data_bytes > 0
    assert size.data_percentage > 0
Beispiel #9
0
def test_targets():
    cc = AvrGcc()
    assert len(cc.targets)
    for mcu in cc.targets:
        cc.mcu = mcu
        try:
            cc.build(cc.minprog)
            print('    program size = %s' % cc.size().program_bytes)
        except AvrGccCompileError:
            print('    compile error: %s' % cc.error_text.splitlines()[0])
Beispiel #10
0
'''
test minimum program size with different optimizations
'''

from pyavrutils import AvrGcc
from entrypoint2 import entrypoint

cc = AvrGcc()
code = 'int main(){}'


def test():
    print '    compiler option:', ' '.join(cc.options_generated())
    cc.build(code)
    print '    program size =', cc.size().program_bytes


@entrypoint
def main():
    print 'compiler version:', cc.version()
    print 'code:', code
    print
    print 'no optimizations::'
    print
    cc.optimize_no()
    test()
    print
    print 'optimize for size::'
    print
    cc.optimize_for_size()
    test()
Beispiel #11
0
def _create_avr(mcu, f_cpu, code):
    cc = AvrGcc(mcu=mcu)
    cc.build(code)
    fw = Firmware(cc.output)
    return Avr(mcu=mcu, firmware=fw, f_cpu=f_cpu)