Changeset 56 in projects for punch-card/driver/documation-m200/src/driver.c
- Timestamp:
- Jan 1, 2010, 1:14:40 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
punch-card/driver/documation-m200/src/driver.c
r51 r56 25 25 case (1 << PINB_MOCK): name = "MOCK"; break; 26 26 case 0: 27 printf("Too lazy, but not "); // und jetzt nicht breaken :-)27 dprintf("Too lazy, but not "); // und jetzt nicht breaken :-) 28 28 default: 29 printf("Illegal PCINT1 raise: %x=>%x, %x, %x\n", status.prev_pinb, pinb_jetzt, pin_changed, rising_edge);29 dprintf("Illegal PCINT1 raise: %x=>%x, %x, %x\n", status.prev_pinb, pinb_jetzt, pin_changed, rising_edge); 30 30 status.prev_pinb = pinb_jetzt; 31 31 return; 32 32 } 33 33 34 printf("%s %s\n", name, rising_edge ? "raising" : "falling");34 dprintf("%s %s\n", name, rising_edge ? "raising" : "falling"); 35 35 36 36 status.prev_pinb = pinb_jetzt; … … 39 39 40 40 ISR(PCINT2_vect) { 41 // this routine is called for 42 // * PINC_IM : Index Mark (store current column) 41 // this routine is called for low speed lines 43 42 // * PINC_RDY : Ready (reader ready for new Pick Command) 44 43 // * PINC_BSY : Busy (card edge - there is a card) 44 // * no more: PINC_IM : Index Mark (store current column), now has an own interrupt line 45 45 // to find out what changed, we make a backup of the former 46 46 // PINC at the end of this routine. … … 59 59 if( check_pin(PINC, PINC_PC) ) { 60 60 // we have started already... 61 puts("READY rising, starting ASAP"); 61 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_READY M200_SERVER_SIGNAL_RISE 62 " already started\n"); 62 63 } else { 63 64 // check if there's space in the buffer to start up … … 69 70 // start. BSY signal will create new card. 70 71 start_reader(); 72 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_READY M200_SERVER_SIGNAL_RISE 73 " firing up\n"); 71 74 } 72 75 } 73 76 } 74 puts("READY rising"); 77 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_READY M200_SERVER_SIGNAL_RISE 78 " Ready rising, no specific action\n"); 75 79 } else { 76 80 // device is no more ready -- perhaps user shutdown (by button). 77 puts("READY falling"); 81 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_READY M200_SERVER_SIGNAL_FALL 82 " Ready falling\n"); 78 83 } 79 84 break; … … 85 90 if(card_buffer_write_advance() != SUCCESS) { 86 91 // No more space in buffer! VERY BAD! 87 puts("BUSY rising, LOOSING DATA!"); 88 } else 89 printf("BUSY rising, new card %d (reader: %d)\n", 90 card_buffer.write_offset, card_buffer.read_offset); 91 } else { 92 puts("BUSY rising, staying card"); 92 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_BUSY M200_SERVER_SIGNAL_RISE "\n"); 93 fatal_printf("No space! LOOSING DATA"); 94 } else { 95 info_printf(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_BUSY M200_SERVER_SIGNAL_RISE 96 "card %d (r=%d)\n", card_buffer.write_offset, card_buffer.read_offset); 97 } 98 } else { 99 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_BUSY M200_SERVER_SIGNAL_RISE 100 " staying card\n"); 93 101 } 94 102 } else { 95 puts("BSY falling"); 96 103 // BUSY falling. 97 104 // nochmal sicherheitshalber, wobei das sowieso viel zu spaet ist 98 105 if( !card_buffer_count_free() ) { 99 106 stop_reader(); 107 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_BUSY M200_SERVER_SIGNAL_FALL 108 " falling, buffer full\n"); 109 } else { 110 info_puts(M200_SERVER_SIGNAL_PREFIX M200_SERVER_SIGNAL_BUSY M200_SERVER_SIGNAL_FALL 111 " falling, OK\n"); 100 112 } 101 113 } … … 104 116 case 0: 105 117 // Signal lag zu kurz an 106 printf("Lost Interrupt, state %x ed=%x\n", pinc_jetzt, rising_edge);118 fatal_printf("Lost Interrupt, state %x ed=%x", pinc_jetzt, rising_edge); 107 119 break; 108 120 default: 109 121 // illegal intterupt! 110 printf("Illegal interrupt! PINC was %x is %x changed %x flanke %x\n",122 fatal_printf("Illegal interrupt! PINC was %x is %x changed %x flanke %x", 111 123 status.prev_pinc, pinc_jetzt, pin_changed, rising_edge); 112 124 break; … … 125 137 if( ! (PINC & (1 << PINC_BSY)) ) { 126 138 // die kann man verwerfen, keine Kartenkante 127 puts("IMS");139 dprintf("IMS"); 128 140 return; 129 141 } 130 142 143 // check for index bounds 131 144 if(current_write_card.offset < 0 || current_write_card.offset >= CARD_LEN ) { 132 puts("BAD card! Stopping reader"); 133 if(PINC & (1 << PORTC_PC)) { 134 puts("Reader wasnt stopped"); 145 if(is_reading()) { 146 fatal_printf("Reader was still running"); 135 147 } 136 148 stop_reader(); 149 // first do the work, then the lengthy error output 150 fatal_printf("BAD card! Stopping reader (current_write_card.offset=%d out of bounds)", current_write_card.offset); 137 151 return; 138 152 } … … 167 181 // finalize the current card 168 182 //current_write_card.offset = CARD_READY; // unnoetig, da CARD_READY == CARD_LEN 169 puts("wr++");183 dprintf("wr++"); 170 184 171 185 // try to create a new card … … 173 187 // no more space! turn off Punch Instruction! 174 188 stop_reader(); 175 puts("No more space on buffer.");189 dprintf("No more space on buffer. Waiting for space"); 176 190 status.reader_waits_for_space = 1; 177 191 } … … 181 195 182 196 // und Blinken darf er auch gerne :-) 183 if (PINB & 0b00000001) 184 start_led(); 185 else 186 stop_led(); 197 toggle_led(); 187 198 } 188 199 189 200 190 201 // Wird von Hauptschleife aufgerufen 191 void process_ buffer_queue(enum format_t out_format) {202 void process_card_buffer() { 192 203 // after handling user input, handle buffer 193 204 if( current_read_card.offset == CARD_READY ) { 194 printf("Karte in rd %d rw %d, cols rd %d rw %d\n", card_buffer.read_offset, card_buffer.write_offset,205 dprintf("Karte in rd %d rw %d, cols rd %d rw %d", card_buffer.read_offset, card_buffer.write_offset, 195 206 current_read_card.offset, current_write_card.offset); 196 207 … … 200 211 //break; // Karte NICHT komplett ausgeben. Hier stoppen. 201 212 202 print_card( out_format);213 print_card(); 203 214 204 215 … … 212 223 // Karte zu kommen 213 224 if( card_buffer_read_advance() != SUCCESS) { 214 puts("output waiting for next");225 dprintf("output waiting for next"); 215 226 } else { 216 puts("cr+");227 dprintf("cr+"); 217 228 } 218 229 … … 228 239 start_reader(); 229 240 } else { 230 puts("Deadline, writer waits for reader");241 fatal_printf("Deadline, writer waits for reader"); 231 242 } 232 243 }
Note: See TracChangeset
for help on using the changeset viewer.