📄 main.lst
字号:
154:main.c **** 0xFF,0x00,0xFF,0x00,0xFF,0x00, // 036 - same as 24, denser pattern 155:main.c **** 0x00,0xFF,0x00,0xFF,0x00,0xFF, // 042 - same as 30, denser pattern 156:main.c **** 0xF0,0xF0,0xF0,0xF0,0xF0,0xF0, // 048 - same as 24, even denser pattern 157:main.c **** 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F, // 054 - same as 30, even denser pattern 158:main.c **** 0xFF,0xFF,0xFF,0xF0,0xFF,0xFF, // 060 - single thin line, outside rim to middle 159:main.c **** 0xFF,0xF0,0xFF,0xFF,0xFF,0xFF, // 066 - single thin line, middle to inside rim 160:main.c **** 0x00,0x00,0x00,0x0F,0x00,0x00, // 072 - invert of 060, single black line 161:main.c **** 0x00,0x0F,0x00,0x00,0x00,0x00, // 078 - invert if 066, single white line 162:main.c **** 0xFF,0xFF,0xFF,0xFF,0x00,0x00, // 084 - all black, white shifting in 163:main.c **** 0x00,0x00,0x00,0x00,0xFF,0xFF, // 090 - all white, black shifting in. 164:main.c **** 165:main.c **** }; 166:main.c **** 167:main.c **** /* Array for the bitmaps we shift out to the LEDs, read in from patterns */ 168:main.c **** 169:main.c **** uint8_t cPattern[6]; // Current pattern 170:main.c **** 171:main.c **** // How many ~3ms delays (-1) must elapse before we consider 172:main.c **** // a subsequent hall-effect sensor interrupt to be valid? 173:main.c **** 174:main.c **** #define HALL_DEBOUNCE_THRESH 4 // ~15ms 175:main.c **** 176:main.c **** // How many msecs the button must be held down before it is 177:main.c **** // considered to be an actual button press. 178:main.c **** 179:main.c **** #define BUTTON_DEBOUNCE 10 180:main.c **** 181:main.c **** // How many pixels in a full rotation of the SpokePOV 182:main.c **** 183:main.c **** #define NUM_PIXELS 256 // max is 255 (since it is 8 bit value) 184:main.c **** 185:main.c **** // How long after the SpokePOV stops rotating will the display continue? 186:main.c **** 187:main.c **** #define STANDBY_TIMEOUT 5 // in seconds 188:main.c **** 189:main.c **** // How long until the SpokePOV goes into sleep mode. 190:main.c **** // NOTE: not actually used, it's hard-coded instead! 191:main.c **** 192:main.c **** #define POWEROFF_TIMEOUT 2*60 // in seconds 193:main.c **** 194:main.c **** // Internal EEPROM storage locations // not used in this app (yet) 195:main.c **** 196:main.c **** #define EEPROM_ROTATION_OFFSET 0x00 // rotation offset to compensate for magnet position 197:main.c **** #define EEPROM_MIRROR 0x01 // flag telling whether oppposite side LEDs are mirrored 198:main.c **** #define EEPROM_ANIMATION 0x02 // animation activation flag 199:main.c **** 200:main.c **** volatile uint8_t hall_debounce; // count (via TIMER0) since last *used* Hall Effect detection 201:main.c **** volatile var16bit sensor_timer; // count (via TIMER0) since last actual Hall Effect detection 202:main.c **** 203:main.c **** volatile uint8_t line_timer = SCROLLSPEED; // counter for scrolling/line stepping; realized it only 204:main.c **** 205:main.c **** volatile uint8_t cur_line = NUM_LINES-1; // the current 'top line' 206:main.c **** volatile uint8_t line_shift = 0x0f; // # of pixels extra shift we do to scroll smoothly 207:main.c **** volatile uint8_t cur_code = 0x06; // current display code 208:main.c **** 209:main.c **** volatile var16bit eeprom_addr; // bitmap eeprom address 210:main.c **** 211:main.c **** // Sends the 4-byte LED pixel data block out 212:main.c **** // over the serial link. Front LEDs only 213:main.c **** 214:main.c **** // Sends 4 bytes + sCount extra bits over the serial link 215:main.c **** // to implement smooth scrolling. Can be used with a 0 216:main.c **** // parameter to just send out the regular 4 bytes. 217:main.c **** 218:main.c **** void clock_scroll(uint8_t sCount) { 243 .LM1: 244 /* prologue: frame size=0 */ 245 0000 CF93 push r28 246 /* prologue end (size=1) */ 247 0002 C82F mov r28,r24 219:main.c **** 220:main.c **** // First, send the basic 4 bytes, they go no matter what 221:main.c **** 222:main.c **** spi_transfer(cPattern[0]); 249 .LM2: 250 0004 8091 0000 lds r24,cPattern 251 0008 00D0 rcall spi_transfer 223:main.c **** spi_transfer(cPattern[1]); 253 .LM3: 254 000a 8091 0000 lds r24,cPattern+1 255 000e 00D0 rcall spi_transfer 224:main.c **** spi_transfer(cPattern[2]); 257 .LM4: 258 0010 8091 0000 lds r24,cPattern+2 259 0014 00D0 rcall spi_transfer 225:main.c **** spi_transfer(cPattern[3]); 261 .LM5: 262 0016 8091 0000 lds r24,cPattern+3 263 001a 00D0 rcall spi_transfer 226:main.c **** 227:main.c **** // If there is anything to do.. 228:main.c **** 229:main.c **** if (sCount != 0) { 265 .LM6: 266 001c CC23 tst r28 267 001e 79F0 breq .L2 230:main.c **** 231:main.c **** // If we have < 8 bits to transfer 232:main.c **** 233:main.c **** if (sCount < 8) { 269 .LM7: 270 0020 C830 cpi r28,lo8(8) 271 0022 20F4 brsh .L3 234:main.c **** 235:main.c **** // Then that is all that we need to do 236:main.c **** 237:main.c **** spi_transfer_n(cPattern[4],sCount); 273 .LM8: 274 0024 6C2F mov r22,r28 275 0026 8091 0000 lds r24,cPattern+4 276 002a 08C0 rjmp .L6 277 .L3: 238:main.c **** 239:main.c **** } else { 240:main.c **** 241:main.c **** // First latch out the full first 8 bits 242:main.c **** 243:main.c **** spi_transfer(cPattern[4]); 279 .LM9: 280 002c 8091 0000 lds r24,cPattern+4 281 0030 00D0 rcall spi_transfer 244:main.c **** 245:main.c **** // How many bits left to do? 246:main.c **** 247:main.c **** sCount = sCount - 8; 283 .LM10: 284 0032 C850 subi r28,lo8(-(-8)) 248:main.c **** 249:main.c **** if (sCount != 0) { 286 .LM11: 287 0034 21F0 breq .L2 250:main.c **** 251:main.c **** spi_transfer_n(cPattern[5],sCount); 289 .LM12: 290 0036 6C2F mov r22,r28 291 0038 8091 0000 lds r24,cPattern+5 292 .L6: 293 003c 00D0 rcall spi_transfer_n 294 .L2: 252:main.c **** 253:main.c **** } 254:main.c **** 255:main.c **** } 256:main.c **** 257:main.c **** } 258:main.c **** 259:main.c **** // finally, latch the bits into the LEDS 260:main.c **** 261:main.c **** LATCH_SELECT_PORT |= _BV(FRONT); 296 .LM13: 297 003e 949A sbi 50-0x20,4 262:main.c **** NOP; NOP; NOP; NOP; 299 .LM14: 300 /* #APP */ 301 0040 0000 nop 302 0042 0000 nop 303 0044 0000 nop 304 0046 0000 nop 263:main.c **** LATCH_SELECT_PORT &= ~_BV(FRONT); 306 .LM15: 307 /* #NOAPP */ 308 0048 9498 cbi 50-0x20,4 309 /* epilogue: frame size=0 */ 310 004a CF91 pop r28 311 004c 0895 ret 312 /* epilogue end (size=2) */ 313 /* function clock_scroll size 44 (41) */ 315 .Lscope0: 319 .global set_all 321 set_all: 264:main.c **** 265:main.c **** } 266:main.c **** 267:main.c **** // Set all the LEDs on a side to have the same 268:main.c **** // repeating 8-bit value (ie: 0x00 = all on, 0xFF = all off) 269:main.c **** // Added by RJW to permit a more comprehensive reset display 270:main.c **** 271:main.c **** void set_all(uint8_t blockValue) { 323 .LM16: 324 /* prologue: frame size=0 */ 325 004e 1F93 push r17 326 /* prologue end (size=1) */ 327 0050 182F mov r17,r24 272:main.c **** 273:main.c **** spi_transfer(blockValue); 329 .LM17: 330 0052 00D0 rcall spi_transfer 274:main.c **** spi_transfer(blockValue); 332 .LM18: 333 0054 812F mov r24,r17 334 0056 00D0 rcall spi_transfer 275:main.c **** spi_transfer(blockValue); 336 .LM19: 337 0058 812F mov r24,r17 338 005a 00D0 rcall spi_transfer 276:main.c **** spi_transfer(blockValue); 340 .LM20: 341 005c 812F mov r24,r17 342 005e 00D0 rcall spi_transfer 277:main.c **** 278:main.c **** // finally, latch the bits into the LEDS 279:main.c **** 280:main.c **** LATCH_SELECT_PORT |= _BV(FRONT); 344 .LM21: 345 0060 949A sbi 50-0x20,4 281:main.c **** NOP; NOP; NOP; NOP; 347 .LM22: 348 /* #APP */ 349 0062 0000 nop 350 0064 0000 nop 351 0066 0000 nop 352 0068 0000 nop 282:main.c **** LATCH_SELECT_PORT &= ~_BV(FRONT); 354 .LM23: 355 /* #NOAPP */ 356 006a 9498 cbi 50-0x20,4 357 /* epilogue: frame size=0 */ 358 006c 1F91 pop r17 359 006e 0895 ret 360 /* epilogue end (size=2) */ 361 /* function set_all size 21 (18) */ 363 .Lscope1: 366 .global __vector_6 368 __vector_6: 283:main.c **** 284:main.c **** } 285:main.c **** 286:main.c **** // TIMER0 interrupt handler. This runs about every 8ms 287:main.c **** // AFAICT. It increments the hall_debounce and sensor_timer 288:main.c **** // values until they pin. 289:main.c **** 290:main.c **** // QUESTION: what's with the setting and clearing of PORTB0? 291:main.c **** // According to the wiring diagram, it isn't connected to 292:main.c **** // anything. Is this vestigial code from when you were using 293:main.c **** // Pin Change Interrupts? Or is it debugger code so you 294:main.c **** // can monitor the pins and tell when something happens. 295:main.c **** 296:main.c **** SIGNAL (SIG_TIMER0_OVF) { 370 .LM24: 371 /* prologue: frame size=0 */ 372 0070 1F92 push __zero_reg__ 373 0072 0F92 push __tmp_reg__ 374 0074 0FB6 in __tmp_reg__,__SREG__ 375 0076 0F92 push __tmp_reg__ 376 0078 1124 clr __zero_reg__ 377 007a 8F93 push r24 378 007c 9F93 push r25 379 /* prologue end (size=7) */ 297:main.c **** 298:main.c **** // Let hall_debounce just wrap around. At worst it'll just 299:main.c **** // mess things up for one of the initial speedup rotations 300:main.c **** // of the blade... 301:main.c **** 302:main.c **** // if (hall_debounce != 0xFF) 303:main.c **** 304:main.c **** hall_debounce++; 381 .LM25: 382 007e 8091 0000 lds r24,hall_debounce 383 0082 8F5F subi r24,lo8(-(1)) 384 0084 8093 0000 sts hall_debounce,r24 305:main.c **** 306:main.c **** if (sensor_timer.bytes.high_byte != 0xFF) 386 .LM26: 387 0088 8091 0000 lds r24,sensor_timer+1 388 008c 8F3F cpi r24,lo8(-1) 389 008e 49F0 breq .L9 307:main.c **** sensor_timer.word++; 391 .LM27: 392 0090 8091 0000 lds r24,sensor_timer 393 0094 9091 0000 lds r25,(sensor_timer)+1 394 0098 0196 adiw r24,1 395 009a 9093 0000 sts (sensor_timer)+1,r25 396 009e 8093 0000 sts sensor_timer,r24 397 .L9: 308:main.c **** 309:main.c **** #if NUM_LINES > 0 310:main.c **** 311:main.c **** // Increment the line timer - we only need to do this 312:main.c **** // if we are scrolling 313:main.c **** 314:main.c **** if (line_timer != 0xFF) { 399 .LM28: 400 00a2 8091 0000 lds r24,line_timer 401 00a6 8F3F cpi r24,lo8(-1) 402 00a8 29F0 breq .L8 315:main.c **** line_timer++; 404 .LM29: 405 00aa 8091 0000 lds r24,line_timer 406 00ae 8F5F subi r24,lo8(-(1)) 407 00b0 8093 0000 sts line_timer,r24 408 .L8: 409 /* epilogue: frame size=0 */ 410 00b4 9F91 pop r25 411 00b6 8F91 pop r24 412 00b8 0F90 pop __tmp_reg__ 413 00ba 0FBE out __SREG__,__tmp_reg__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -