File: unittest_io_pin.cpp

package info (click to toggle)
simulavr 1.0.0%2Bgit20160221.e53413b-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,748 kB
  • sloc: cpp: 35,491; python: 6,991; ansic: 3,567; makefile: 1,072; sh: 653; asm: 414; tcl: 320
file content (47 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
using namespace std;

#include "gtest.h"

#include "avrdevice.h"
#include "atmega128.h"
#include "systemclock.h"

#include "pin.h"

TEST( SESSION_IO_PIN, OPEN_DRAIN1 )
{
    AvrDevice *dev1= new AvrDevice_atmega128;
    dev1->Load("session_io_pin/tc1.atmega128.o");
    dev1->SetClockFreq(136);    // 7.3728
    dev1->RegisterTerminationSymbol("stopsim");
    SystemClock::Instance().Add(dev1);

    Net net;

    OpenDrain driveOpenDrain( dev1->GetPin("B2"));
    net.Add( &driveOpenDrain );

    net.Add( dev1->GetPin("B3"));    // read behind the open drain transistor circuit

    Pin extPullUp(Pin::PULLUP);  //create a pull up
    net.Add( &extPullUp );

    // set all other pins to defined value
    Net net2;
    net2.Add( dev1->GetPin("B0"));
    net2.Add( dev1->GetPin("B1"));
    net2.Add( dev1->GetPin("B4"));
    net2.Add( dev1->GetPin("B5"));
    net2.Add( dev1->GetPin("B6"));
    net2.Add( dev1->GetPin("B7"));

    Pin extPullDown(Pin::PULLDOWN); // create a pull down
    net2.Add( &extPullDown);


    SystemClock::Instance().Endless(); 

    EXPECT_EQ(0x08, (unsigned char)(*(dev1->rw[17]))) << "wrong value read back from PORTB R17" << endl;
    EXPECT_EQ(0x04, (unsigned char)(*(dev1->rw[18]))) << "wrong value read back from PORTB R18" << endl;
}