⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spokepov.lss

📁 旋转16个LED灯控制程序
💻 LSS
📖 第 1 页 / 共 5 页
字号:
        
        switch (dynamicType & 0xF0) {
 5b0:	80 91 74 00 	lds	r24, 0x0074
 5b4:	99 27       	eor	r25, r25
 5b6:	80 7f       	andi	r24, 0xF0	; 240
 5b8:	90 70       	andi	r25, 0x00	; 0
 5ba:	80 31       	cpi	r24, 0x10	; 16
 5bc:	91 05       	cpc	r25, r1
 5be:	19 f0       	breq	.+6      	; 0x5c6 <main+0x54>
 5c0:	80 97       	sbiw	r24, 0x20	; 32
 5c2:	29 f0       	breq	.+10     	; 0x5ce <main+0x5c>
 5c4:	65 c0       	rjmp	.+202    	; 0x690 <main+0x11e>
           
          #ifdef DYNAMIC_REVCOUNT					// Rev counter compiled in?
            
            case 0x10:								// Rev counter
            
              tBytes = 4;							// number of bytes we'll move down below
 5c6:	94 e0       	ldi	r25, 0x04	; 4
              a.fPtr = (char *)dynamicREV;
 5c8:	c7 e6       	ldi	r28, 0x67	; 103
 5ca:	d0 e0       	ldi	r29, 0x00	; 0
              break;                                // gets put into dynamicBuffer in reverse order.
 5cc:	62 c0       	rjmp	.+196    	; 0x692 <main+0x120>
            
          #endif
            
          #ifdef DYNAMIC_RPM						// RPM counter compiled in?
            
            case 0x20:
            
              // CODE NOT YET OPTIMIZED FOR SPACE.
              
              // Initialize the RPM counter to 0
              
              dynamicRPM[0]=dynamicRPM[1]=dynamicRPM[2] = '0';
 5ce:	80 e3       	ldi	r24, 0x30	; 48
 5d0:	80 93 65 00 	sts	0x0065, r24
 5d4:	80 91 65 00 	lds	r24, 0x0065
 5d8:	80 93 64 00 	sts	0x0064, r24
 5dc:	80 91 64 00 	lds	r24, 0x0064
 5e0:	80 93 63 00 	sts	0x0063, r24
              
              // Get a copy of the TIMER1 value that we need to divide 732 by
              
              a.divisor.word = OCR1A;
 5e4:	ca b5       	in	r28, 0x2a	; 42
 5e6:	db b5       	in	r29, 0x2b	; 43
              
              // Start out pointing to the SECOND element of the div732 array.
              // We need to set to the second one because the min value of the
              // OCR1A hibyte (max speed) is 01, and we'll do at most 7 shifts
              // before we see a bit.  But there are 8 bits after that that
              // might get looked at, so the div732 table must be 8 entries long.
              // We also add 2 so that we are pointing at the last byte of each
              // entry.
              
              b.divTable = (char *)(div732+5);				// 3 bytes per entry
 5e8:	ab e2       	ldi	r26, 0x2B	; 43
 5ea:	b0 e0       	ldi	r27, 0x00	; 0
              
              // Shift the divisor to the left and the divtable pointer to the
              // right until the high bit of the divisor is set
              
              while (a.divisor.bytes.high_byte < 0x80) {
               
                a.divisor.word = a.divisor.word << 1;
                b.divTable = b.divTable + 3;
 5ec:	d7 fd       	sbrc	r29, 7
 5ee:	04 c0       	rjmp	.+8      	; 0x5f8 <main+0x86>
 5f0:	cc 0f       	add	r28, r28
 5f2:	dd 1f       	adc	r29, r29
 5f4:	13 96       	adiw	r26, 0x03	; 3
 5f6:	fa cf       	rjmp	.-12     	; 0x5ec <main+0x7a>
                 
              }
              
              // Once we have found the high bit, that tells us the fastest
              // the device could possibly be rotating.  Any other set bits in
              // a.divisor mean that the RPM is lower.  So what we do is clear
              // the high bit and add in our partial sums only when the bits
              // in the remainder are ** 0 **.  Since we just cleared the
              // high bit, it'll get counted.  If all the bits are zero, all
              // the sums will be added.
                    
              // NOTE: could be made smaller by using a.divisor.bytes.high_byte
              // below, sacrificing a bit of accuracy at very high speeds.
              
              a.divisor.word = a.divisor.word & 0x7FFF;
 5f8:	df 77       	andi	r29, 0x7F	; 127
              
              while (b.divTable > div732) {
              
                if (a.divisor.bytes.high_byte < 0x80) {
                
                  // Add in the least significant bit.  Since the table is actual
                  // byte values, we don't need to deal with an ascii conversion
                
                  dynamicRPM[0] = dynamicRPM[0] + pgm_read_byte(b.divTable--);

                  if (dynamicRPM[0] > '9') {
                    dynamicRPM[0] = dynamicRPM[0] - 10;
                    dynamicRPM[1]++;
                  }
                
                  // repeat for second byte...
                
                  dynamicRPM[1] = dynamicRPM[1] + pgm_read_byte(b.divTable--);

                  if (dynamicRPM[1] > '9') {
                    dynamicRPM[1] = dynamicRPM[1] - 10;
                    dynamicRPM[2]++;
                  }
             
                  // and for third, but no carry needed this time
                
                  dynamicRPM[2] = dynamicRPM[2] + pgm_read_byte(b.divTable--);

				  // At this point, we've already subtracted 3 from b.divTable, so we're
				  // ready to go for the next loop.
				
				} else {
				
				  // But if we didn't add anything in, we need to shift b.divTable
				  
				  b.divTable = b.divTable - 3;
				  
				}
				
				// And finally move to the next bit
				
				a.divisor.word = a.divisor.word << 1;				
 5fa:	80 e0       	ldi	r24, 0x00	; 0
 5fc:	a6 32       	cpi	r26, 0x26	; 38
 5fe:	b8 07       	cpc	r27, r24
 600:	09 f0       	breq	.+2      	; 0x604 <main+0x92>
 602:	08 f4       	brcc	.+2      	; 0x606 <main+0x94>
 604:	41 c0       	rjmp	.+130    	; 0x688 <main+0x116>
 606:	d7 fd       	sbrc	r29, 7
 608:	3b c0       	rjmp	.+118    	; 0x680 <main+0x10e>
 60a:	fb 2f       	mov	r31, r27
 60c:	ea 2f       	mov	r30, r26
 60e:	11 97       	sbiw	r26, 0x01	; 1
 610:	c8 95       	lpm
 612:	90 2d       	mov	r25, r0
 614:	80 91 63 00 	lds	r24, 0x0063
 618:	89 0f       	add	r24, r25
 61a:	80 93 63 00 	sts	0x0063, r24
 61e:	80 91 63 00 	lds	r24, 0x0063
 622:	8a 33       	cpi	r24, 0x3A	; 58
 624:	50 f0       	brcs	.+20     	; 0x63a <main+0xc8>
 626:	80 91 63 00 	lds	r24, 0x0063
 62a:	8a 50       	subi	r24, 0x0A	; 10
 62c:	80 93 63 00 	sts	0x0063, r24
 630:	80 91 64 00 	lds	r24, 0x0064
 634:	8f 5f       	subi	r24, 0xFF	; 255
 636:	80 93 64 00 	sts	0x0064, r24
 63a:	fb 2f       	mov	r31, r27
 63c:	ea 2f       	mov	r30, r26
 63e:	11 97       	sbiw	r26, 0x01	; 1
 640:	c8 95       	lpm
 642:	90 2d       	mov	r25, r0
 644:	80 91 64 00 	lds	r24, 0x0064
 648:	89 0f       	add	r24, r25
 64a:	80 93 64 00 	sts	0x0064, r24
 64e:	80 91 64 00 	lds	r24, 0x0064
 652:	8a 33       	cpi	r24, 0x3A	; 58
 654:	50 f0       	brcs	.+20     	; 0x66a <main+0xf8>
 656:	80 91 64 00 	lds	r24, 0x0064
 65a:	8a 50       	subi	r24, 0x0A	; 10
 65c:	80 93 64 00 	sts	0x0064, r24
 660:	80 91 65 00 	lds	r24, 0x0065
 664:	8f 5f       	subi	r24, 0xFF	; 255
 666:	80 93 65 00 	sts	0x0065, r24
 66a:	fb 2f       	mov	r31, r27
 66c:	ea 2f       	mov	r30, r26
 66e:	11 97       	sbiw	r26, 0x01	; 1
 670:	c8 95       	lpm
 672:	90 2d       	mov	r25, r0
 674:	80 91 65 00 	lds	r24, 0x0065
 678:	89 0f       	add	r24, r25
 67a:	80 93 65 00 	sts	0x0065, r24
 67e:	01 c0       	rjmp	.+2      	; 0x682 <main+0x110>
 680:	13 97       	sbiw	r26, 0x03	; 3
 682:	cc 0f       	add	r28, r28
 684:	dd 1f       	adc	r29, r29
 686:	b9 cf       	rjmp	.-142    	; 0x5fa <main+0x88>
								
			  }
			  
			  // And when that's all done, we just set up for the move
			  
			  tBytes = 3;
 688:	93 e0       	ldi	r25, 0x03	; 3
			  a.fPtr = (char *)dynamicRPM;
 68a:	c3 e6       	ldi	r28, 0x63	; 99
 68c:	d0 e0       	ldi	r29, 0x00	; 0
              
              break;
 68e:	01 c0       	rjmp	.+2      	; 0x692 <main+0x120>
              
          #endif
            
          default:								// This will get executed if no dynamic data
            tBytes = 0x00;						// and will clear things.
 690:	90 e0       	ldi	r25, 0x00	; 0
               
        }
          
        // If we have bytes to transfer, and if the dynamic display
        // is still active, then transfer the bytes into the display
           
        cli();
 692:	f8 94       	cli
           
        if ( (dynamicType != 0x00) && (tBytes != 0x00) ) {
 694:	80 91 74 00 	lds	r24, 0x0074
 698:	88 23       	and	r24, r24
 69a:	59 f0       	breq	.+22     	; 0x6b2 <main+0x140>
 69c:	99 23       	and	r25, r25
 69e:	49 f0       	breq	.+18     	; 0x6b2 <main+0x140>
           
          b.tPtr = (char *)dynamicPtr;			// we now know dynamicPtr is valid
 6a0:	a0 91 75 00 	lds	r26, 0x0075
 6a4:	b0 91 76 00 	lds	r27, 0x0076
           
          // Remember, dynamicPtr points to the last byte, so we
          // copy bass ackwards!
             
          for(;tBytes>0;tBytes--) {
            *b.tPtr-- = *a.fPtr++;
 6a8:	89 91       	ld	r24, Y+
 6aa:	8c 93       	st	X, r24
 6ac:	11 97       	sbiw	r26, 0x01	; 1
 6ae:	91 50       	subi	r25, 0x01	; 1
 6b0:	d9 f7       	brne	.-10     	; 0x6a8 <main+0x136>
          }
             
        }
           
        sei();
 6b2:	78 94       	sei
 6b4:	6a cf       	rjmp	.-300    	; 0x58a <main+0x18>

000006b6 <spi_transfer_n>:
// code space!

// Move n bits of data over the serial link

void spi_transfer_n(uint8_t c, uint8_t n) {
 6b6:	96 2f       	mov	r25, r22

  // Stuff the byte to transfer into the serial data register
  
  USIDR = c;
 6b8:	8f b9       	out	0x0f, r24	; 15
  
  // Set up the status register.  On each state transition of
  // the serial bus (up or down), the lower 4 bits will be
  // incremented - so twice per bit.  When that overflows,
  // the transfer is done.  So if they start out as 0, 8
  // bits get moved.  But if you start it out at a different
  // value, you can move an arbitrary number of bits
  
  USISR = _BV(USIOIF) | (16 - (n<<1));
 6ba:	99 0f       	add	r25, r25
 6bc:	80 e1       	ldi	r24, 0x10	; 16
 6be:	89 1b       	sub	r24, r25
 6c0:	80 64       	ori	r24, 0x40	; 64
 6c2:	8e b9       	out	0x0e, r24	; 14

  // While the transfer has not finished
  
  while ( (USISR & _BV(USIOIF)) == 0) {

    // Send out another bit
    
    USICR = _BV(USIWM0) | _BV(USICS1) | _BV(USICLK) | _BV(USITC);
 6c4:	76 99       	sbic	0x0e, 6	; 14
 6c6:	04 c0       	rjmp	.+8      	; 0x6d0 <spi_transfer_n+0x1a>
 6c8:	8b e1       	ldi	r24, 0x1B	; 27
 6ca:	8d b9       	out	0x0d, r24	; 13
 6cc:	76 9b       	sbis	0x0e, 6	; 14
 6ce:	fd cf       	rjmp	.-6      	; 0x6ca <spi_transfer_n+0x14>
 6d0:	08 95       	ret

000006d2 <spi_transfer>:
    //NOP;  // slow down so that the eeprom isnt overwhelmed

  }

}

// Move 4 bytes over the serial link (to the 1K/4K EEPROM or the
// LED shift registers, or both!).  This code does things "blind",
// clocking 16 times, to transfer the data as fast as possible.

void spi_transfer(uint8_t c) {

  USIDR = c;
 6d2:	8f b9       	out	0x0f, r24	; 15
  USISR = _BV(USIOIF);
 6d4:	80 e4       	ldi	r24, 0x40	; 64
 6d6:	8e b9       	out	0x0e, r24	; 14

  while ( (USISR & _BV(USIOIF)) == 0) {

    USICR = _BV(USIWM0) | _BV(USICS1) | _BV(USICLK) | _BV(USITC);
 6d8:	76 99       	sbic	0x0e, 6	; 14
 6da:	04 c0       	rjmp	.+8      	; 0x6e4 <spi_transfer+0x12>
 6dc:	8b e1       	ldi	r24, 0x1B	; 27
 6de:	8d b9       	out	0x0d, r24	; 13
 6e0:	76 9b       	sbis	0x0e, 6	; 14
 6e2:	fd cf       	rjmp	.-6      	; 0x6de <spi_transfer+0xc>
 6e4:	08 95       	ret

000006e6 <spieeprom_read>:
    //NOP;  // slow down so that the eeprom isnt overwhelmed

  }

  // The byte read, if any, will be in USIDR
  
}

void spieeprom_read(uint16_t addr, uint8_t *buff, uint8_t len) {
 6e6:	ff 92       	push	r15
 6e8:	0f 93       	push	r16
 6ea:	1f 93       	push	r17
 6ec:	cf 93       	push	r28
 6ee:	df 93       	push	r29
 6f0:	08 2f       	mov	r16, r24
 6f2:	19 2f       	mov	r17, r25
 6f4:	d7 2f       	mov	r29, r23
 6f6:	c6 2f       	mov	r28, r22
 6f8:	f4 2e       	mov	r15, r20
  uint8_t i;

  SPIEE_CS_PORT &= ~_BV(SPIEE_CS); // pull CS low
 6fa:	c4 98       	cbi	0x18, 4	; 24
	...
  NOP; NOP; NOP; NOP;

  spi_transfer(SPI_EEPROM_READ);           // send READ command
 704:	83 e0       	ldi	r24, 0x03	; 3
 706:	e5 df       	rcall	.-54     	; 0x6d2 <spi_transfer>
  spi_transfer(addr >> 8);                 // send high addr 
 708:	81 2f       	mov	r24, r17
 70a:	99 27       	eor	r25, r25
 70c:	e2 df       	rcall	.-60     	; 0x6d2 <spi_transfer>
  spi_transfer(addr & 0xFF);               // send low addr
 70e:	80 2f       	mov	r24, r16
 710:	e0 df       	rcall	.-64     	; 0x6d2 <spi_transfer>

  for (i=0; i<len; i++)	{				   // read in the right number of
 712:	00 e0       	ldi	r16, 0x00	; 0
 714:	0f 15       	cp	r16, r15
 716:	30 f4       	brcc	.+12     	; 0x724 <spieeprom_read+0x3e>
    spi_transfer(0);					   // bits, then move to buff[]
 718:	80 e0       	ldi	r24, 0x00	; 0
 71a:	db df       	rcall	.-74     	; 0x6d2 <spi_transfer>
    buff[i] = USIDR;
 71c:	8f b1       	in	r24, 0x0f	; 15
 71e:	89 93       	st	Y+, r24
 720:	0f 5f       	subi	r16, 0xFF	; 255
 722:	f8 cf       	rjmp	.-16     	; 0x714 <spieeprom_read+0x2e>
  }

  SPIEE_CS_PORT |= _BV(SPIEE_CS);      // pull CS high
 724:	c4 9a       	sbi	0x18, 4	; 24
 726:	df 91       	pop	r29
 728:	cf 91       	pop	r28
 72a:	1f 91       	pop	r17
 72c:	0f 91       	pop	r16
 72e:	ff 90       	pop	r15
 730:	08 95       	ret

00000732 <memcpy_P>:
 732:	e6 2f       	mov	r30, r22
 734:	f7 2f       	mov	r31, r23
 736:	a8 2f       	mov	r26, r24
 738:	b9 2f       	mov	r27, r25
 73a:	03 c0       	rjmp	.+6      	; 0x742 <memcpy_P+0x10>
 73c:	c8 95       	lpm
 73e:	31 96       	adiw	r30, 0x01	; 1
 740:	0d 92       	st	X+, r0
 742:	41 50       	subi	r20, 0x01	; 1
 744:	50 40       	sbci	r21, 0x00	; 0
 746:	d0 f7       	brcc	.-12     	; 0x73c <memcpy_P+0xa>
 748:	08 95       	ret

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -