00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "Cpu.h"
00043 #include "Events.h"
00044 #include "database.h"
00045
00046
00047 #include "PE_Types.h"
00048 #include "PE_Error.h"
00049 #include "PE_Const.h"
00050 #include "IO_Map.h"
00051 #include "LCD_methods.h"
00052 #include "bitmaps.h"
00053 #include "UDP_Client_app.h"
00054 #include "ne64api.h"
00055 #include "ne64config.h"
00056 #include "ne64debug.h"
00057 #include "ne64driver.h"
00058 #include "mBuf.h"
00059 #include "debug.h"
00060 #include "datatypes.h"
00061 #include "timers.h"
00062 #include "system.h"
00063 #include "ethernet.h"
00064 #include "arp.h"
00065 #include "icmp.h"
00066 #include "ip.h"
00067 #include "udp.h"
00068 #include "address.h"
00069
00070
00071
00072
00073
00074
00075 #define IDLE 1
00076 #define USER_QUERY_DB 2
00077 #define INVALID_USER 3
00078 #define CAPTURE_PIN 4
00079 #define SESSION_START 5
00080 #define SESSION_RUNNING 6
00081 #define INVALID_KEYPRESS 7
00082 #define ITEM_QUERY_DB 8
00083 #define CONFIRM_REMOVAL 9
00084 #define ITEM_NOT_MATCHED 10
00085 #define CANCEL_SESSION 11
00086 #define REMOVE_LAST_ITEM 12
00087 #define SESSION_END 13
00088 #define PRINT 14
00089 #define EMAIL 15
00090 #define FINISH_SESSION 16
00091 #define TIME_SYNCH 17
00092
00093
00094 #define RFID_FLAG_MASK 0x01
00095 #define KEYPAD_FLAG_MASK 0x02
00096 #define CHK_KEYPAD_FLAG_MASK 0x04
00097 #define VALID_QUERY_FLAG_MASK 0x08
00098 #define CANCEL_ONCE_MASK 0x10
00099 #define ONLY_ONCE_MASK 0x20
00100 #define CHK_RFID_MASK 0x40
00101 #define MASK_CANCEL_MASK 0x80
00102 #define RFID_FLAG 0
00103 #define KEYPAD_FLAG 1
00104 #define CHK_KEYPAD_FLAG 2
00105 #define VALID_QUERY_FLAG 3
00106 #define CANCEL_ONCE 4
00107 #define ONLY_ONCE 5
00108 #define CHK_RFID_FLAG 6
00109 #define MASK_CANCEL_FLAG 7
00110
00111
00112 #define USER 1
00113 #define ITEM 0
00114
00115
00116 #define KEY_ONE 1
00117 #define KEY_TWO 2
00118 #define KEY_THREE 3
00119 #define KEY_FOUR 4
00120 #define KEY_FIVE 5
00121 #define KEY_SIX 6
00122 #define KEY_SEVEN 7
00123 #define KEY_EIGHT 8
00124 #define KEY_NINE 9
00125 #define KEY_ZERO 0
00126 #define KEY_STAR 11
00127 #define KEY_POUND 12
00128 #define KEY_ENTER 13
00129 #define KEY_CLEAR 14
00130 #define KEY_HELP 15
00131 #define KEY_CANCEL 16
00132
00133
00134 #define AM 1
00135 #define PM 2
00136
00137
00138
00139
00140
00141 #define SetBit(bit_ID, varID) (varID |= (byte)(1<<bit_ID))
00142 #define ClearBit(bit_ID, varID) (varID &= ~(byte)(1<<bit_ID))
00143 #define clrReg8Bits(RegName, ClrMask) (RegName &= ~(byte)(ClrMask))
00144
00145
00146
00147
00148
00149 typedef struct{
00150 char itemSerial[14];
00151 char itemName[26];
00152 int nameLength;
00153 char itemPrice[6];
00154 } itemStruct;
00155
00156 typedef struct{
00157 char userName[21];
00158 int nameLength;
00159 char userEmail[31];
00160 int emailLength;
00161 int cartSizeI;
00162 long cartTotalI;
00163 int timeHrI;
00164 int timeMinI;
00165 int timeSecsI;
00166 int timeHalfI;
00167 int dateMonthI;
00168 int dateDayI;
00169 int dateYearI;
00170 itemStruct items[20];
00171 } sessionStruct;
00172
00173
00174
00175
00176
00177 byte state;
00178 byte returnState;
00179 byte flags;
00180 int keyPressed;
00181 int pinCounter;
00182 char currentPin[5];
00183 char userPin[5];
00184 char lastSerial[14];
00185 char userSerial[14];
00186 char serialNum[14];
00187 long counter = 0;
00188 int timecounter = 0;
00189 int printcounter = 1;
00190 int testcounter = 0;
00191 int waitcounter = 0;
00192 int pollCounter2 = 0;
00193 sessionStruct currSession;
00194 const int calendar[] = {
00195 31,31,31,30,31,30,31,31,30,31,30,31
00196 };
00197
00198 INT8 SendData;
00199 INT8 RcvData;
00200 char toSend[15] = "I:0413AAC34F3A";
00201 char rcvPacket[55];
00202
00203 struct netif localmachine;
00204
00205 extern tU08 gotlink;
00206
00207
00208
00209
00210
00211 void PrintReceipt(void);
00212 void PollKeypad(void);
00213 void ProcInit(void);
00214 void LCDInit(void);
00215
00216 void UpdateLCD(void);
00217 void SetupSession(void);
00218 void WaitFor(int);
00219 int HandlePacket(void);
00220 extern void RTI_Enable (void);
00221 void mystrcpy(char *, char*, int, int);
00222
00223
00224
00225
00226
00227 void main()
00228 {
00229 INT16 len;
00230 INT32 i;
00231 INT32 j = 0;
00232 INT32 k = 0;
00233
00234 state = TIME_SYNCH;
00235 flags = 0x00;
00236 SendData = 0;
00237
00238 ProcInit();
00239 LCDInit();
00240 SetupSession();
00241
00242 _INIT_DEBUG();
00243
00244
00245
00246
00247 localmachine.localip = *((UINT32 *)ip_address);
00248
00249
00250 localmachine.defgw = *((UINT32 *)ip_gateway);
00251
00252
00253 localmachine.netmask = *((UINT32 *)ip_netmask);
00254
00255
00256 localmachine.localHW[0] = hard_addr[0];
00257 localmachine.localHW[1] = hard_addr[1];
00258 localmachine.localHW[2] = hard_addr[2];
00259 localmachine.localHW[3] = hard_addr[3];
00260 localmachine.localHW[4] = hard_addr[4];
00261 localmachine.localHW[5] = hard_addr[5];
00262
00263
00264 timer_pool_init();
00265
00266
00267 mBufInit ();
00268
00269
00270
00271 EtherInit();
00272
00273 asm cli;
00274
00275
00276 arp_init();
00277 (void) udp_init();
00278 udp_demo_init();
00279
00280
00281 RTI_Enable ();
00282
00283 while (1)
00284 {
00285 if (gotlink) {
00286
00287 if( NETWORK_CHECK_IF_RECEIVED() == TRUE ) {
00288 switch( received_frame.protocol)
00289 {
00290 case PROTOCOL_ARP:
00291 process_arp (&received_frame);
00292 break;
00293 case PROTOCOL_IP:
00294 len = process_ip_in(&received_frame);
00295 if(len < 0)
00296 break;
00297 switch (received_ip_packet.protocol)
00298 {
00299 case IP_ICMP:
00300 process_icmp_in (&received_ip_packet, len);
00301 break;
00302 case IP_UDP:
00303 process_udp_in (&received_ip_packet,len);
00304 break;
00305 default:
00306 break;
00307 }
00308 break;
00309 default:
00310 break;
00311 }
00312
00313 NETWORK_RECEIVE_END();
00314 }
00315 arp_manage();
00316 udp_demo_run();
00317 }
00318
00319 if (state == TIME_SYNCH) {
00320 if (!(flags & ONLY_ONCE_MASK)) {
00321 UpdateLCD();
00322 toSend[0] = 'T';
00323 SetBit(ONLY_ONCE, flags);
00324 SetBit(MASK_CANCEL_FLAG, flags);
00325 }
00326 SendData = 1;
00327 if(RcvData) {
00328 if (HandlePacket()) {
00329 flags = 0x00;
00330 state = IDLE;
00331 } else {
00332 flags = 0x00;
00333 state = TIME_SYNCH;
00334 }
00335 }
00336 }
00337
00338 else if (state == IDLE) {
00339 if (!(flags & ONLY_ONCE_MASK)) {
00340 UpdateLCD();
00341 SetBit(ONLY_ONCE, flags);
00342 SetBit(CHK_RFID_FLAG, flags);
00343 SetBit(MASK_CANCEL_FLAG, flags);
00344 }
00345 if (flags & RFID_FLAG_MASK)
00346 {
00347 mystrcpy(userSerial,serialNum,13,13);
00348 state = USER_QUERY_DB;
00349 flags = 0x00;
00350 }
00351 }
00352
00353 else if (state == USER_QUERY_DB) {
00354 if (!(flags & ONLY_ONCE_MASK)) {
00355 toSend[0] = 'U';
00356 mystrcpy(&toSend[1],userSerial,13,13);
00357 SetBit(ONLY_ONCE, flags);
00358 }
00359 SendData = 1;
00360 if(RcvData) {
00361 if (HandlePacket()) {
00362 pinCounter = 0;
00363 flags = 0x00;
00364 state = CAPTURE_PIN;
00365 } else {
00366 flags = 0x00;
00367 state = INVALID_USER;
00368 }
00369 }
00370 }
00371
00372 else if (state == INVALID_USER) {
00373 UpdateLCD();
00374 WaitFor(4);
00375 asm sei;
00376 SetupSession();
00377 asm cli;
00378 state = IDLE;
00379 }
00380
00381 else if (state == CAPTURE_PIN) {
00382 if (!(flags & ONLY_ONCE_MASK)) {
00383 UpdateLCD();
00384 SetBit(CHK_KEYPAD_FLAG, flags);
00385 SetBit(ONLY_ONCE, flags);
00386 }
00387 if (flags & KEYPAD_FLAG_MASK) {
00388 if (pinCounter < 4) {
00389 if ((keyPressed >= 0) && (keyPressed <= 9)) {
00390 currentPin[pinCounter] = keyPressed + '0';
00391 pinCounter++;
00392 UpdateLCD();
00393 } else if (keyPressed == KEY_CLEAR) {
00394 if (pinCounter > 0) {
00395 pinCounter--;
00396 UpdateLCD();
00397 }
00398 }
00399 } else {
00400 if (keyPressed == KEY_CLEAR) {
00401 pinCounter--;
00402 UpdateLCD();
00403 } else if (keyPressed == KEY_ENTER) {
00404 for (j = 0; j < 4; j++) {
00405 if (currentPin[j] != userPin[j]) {
00406 state = INVALID_USER;
00407 break;
00408 }
00409 }
00410 if (j == 4) {
00411 state = SESSION_START;
00412 }
00413 flags = 0x00;
00414 }
00415 }
00416 ClearBit(KEYPAD_FLAG, flags);
00417 }
00418 }
00419
00420 else if (state == SESSION_START) {
00421 if (!(flags & ONLY_ONCE_MASK)) {
00422 UpdateLCD();
00423 SetBit(ONLY_ONCE, flags);
00424 SetBit(CHK_RFID_FLAG, flags);
00425 }
00426 if (flags & RFID_FLAG_MASK) {
00427 state = ITEM_QUERY_DB;
00428 flags = 0x00;
00429 }
00430 }
00431
00432 else if (state == SESSION_RUNNING) {
00433 if (!(flags & ONLY_ONCE_MASK)) {
00434 UpdateLCD();
00435 SetBit(ONLY_ONCE, flags);
00436 SetBit(CHK_KEYPAD_FLAG, flags);
00437 SetBit(CHK_RFID_FLAG, flags);
00438 }
00439 if (flags & RFID_FLAG_MASK) {
00440 state = ITEM_QUERY_DB;
00441 flags = 0x00;
00442 }if (flags & KEYPAD_FLAG_MASK) {
00443 if (keyPressed == KEY_CLEAR) {
00444 state = CONFIRM_REMOVAL;
00445 } else if (keyPressed == KEY_ENTER) {
00446 state = SESSION_END;
00447 } else {
00448 state = INVALID_KEYPRESS;
00449 }
00450 flags = 0x00;
00451 }
00452 }
00453
00454 else if (state == INVALID_KEYPRESS) {
00455 UpdateLCD();
00456 WaitFor(4);
00457 state = SESSION_RUNNING;
00458 }
00459
00460 else if (state == ITEM_QUERY_DB) {
00461 if (!(flags & ONLY_ONCE_MASK)) {
00462 for (i = 0; i < 13; i++) {
00463 if (lastSerial[i] != serialNum[i]) {
00464 mystrcpy(lastSerial,serialNum,13,13);
00465 break;
00466 } else if (i == 12) {
00467 flags = 0x00;
00468 SetBit(ONLY_ONCE, flags);
00469 SetBit(CHK_KEYPAD_FLAG, flags);
00470 SetBit(CHK_RFID_FLAG, flags);
00471 state = SESSION_RUNNING;
00472 }
00473 }
00474 if (state != SESSION_RUNNING) {
00475 toSend[0] = 'I';
00476 mystrcpy(&toSend[1],serialNum,13,13);
00477 SetBit(ONLY_ONCE, flags);
00478 }
00479 }
00480
00481 if (state != SESSION_RUNNING) {
00482 SendData = 1;
00483 }
00484 if(RcvData) {
00485 if (HandlePacket()) {
00486 state = SESSION_RUNNING;
00487 } else {
00488 state = ITEM_NOT_MATCHED;
00489 }
00490 flags = 0x00;
00491 }
00492 }
00493
00494 else if (state == ITEM_NOT_MATCHED) {
00495 UpdateLCD();
00496 WaitFor(4);
00497 state = SESSION_RUNNING;
00498 }
00499
00500 else if (state == CANCEL_SESSION) {
00501 if (!(flags & CANCEL_ONCE_MASK)) {
00502 UpdateLCD();
00503 ClearBit(ONLY_ONCE, flags);
00504 SetBit(CANCEL_ONCE, flags);
00505 SetBit(CHK_KEYPAD_FLAG, flags);
00506 SetBit(MASK_CANCEL_FLAG, flags);
00507 }
00508 if (flags & KEYPAD_FLAG_MASK) {
00509 if (keyPressed == KEY_ENTER) {
00510 flags = 0x00;
00511 state = FINISH_SESSION;
00512 } else if (keyPressed == KEY_CANCEL) {
00513 flags = 0x00;
00514 state = returnState;
00515 }
00516 ClearBit(KEYPAD_FLAG, flags);
00517 }
00518 }
00519
00520 else if (state == CONFIRM_REMOVAL) {
00521 if (!(flags & ONLY_ONCE_MASK)) {
00522 UpdateLCD();
00523 SetBit(ONLY_ONCE, flags);
00524 SetBit(CHK_KEYPAD_FLAG, flags);
00525 SetBit(MASK_CANCEL_FLAG, flags);
00526 }
00527 if (flags & KEYPAD_FLAG_MASK) {
00528 if (keyPressed == KEY_ENTER) {
00529 flags = 0x00;
00530 state = REMOVE_LAST_ITEM;
00531 } else if (keyPressed == KEY_CANCEL) {
00532 flags = 0x00;
00533 state = SESSION_RUNNING;
00534 }
00535 ClearBit(KEYPAD_FLAG, flags);
00536 }
00537 }
00538
00539 else if (state == REMOVE_LAST_ITEM) {
00540 if (!(flags & ONLY_ONCE_MASK)) {
00541 toSend[0] = 'R';
00542 mystrcpy(&toSend[1],currSession.items[currSession.cartSizeI-1].itemSerial,13,13);
00543 UpdateLCD();
00544 SetBit(ONLY_ONCE, flags);
00545 SetBit(MASK_CANCEL_FLAG, flags);
00546 }
00547 SendData = 1;
00548 if(RcvData) {
00549 HandlePacket();
00550 state = SESSION_RUNNING;
00551 flags = 0x00;
00552 }
00553 }
00554
00555 else if (state == SESSION_END) {
00556 if (!(flags & ONLY_ONCE_MASK)) {
00557 UpdateLCD();
00558 SetBit(CHK_KEYPAD_FLAG, flags);
00559 SetBit(MASK_CANCEL_FLAG, flags);
00560 SetBit(ONLY_ONCE, flags);
00561 }
00562 if (flags & KEYPAD_FLAG_MASK) {
00563 if (keyPressed == KEY_ENTER) {
00564 flags = 0x00;
00565 state = PRINT;
00566 } else if (keyPressed == KEY_CANCEL) {
00567 flags = 0x00;
00568 state = EMAIL;
00569 }
00570 ClearBit(KEYPAD_FLAG, flags);
00571 }
00572 }
00573
00574 else if (state == PRINT) {
00575 UpdateLCD();
00576 asm sei;
00577 PrintReceipt();
00578 asm cli;
00579 WaitFor(3);
00580 state = EMAIL;
00581 }
00582
00583 else if (state == EMAIL) {
00584 if (!(flags & ONLY_ONCE_MASK)) {
00585 toSend[0] = 'M';
00586 mystrcpy(&toSend[1],userSerial,13,13);
00587 UpdateLCD();
00588 SetBit(ONLY_ONCE, flags);
00589 }
00590 SendData = 1;
00591 if(RcvData) {
00592 HandlePacket();
00593 WaitFor(3);
00594 state = FINISH_SESSION;
00595 flags = 0x00;
00596 }
00597 }
00598
00599 else if (state == FINISH_SESSION) {
00600 UpdateLCD();
00601 SetupSession();
00602 WaitFor(8);
00603 asm cli;
00604 state = IDLE;
00605 }
00606
00607 PollKeypad();
00608 }
00609 }
00610
00611 void mystrcpy(char *dst, char*src, int dstlen, int srclen) {
00612 int i = 0;
00613
00614 for (i = 0; i < dstlen; i++) {
00615 if ( i < srclen) {
00616 dst[i] = src[i];
00617 } else {
00618 dst[i] = ' ';
00619 }
00620 }
00621 }
00622
00623 void SetupSession(void) {
00624 currSession.cartSizeI = 0;
00625 currSession.cartTotalI = 0;
00626 currSession.userName[20] = NULL;
00627 currSession.userEmail[30] = NULL;
00628 pinCounter = 0;
00629 lastSerial[0] = '?';
00630 }
00631
00632
00633
00634
00635
00636
00637 interrupt void RFIDInterrupt(void) {
00638 int startFlag = 0;
00639 int mycounter = 0;
00640 char holder = ' ';
00641
00642 SCI1SR1;
00643 holder = SCI1DRL;
00644
00645 if (!(CHK_RFID_MASK & flags)) {
00646 return;
00647 }
00648
00649 serialNum[0] = holder;
00650
00651 if (SCI1DRL == 0x3A) {
00652 startFlag = 1;
00653 mycounter++;
00654 } else {
00655 return;
00656 }
00657
00658 while (mycounter < 14) {
00659 while ((SCI1SR1 & SCI1SR1_RDRF_MASK) == 0);
00660 if (SCI1DRL == 0x3A) startFlag = 1;
00661 if (startFlag == 1) {
00662 serialNum[mycounter] = SCI1DRL;
00663 mycounter++;
00664 }
00665 }
00666
00667 SetBit(RFID_FLAG, flags);
00668 }
00669
00670
00671
00672
00673
00674
00675 interrupt void HandleTimerInterrupt(void) {
00676 if (pollCounter2 == 0) {
00677 PTJ_PTJ6 = 1;
00678 PTJ_PTJ7 = 0;
00679 PTT_PTT4 = 0;
00680 PTT_PTT5 = 0;
00681 } else if (pollCounter2 == 1) {
00682 PTJ_PTJ6 = 0;
00683 PTJ_PTJ7 = 1;
00684 PTT_PTT4 = 0;
00685 PTT_PTT5 = 0;
00686 } else if (pollCounter2 == 2) {
00687 PTJ_PTJ6 = 0;
00688 PTJ_PTJ7 = 0;
00689 PTT_PTT4 = 1;
00690 PTT_PTT5 = 0;
00691 } else if (pollCounter2 == 3) {
00692 PTJ_PTJ6 = 0;
00693 PTJ_PTJ7 = 0;
00694 PTT_PTT4 = 0;
00695 PTT_PTT5 = 1;
00696 }
00697 pollCounter2 = (pollCounter2 + 1) % 4;
00698
00699 TFLG1_C6F = 1;
00700 timecounter++;
00701 if (timecounter == 25) {
00702 currSession.timeSecsI++;
00703 if (currSession.timeSecsI > 59) {
00704 currSession.timeSecsI = 0;
00705 currSession.timeMinI++;
00706 if (currSession.timeMinI > 59) {
00707 currSession.timeMinI = 0;
00708 currSession.timeHrI++;
00709 if (currSession.timeHrI == 12) {
00710 if (currSession.timeHalfI == AM) {
00711 currSession.timeHalfI = PM;
00712 } else {
00713 currSession.timeHalfI = AM;
00714 currSession.dateDayI++;
00715 if (currSession.dateDayI > calendar[currSession.dateMonthI]) {
00716 currSession.dateDayI = 1;
00717 currSession.dateMonthI++;
00718 if (currSession.dateMonthI > 12) {
00719 currSession.dateMonthI = 1;
00720 currSession.dateYearI++;
00721 if (currSession.dateYearI > 99) {
00722 currSession.dateYearI = 0;
00723 }
00724 }
00725 }
00726 }
00727 } else if (currSession.timeHrI > 12) {
00728 currSession.timeHrI = 1;
00729 }
00730 }
00731 if ((state == SESSION_RUNNING)) {
00732 UpdateLCD();
00733 }
00734 }
00735 waitcounter++;
00736 timecounter = 0;
00737 }
00738 }
00739
00740
00741
00742
00743
00744
00745 void ProcInit(void) {
00746 SCI0BD = 163;
00747 SCI0CR2 = 0x08;
00748 SCI1BD = 163;
00749 SCI1CR2 = 0x24;
00750 DDRG = 0xFF;
00751 DDRH = 0x07;
00752 PERH = 0x78;
00753 PPSH = 0x78;
00754 DDRJ_DDRJ0 = 1;
00755 DDRJ_DDRJ6 = 1;
00756 DDRJ_DDRJ7 = 1;
00757 DDRT_DDRT4 = 1;
00758 DDRT_DDRT5 = 1;
00759
00760 TSCR1 = 0x80;
00761 TCTL1 = 0x00;
00762 TIOS = 0xF0;
00763 TIE = 0x40;
00764 TSCR2 = 0x0E;
00765 TC7 = 0x3D0A;
00766 TC6 = 0x3D09;
00767
00768 CLKSEL=0;
00769 CLKSEL_PLLSEL = 0;
00770 PLLCTL_PLLON = 0;
00771 SYNR = 0;
00772 REFDV = 0;
00773 PLLCTL = 192;
00774 PLLCTL_PLLON = 1;
00775 while(!CRGFLG_LOCK);
00776 CLKSEL_PLLSEL = 1;
00777
00778 INTCR_IRQEN = 0;
00779 }
00780
00781
00782
00783
00784
00785
00786 void LCDInit(void) {
00787 LCD_reset();
00788 }
00789
00790
00791
00792
00793
00794
00795 int HandlePacket(void) {
00796 char mynum[3] = "00";
00797 int startpos = 0;
00798 int i = 0;
00799
00800 SendData = 0;
00801 RcvData = 0;
00802 if (rcvPacket[0] == '~') {
00803 return 0;
00804 } else if (state == TIME_SYNCH) {
00805
00806
00807 if (rcvPacket[startpos+1] == '/') {
00808 currSession.dateMonthI = rcvPacket[startpos] - '0';
00809 startpos += 2;
00810 } else {
00811 currSession.dateMonthI = 10 + (rcvPacket[startpos+1] - '0');
00812 startpos += 3;
00813 }
00814
00815
00816 if (rcvPacket[startpos+1] == '/') {
00817 currSession.dateDayI = rcvPacket[startpos] - '0';
00818 startpos += 2;
00819 } else {
00820 currSession.dateDayI = (10 * (rcvPacket[startpos] - '0')) + (rcvPacket[startpos+1] - '0');
00821 startpos += 3;
00822 }
00823
00824
00825 currSession.dateYearI = (10 * (rcvPacket[startpos] - '0')) + (rcvPacket[startpos+1] - '0');
00826 startpos += 3;
00827
00828
00829 if (rcvPacket[startpos+1] == ':') {
00830 currSession.timeHrI = rcvPacket[startpos] - '0';
00831 startpos += 2;
00832 } else {
00833 currSession.timeHrI = 10 + (rcvPacket[startpos+1] - '0');
00834 startpos += 3;
00835 }
00836
00837
00838 currSession.timeMinI = (10 * (rcvPacket[startpos] - '0')) + (rcvPacket[startpos+1] - '0');
00839 startpos += 3;
00840
00841
00842 currSession.timeSecsI = (10 * (rcvPacket[startpos] - '0')) + (rcvPacket[startpos+1] - '0');
00843 startpos += 3;
00844
00845 if (rcvPacket[startpos] == 'A') {
00846 currSession.timeHalfI = AM;
00847 } else {
00848 currSession.timeHalfI = PM;
00849 }
00850
00851 } else if (state == USER_QUERY_DB) {
00852 mystrcpy(currSession.userName, rcvPacket, 20, 20);
00853 i = 19;
00854 while(rcvPacket[i] == ' ') {
00855 i--;
00856 }
00857 currSession.nameLength = i + 1;
00858 mystrcpy(currSession.userEmail, &rcvPacket[20], 30, 30);
00859 i = 49;
00860 while(rcvPacket[i] == ' ') {
00861 i--;
00862 }
00863 currSession.emailLength = i + 1 - 20;
00864 mystrcpy(userPin, &rcvPacket[50], 4, 4);
00865 } else if (state == REMOVE_LAST_ITEM) {
00866
00867
00868 if (currSession.items[currSession.cartSizeI-1].itemPrice[0] != ' ') {
00869 currSession.cartTotalI -= 10000 * (currSession.items[currSession.cartSizeI-1].itemPrice[0] - '0');
00870 }
00871 if (currSession.items[currSession.cartSizeI-1].itemPrice[1] != ' ') {
00872 currSession.cartTotalI -= 1000 * (currSession.items[currSession.cartSizeI-1].itemPrice[1] - '0');
00873 }
00874 if (currSession.items[currSession.cartSizeI-1].itemPrice[2] != ' ') {
00875 currSession.cartTotalI -= 100 * (currSession.items[currSession.cartSizeI-1].itemPrice[2] - '0');
00876 }
00877 if (currSession.items[currSession.cartSizeI-1].itemPrice[3] != ' ') {
00878 currSession.cartTotalI -= 10 * (currSession.items[currSession.cartSizeI-1].itemPrice[3] - '0');
00879 }
00880 if (currSession.items[currSession.cartSizeI-1].itemPrice[4] != ' ') {
00881 currSession.cartTotalI -= 1 * (currSession.items[currSession.cartSizeI-1].itemPrice[4] - '0');
00882 }
00883 currSession.cartSizeI--;
00884 mystrcpy(lastSerial,currSession.items[currSession.cartSizeI-1].itemSerial,13,13);
00885 } else if (state == ITEM_QUERY_DB) {
00886 mystrcpy(currSession.items[currSession.cartSizeI].itemSerial, serialNum, 13, 13);
00887 mystrcpy(currSession.items[currSession.cartSizeI].itemName, rcvPacket, 25, 25);
00888 i = 24;
00889 while(rcvPacket[i] == ' ') {
00890 i--;
00891 }
00892 currSession.items[currSession.cartSizeI].nameLength = i + 1;
00893 mystrcpy(currSession.items[currSession.cartSizeI].itemPrice, &rcvPacket[25], 5, 5);
00894
00895
00896 if (currSession.items[currSession.cartSizeI].itemPrice[0] != ' ') {
00897 currSession.cartTotalI += 10000 * (currSession.items[currSession.cartSizeI].itemPrice[0] - '0');
00898 }
00899 if (currSession.items[currSession.cartSizeI].itemPrice[1] != ' ') {
00900 currSession.cartTotalI += 1000 * (currSession.items[currSession.cartSizeI].itemPrice[1] - '0');
00901 }
00902 if (currSession.items[currSession.cartSizeI].itemPrice[2] != ' ') {
00903 currSession.cartTotalI += 100 * (currSession.items[currSession.cartSizeI].itemPrice[2] - '0');
00904 }
00905 if (currSession.items[currSession.cartSizeI].itemPrice[3] != ' ') {
00906 currSession.cartTotalI += 10 * (currSession.items[currSession.cartSizeI].itemPrice[3] - '0');
00907 }
00908 if (currSession.items[currSession.cartSizeI].itemPrice[4] != ' ') {
00909 currSession.cartTotalI += 1 * (currSession.items[currSession.cartSizeI].itemPrice[4] - '0');
00910 }
00911 currSession.cartSizeI++;
00912 }
00913
00914 return 1;
00915 }
00916
00917
00918
00919
00920
00921
00922 void UpdateLCD(void) {
00923 int item_counter, e, f, flag = 0;
00924 char indexStr[3] = " 0";
00925 char datetime[18] = "11:11AM 11/11/11";
00926 char datetime2[21] = "11:11:11AM 11/11/11";
00927 char mynumber[3] = "00";
00928 char myprice[8] = "$000.00";
00929 char temp = ' ';
00930
00931 LCD_clr_scr_char(0);
00932 if (state == IDLE) {
00933 LCD_graphic_ini();
00934
00935
00936 for (e = 0; e < 4; e++) {
00937 for (f = 0; f < 30; f++) {
00938 LCD_write_data(0x00);
00939 }
00940 }
00941
00942
00943 for (e = 0; e < LOGO_SIZE; e++) {
00944 LCD_write_data(logo_bitmap[e]);
00945 }
00946
00947
00948 for (e = 0; e < FOOTER_SIZE; e++) {
00949 LCD_write_data(please_scan_bitmap[e]);
00950 }
00951
00952
00953 for (e = 0; e < 3; e++) {
00954 for (f = 0; f < 30; f++) {
00955 LCD_write_data(0x00);
00956 }
00957 }
00958 } else if (state == TIME_SYNCH) {
00959 LCD_graphic_ini();
00960
00961
00962 for (e = 0; e < 4; e++) {
00963 for (f = 0; f < 30; f++) {
00964 LCD_write_data(0x00);
00965 }
00966 }
00967
00968
00969 for (e = 0; e < LOGO_SIZE; e++) {
00970 LCD_write_data(logo_bitmap[e]);
00971 }
00972
00973
00974 for (e = 0; e < 15; e++) {
00975 for (f = 0; f < 30; f++) {
00976 LCD_write_data(0x00);
00977 }
00978 }
00979 } else if (state == INVALID_USER) {
00980 LCD_char_ini();
00981 LCD_set_char_add(5,4);
00982 LCD_print_string("Sorry, customer not recognized.");
00983 } else if (state == CAPTURE_PIN) {
00984 LCD_char_ini();
00985 LCD_set_char_add(5,9);
00986 LCD_print_string("Welcome, ");
00987 LCD_print_string(currSession.userName);
00988 LCD_set_char_add(6,5);
00989 LCD_print_string("Please enter your 4-digit PIN:");
00990 LCD_set_char_add(8,17);
00991 if (pinCounter == 0)
00992 LCD_print_string(" ");
00993 else if (pinCounter == 1)
00994 LCD_print_string("*");
00995 else if (pinCounter == 2)
00996 LCD_print_string("* *");
00997 else if (pinCounter == 3)
00998 LCD_print_string("* * *");
00999 else if (pinCounter == 4)
01000 LCD_print_string("* * * *");
01001 else
01002 LCD_print_string("FATAL ERROR");
01003 } else if (state == SESSION_START) {
01004 LCD_char_ini();
01005 LCD_set_char_add(5,6);
01006 LCD_print_string("Please scan your first item");
01007 } else if (state == SESSION_RUNNING) {
01008 LCD_char_ini();
01009 LCD_set_char_add(0,0);
01010 LCD_print_string("RFID Xpr3ss");
01011 LCD_set_char_add(0,21);
01012 mynumber[0] = (currSession.timeHrI / 10) + '0';
01013 mynumber[1] = (currSession.timeHrI % 10) + '0';
01014 mystrcpy(&datetime[0],mynumber,2,2);
01015 mynumber[0] = (currSession.timeMinI / 10) + '0';
01016 mynumber[1] = (currSession.timeMinI % 10) + '0';
01017 mystrcpy(&datetime[3],mynumber,2,2);
01018 mynumber[0] = (currSession.dateMonthI / 10) + '0';
01019 mynumber[1] = (currSession.dateMonthI % 10) + '0';
01020 mystrcpy(&datetime[9],mynumber,2,2);
01021 mynumber[0] = (currSession.dateDayI / 10) + '0';
01022 mynumber[1] = (currSession.dateDayI % 10) + '0';
01023 mystrcpy(&datetime[12],mynumber,2,2);
01024 mynumber[0] = (currSession.dateYearI / 10) + '0';
01025 mynumber[1] = (currSession.dateYearI % 10) + '0';
01026 mystrcpy(&datetime[15],mynumber,2,2);
01027 mynumber[1] = 'M';
01028 if (currSession.timeHalfI == AM) {
01029 mynumber[0] = 'A';
01030 } else {
01031 mynumber[0] = 'P';
01032 }
01033 mystrcpy(&datetime[5],mynumber,2,2);
01034 LCD_print_string(datetime);
01035 LCD_set_char_add(1,0);
01036 LCD_print_string("ITEM PRICE ");
01037
01038
01039 for (item_counter=currSession.cartSizeI-7; item_counter<currSession.cartSizeI; item_counter++){
01040 if (currSession.cartSizeI == 0){break;}
01041 if (item_counter<0){item_counter=0;}
01042 if (item_counter < 9) {
01043 indexStr[0] = ' ';
01044 } else {
01045 indexStr[0] = (char)(((item_counter+1) / 10)+'0');
01046 }
01047 indexStr[1] = (char)(((item_counter+1) % 10) + '0');
01048 LCD_print_string(indexStr);
01049 LCD_print_string(" ");
01050 LCD_print_string(currSession.items[item_counter].itemName);
01051 LCD_print_string(" ");
01052 mystrcpy(&myprice[1], currSession.items[item_counter].itemPrice,3,3);
01053 mystrcpy(&myprice[5], &currSession.items[item_counter].itemPrice[3],2,2);
01054 LCD_print_string(myprice);
01055 }
01056
01057 LCD_set_char_add(9,33);
01058 LCD_print_string("-------");
01059
01060 temp = (currSession.cartSizeI / 10) + '0';
01061 if (temp == '0') {
01062 mynumber[0] = ' ';
01063 } else {
01064 mynumber[0] = temp;
01065 }
01066
01067 mynumber[1] = (currSession.cartSizeI % 10) + '0';
01068
01069 LCD_set_char_add(10,0);
01070 LCD_print_string(mynumber);
01071 LCD_print_string(" items in your cart");
01072 LCD_set_char_add(10,3);
01073 LCD_print_string("items in your cart TOTAL: $");
01074
01075
01076 temp = (currSession.cartTotalI / 100000) + '0';
01077 if ((temp == '0') && (flag == 0)) {
01078 myprice[0] = ' ';
01079 } else {
01080 myprice[0] = temp;
01081 flag = 1;
01082 }
01083
01084 temp = ((currSession.cartTotalI % 100000) / 10000) + '0';
01085 if ((temp == '0') && (flag == 0)) {
01086 myprice[1] = ' ';
01087 } else {
01088 myprice[1] = temp;
01089 flag = 1;
01090 }
01091
01092 temp = ((currSession.cartTotalI % 10000) / 1000) + '0';
01093 if ((temp == '0') && (flag == 0)) {
01094 myprice[2] = ' ';
01095 } else {
01096 myprice[2] = temp;
01097 flag = 1;
01098 }
01099
01100 temp = ((currSession.cartTotalI % 1000) / 100) + '0';
01101 if ((temp == '0') && (flag == 0)) {
01102 myprice[3] = ' ';
01103 } else {
01104 myprice[3] = temp;
01105 flag = 1;
01106 }
01107
01108 temp = ((currSession.cartTotalI % 100) / 10) + '0';
01109 if ((temp == '0') && (flag == 0)) {
01110 myprice[5] = ' ';
01111 } else {
01112 myprice[5] = temp;
01113 flag = 1;
01114 }
01115
01116 temp = ((currSession.cartTotalI % 10) / 1) + '0';
01117 if ((temp == '0') && (flag == 0)) {
01118 myprice[6] = ' ';
01119 } else {
01120 myprice[6] = temp;
01121 flag = 1;
01122 }
01123 LCD_print_string(myprice);
01124 LCD_set_char_add(11,1);
01125 LCD_print_string("[ PRESS ENTER TO FINISH ]");
01126 } else if (state == INVALID_KEYPRESS) {
01127 LCD_char_ini();
01128 LCD_set_char_add(5,10);
01129 LCD_print_string("Key not recognized");
01130 } else if (state == ITEM_NOT_MATCHED) {
01131 LCD_char_ini();
01132 LCD_set_char_add(5,10);
01133 LCD_print_string("Item not recognized");
01134 } else if (state == CANCEL_SESSION) {
01135 LCD_char_ini();
01136 LCD_set_char_add(4,0);
01137 LCD_print_string(" Are you sure you want to quit shopping?");
01138 LCD_set_char_add(6,0);
01139 if (returnState == CAPTURE_PIN) {
01140 LCD_print_string(" Press ENTER to confirm, ");
01141 LCD_print_string(" CANCEL to return to pin entry ");
01142 } else {
01143 LCD_print_string(" Press ENTER to confirm, ");
01144 LCD_print_string(" CANCEL to return to cart");
01145 }
01146 } else if ((state == REMOVE_LAST_ITEM) || (state == CONFIRM_REMOVAL)) {
01147 LCD_char_ini();
01148 LCD_set_char_add(2,5);
01149 LCD_print_string("Are you sure you want to remove ");
01150 LCD_set_char_add(4,(20 - currSession.items[currSession.cartSizeI-1].nameLength / 2));
01151 LCD_print_string(currSession.items[currSession.cartSizeI-1].itemName);
01152 LCD_set_char_add(6,13);
01153 LCD_print_string("from your cart?");
01154 LCD_set_char_add(8,0);
01155 LCD_print_string(" Press ENTER to remove item, ");
01156 LCD_print_string(" CANCEL to return to cart");
01157 } else if (state == SESSION_END) {
01158 LCD_char_ini();
01159 LCD_set_char_add(5,5);
01160 LCD_print_string("Do you want a printed receipt?");
01161 LCD_set_char_add(7,0);
01162 LCD_print_string(" Press ENTER for yes, ");
01163 LCD_print_string(" CANCEL to skip");
01164 } else if (state == PRINT) {
01165 LCD_char_ini();
01166 LCD_set_char_add(4,15);
01167 LCD_print_string("Printing...");
01168 LCD_set_char_add(6,7);
01169 LCD_print_string("Please take your receipt...");
01170 } else if (state == EMAIL) {
01171 LCD_char_ini();
01172 LCD_set_char_add(4,11);
01173 LCD_print_string("Emailing receipt to");
01174 LCD_set_char_add(6,(20 - currSession.emailLength / 2));
01175 LCD_print_string(currSession.userEmail);
01176 } else if (state == FINISH_SESSION) {
01177 LCD_graphic_ini();
01178
01179
01180 for (e = 0; e < 4; e++) {
01181 for (f = 0; f < 30; f++) {
01182 LCD_write_data(0x00);
01183 }
01184 }
01185
01186
01187 for (e = 0; e < LOGO_SIZE; e++) {
01188 LCD_write_data(logo_bitmap[e]);
01189 }
01190
01191
01192 for (e = 0; e < FOOTER_SIZE; e++) {
01193 LCD_write_data(thank_you_bitmap[e]);
01194 }
01195
01196
01197 for (e = 0; e < 3; e++) {
01198 for (f = 0; f < 30; f++) {
01199 LCD_write_data(0x00);
01200 }
01201 }
01202 } else {
01203 LCD_set_char_add(5,10);
01204 LCD_print_string("UNKNOWN ERROR");
01205 }
01206 }
01207
01208
01209
01210
01211
01212
01213 void WaitFor(int time) {
01214 waitcounter = 0;
01215 while (waitcounter < time);
01216 }
01217
01218
01219
01220
01221
01222
01223 void PollKeypad(void)
01224 {
01225 asm sei;
01226 if (PTH_PTH6 == 1) {
01227 if (pollCounter2 == 1) {
01228 keyPressed = KEY_ONE;
01229 SetBit(KEYPAD_FLAG, flags);
01230 } else if (pollCounter2 == 2) {
01231 keyPressed = KEY_TWO;
01232 SetBit(KEYPAD_FLAG, flags);
01233 } else if (pollCounter2 == 3) {
01234 keyPressed = KEY_THREE;
01235 SetBit(KEYPAD_FLAG, flags);
01236 } else {
01237 keyPressed = KEY_ENTER;
01238 SetBit(KEYPAD_FLAG, flags);
01239 }
01240 } else if (PTH_PTH5 == 1) {
01241 if (pollCounter2 == 1) {
01242 keyPressed = KEY_FOUR;
01243 SetBit(KEYPAD_FLAG, flags);
01244 } else if (pollCounter2 == 2) {
01245 keyPressed = KEY_FIVE;
01246 SetBit(KEYPAD_FLAG, flags);
01247 } else if (pollCounter2 == 3) {
01248 keyPressed = KEY_SIX;
01249 SetBit(KEYPAD_FLAG, flags);
01250 } else {
01251 keyPressed = KEY_CLEAR;
01252 SetBit(KEYPAD_FLAG, flags);
01253 }
01254 } else if (PTH_PTH4 == 1) {
01255 if (pollCounter2 == 1) {
01256 keyPressed = KEY_SEVEN;
01257 SetBit(KEYPAD_FLAG, flags);
01258 } else if (pollCounter2 == 2) {
01259 keyPressed = KEY_EIGHT;
01260 SetBit(KEYPAD_FLAG, flags);
01261 } else if (pollCounter2 == 3) {
01262 keyPressed = KEY_NINE;
01263 SetBit(KEYPAD_FLAG, flags);
01264 } else {
01265 keyPressed = KEY_HELP;
01266 SetBit(KEYPAD_FLAG, flags);
01267 }
01268 } else if (PTH_PTH3 == 1) {
01269 if (pollCounter2 == 1) {
01270 keyPressed = KEY_STAR;
01271 SetBit(KEYPAD_FLAG, flags);
01272 } else if (pollCounter2 == 2) {
01273 keyPressed = KEY_ZERO;
01274 SetBit(KEYPAD_FLAG, flags);
01275 } else if (pollCounter2 == 3) {
01276 keyPressed = KEY_POUND;
01277 SetBit(KEYPAD_FLAG, flags);
01278 } else {
01279 keyPressed = KEY_CANCEL;
01280 SetBit(KEYPAD_FLAG, flags);
01281 }
01282 }
01283
01284
01285 while (PTH_PTH6 || PTH_PTH5 || PTH_PTH4 || PTH_PTH3);
01286
01287 asm cli;
01288
01289 if (flags & KEYPAD_FLAG_MASK) {
01290 if ((keyPressed == KEY_CANCEL) && (!(flags & MASK_CANCEL_MASK))) {
01291 returnState = state;
01292 state = CANCEL_SESSION;
01293 ClearBit(KEYPAD_FLAG, flags);
01294 } else if (!(flags & CHK_KEYPAD_FLAG_MASK)) {
01295 ClearBit(KEYPAD_FLAG, flags);
01296 }
01297 }
01298 }
01299
01300
01301
01302
01303
01304
01305 void PrintReceipt(void)
01306 {
01307 int printcounter = 0;
01308 const char Logo[] = "********************************* \\\\// ** RFID // PRESS ** //\\\\ *********************************";
01309 char DashDash[32] = " -------";
01310 char Total[32] = " Total: $1111.11";
01311 char ThankYou[32] = " Thank you for shopping with us.";
01312 char ComeAgain[32] = " Please come again! ";
01313 char datetime[18] = "11:11AM 11/11/11";
01314 int i, j, itemLen, priceLen, flag = 0;
01315 char datetime2[21] = "11:11:11AM 11/11/11";
01316 char mynumber[3] = "00";
01317 char myprice[9] = "$0000.00";
01318 char temp = ' ';
01319
01320
01321 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01322 SCI0DRH = 0;
01323 SCI0DRL = 0x0D;
01324 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01325 SCI0DRH = 0;
01326 SCI0DRL = 0x0A;
01327
01328
01329 while (printcounter < 160) {
01330 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01331 SCI0DRH = 0;
01332 SCI0DRL = Logo[printcounter];
01333 printcounter++;
01334 }
01335
01336
01337 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01338 SCI0DRH = 0;
01339 SCI0DRL = 0x0D;
01340 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01341 SCI0DRH = 0;
01342 SCI0DRL = 0x0A;
01343 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01344 SCI0DRH = 0;
01345 SCI0DRL = 0x0A;
01346
01347 mynumber[0] = (currSession.timeHrI / 10) + '0';
01348 mynumber[1] = (currSession.timeHrI % 10) + '0';
01349 mystrcpy(&datetime2[0],mynumber,2,2);
01350 mynumber[0] = (currSession.timeMinI / 10) + '0';
01351 mynumber[1] = (currSession.timeMinI % 10) + '0';
01352 mystrcpy(&datetime2[3],mynumber,2,2);
01353 mynumber[0] = (currSession.timeSecsI / 10) + '0';
01354 mynumber[1] = (currSession.timeSecsI % 10) + '0';
01355 mystrcpy(&datetime2[6],mynumber,2,2);
01356 mynumber[0] = (currSession.dateMonthI / 10) + '0';
01357 mynumber[1] = (currSession.dateMonthI % 10) + '0';
01358 mystrcpy(&datetime2[12],mynumber,2,2);
01359 mynumber[0] = (currSession.dateDayI / 10) + '0';
01360 mynumber[1] = (currSession.dateDayI % 10) + '0';
01361 mystrcpy(&datetime2[15],mynumber,2,2);
01362 mynumber[0] = (currSession.dateYearI / 10) + '0';
01363 mynumber[1] = (currSession.dateYearI % 10) + '0';
01364 mystrcpy(&datetime2[18],mynumber,2,2);
01365 mynumber[1] = 'M';
01366 if (currSession.timeHalfI == AM) {
01367 mynumber[0] = 'A';
01368 } else {
01369 mynumber[0] = 'P';
01370 }
01371 mystrcpy(&datetime2[8],mynumber,2,2);
01372
01373 for (j = 0; j < 12; j++) {
01374 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01375 SCI0DRH = 0;
01376 SCI0DRL = ' ';
01377 }
01378
01379 printcounter = 0;
01380
01381 while (printcounter < 20) {
01382 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01383 SCI0DRH = 0;
01384 SCI0DRL = datetime2[printcounter];
01385 printcounter++;
01386 }
01387
01388
01389 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01390 SCI0DRH = 0;
01391 SCI0DRL = 0x0D;
01392 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01393 SCI0DRH = 0;
01394 SCI0DRL = 0x0A;
01395 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01396 SCI0DRH = 0;
01397 SCI0DRL = 0x0A;
01398
01399
01400 for (i = 0; i < currSession.cartSizeI; i++)
01401 {
01402 itemLen = 0;
01403 priceLen = 0;
01404
01405
01406 while (itemLen < 20){
01407 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01408 SCI0DRH = 0;
01409 SCI0DRL = currSession.items[i].itemName[itemLen];
01410 itemLen++;
01411 }
01412
01413
01414 for (j = 0; j < 5; j++) {
01415 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01416 SCI0DRH = 0;
01417 SCI0DRL = ' ';
01418 }
01419
01420 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01421 SCI0DRH = 0;
01422 SCI0DRL = '$';
01423
01424
01425 while (priceLen < 3) {
01426 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01427 SCI0DRH = 0;
01428 SCI0DRL = currSession.items[i].itemPrice[priceLen];
01429 priceLen++;
01430 }
01431
01432 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01433 SCI0DRH = 0;
01434 SCI0DRL = '.';
01435
01436 while (priceLen < 5) {
01437 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01438 SCI0DRH = 0;
01439 SCI0DRL = currSession.items[i].itemPrice[priceLen];
01440 priceLen++;
01441 }
01442
01443
01444 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01445 SCI0DRH = 0;
01446 SCI0DRL = 0x0D;
01447 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01448 SCI0DRH = 0;
01449 SCI0DRL = 0x0A;
01450 }
01451
01452 printcounter = 0;
01453
01454 while (printcounter < 32) {
01455 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01456 SCI0DRH = 0;
01457 SCI0DRL = DashDash[printcounter];
01458 printcounter++;
01459 }
01460
01461
01462 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01463 SCI0DRH = 0;
01464 SCI0DRL = 0x0D;
01465 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01466 SCI0DRH = 0;
01467 SCI0DRL = 0x0A;
01468
01469
01470 temp = (currSession.cartTotalI / 100000) + '0';
01471 if ((temp == '0') && (flag == 0)) {
01472 myprice[1] = ' ';
01473 } else {
01474 myprice[1] = temp;
01475 flag = 1;
01476 }
01477
01478 temp = ((currSession.cartTotalI % 100000) / 10000) + '0';
01479 if ((temp == '0') && (flag == 0)) {
01480 myprice[2] = ' ';
01481 } else {
01482 myprice[2] = temp;
01483 flag = 1;
01484 }
01485
01486 temp = ((currSession.cartTotalI % 10000) / 1000) + '0';
01487 if ((temp == '0') && (flag == 0)) {
01488 myprice[3] = ' ';
01489 } else {
01490 myprice[3] = temp;
01491 flag = 1;
01492 }
01493
01494 temp = ((currSession.cartTotalI % 1000) / 100) + '0';
01495 if ((temp == '0') && (flag == 0)) {
01496 myprice[4] = ' ';
01497 } else {
01498 myprice[4] = temp;
01499 flag = 1;
01500 }
01501
01502 temp = ((currSession.cartTotalI % 100) / 10) + '0';
01503 if ((temp == '0') && (flag == 0)) {
01504 myprice[6] = ' ';
01505 } else {
01506 myprice[6] = temp;
01507 flag = 1;
01508 }
01509
01510 temp = ((currSession.cartTotalI % 10) / 1) + '0';
01511 if ((temp == '0') && (flag == 0)) {
01512 myprice[7] = ' ';
01513 } else {
01514 myprice[7] = temp;
01515 flag = 1;
01516 }
01517
01518
01519 mystrcpy(&Total[24],myprice,8,8);
01520 printcounter = 0;
01521
01522 while (printcounter < 32) {
01523 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01524 SCI0DRH = 0;
01525 SCI0DRL = Total[printcounter];
01526 printcounter++;
01527 }
01528
01529
01530 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01531 SCI0DRH = 0;
01532 SCI0DRL = 0x0D;
01533 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01534 SCI0DRH = 0;
01535 SCI0DRL = 0x0A;
01536 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01537 SCI0DRH = 0;
01538 SCI0DRL = 0x0A;
01539
01540
01541 printcounter = 0;
01542 while (printcounter < 32) {
01543 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01544 SCI0DRH = 0;
01545 SCI0DRL = ThankYou[printcounter];
01546 printcounter++;
01547 }
01548
01549
01550 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01551 SCI0DRH = 0;
01552 SCI0DRL = 0x0D;
01553 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01554 SCI0DRH = 0;
01555 SCI0DRL = 0x0A;
01556
01557 printcounter = 0;
01558 while (printcounter < 32) {
01559 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01560 SCI0DRH = 0;
01561 SCI0DRL = ComeAgain[printcounter];
01562 printcounter++;
01563 }
01564
01565
01566 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01567 SCI0DRH = 0;
01568 SCI0DRL = 0x0D;
01569 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01570 SCI0DRH = 0;
01571 SCI0DRL = 0x0A;
01572 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01573 SCI0DRH = 0;
01574 SCI0DRL = 0x0A;
01575 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01576 SCI0DRH = 0;
01577 SCI0DRL = 0x0A;
01578 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01579 SCI0DRH = 0;
01580 SCI0DRL = 0x0A;
01581 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01582 SCI0DRH = 0;
01583 SCI0DRL = 0x0A;
01584 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01585 SCI0DRH = 0;
01586 SCI0DRL = 0x0A;
01587 while ((SCI0SR1 & SCI0SR1_TDRE_MASK) == 0);
01588 SCI0DRH = 0;
01589 SCI0DRL = 0x0A;
01590 }