@@ -9,7 +9,7 @@ describe('GPIO', () => {
99 cpu . writeData ( 0x24 , 0x0f ) ; // DDRB <- 0x0f
1010 port . addListener ( listener ) ;
1111 cpu . writeData ( 0x25 , 0x55 ) ; // PORTB <- 0x55
12- expect ( listener ) . toHaveBeenCalledWith ( 0x05 , 0 ) ;
12+ expect ( listener ) . toHaveBeenCalledWith ( 0x55 , 0 ) ;
1313 expect ( cpu . data [ 0x23 ] ) . toEqual ( 0x5 ) ; // PINB should return port value
1414 } ) ;
1515
@@ -20,7 +20,16 @@ describe('GPIO', () => {
2020 cpu . writeData ( 0x25 , 0x55 ) ; // PORTB <- 0x55
2121 port . addListener ( listener ) ;
2222 cpu . writeData ( 0x24 , 0xf0 ) ; // DDRB <- 0xf0
23- expect ( listener ) . toHaveBeenCalledWith ( 0x50 , 0 ) ;
23+ expect ( listener ) . toHaveBeenCalledWith ( 0x55 , 0x55 ) ;
24+ } ) ;
25+
26+ it ( 'should invoke the listeners when pullup register enabled (issue #62)' , ( ) => {
27+ const cpu = new CPU ( new Uint16Array ( 1024 ) ) ;
28+ const port = new AVRIOPort ( cpu , portBConfig ) ;
29+ const listener = jest . fn ( ) ;
30+ port . addListener ( listener ) ;
31+ cpu . writeData ( 0x25 , 0x55 ) ; // PORTB <- 0x55
32+ expect ( listener ) . toHaveBeenCalledWith ( 0x55 , 0 ) ;
2433 } ) ;
2534
2635 it ( 'should toggle the pin when writing to the PIN register' , ( ) => {
@@ -31,7 +40,7 @@ describe('GPIO', () => {
3140 cpu . writeData ( 0x24 , 0x0f ) ; // DDRB <- 0x0f
3241 cpu . writeData ( 0x25 , 0x55 ) ; // PORTB <- 0x55
3342 cpu . writeData ( 0x23 , 0x01 ) ; // PINB <- 0x0f
34- expect ( listener ) . toHaveBeenCalledWith ( 0x04 , 0x5 ) ;
43+ expect ( listener ) . toHaveBeenCalledWith ( 0x54 , 0x55 ) ;
3544 expect ( cpu . data [ 0x23 ] ) . toEqual ( 0x4 ) ; // PINB should return port value
3645 } ) ;
3746
0 commit comments