VERSION0/TPF0TVersionnumberdetails Version 515 PRJFILEHEADER0TPF0TPrjFileHeaderZpercnt@ZordxZordy Targetfile i2ccard.inc Targetpath'C:\myfiles\microchip\projects\ai2ccard\ Templatefile)C:\WINDOWS\Desktop\picexp\templates\c.txt TargetdevicePIC16F84 TargetMimicDEFAULT Targetclock = PaletteCountSciCount Notes.Strings{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 Arial;}{\f3\fswiss Arial;}{\f4\fmodern Courier New;}{\f5\fswiss Arial;}}{\colortbl\red0\green0\blue0;}.\deflang2057\pard\plain\f2\fs20\b Introductionv\par \plain\f2\fs20 This project demonstrates how to operate the 'I2C card reader (ST14C02)' using a serial interface.\par F\par The target device is a PIC16F84 running at 4Mhz.\plain\f2\fs20\b \par \par Operation \par \plain\f2\fs20 See application code below. When a 256-byte I2C memory card such as the ST Microelectronics ST14C02 is inserted in to the card socket the string "/E01" is transmitted out of the serial port, when the card is removed the string "/E00" is transmitted.\par q\par The card reader/writer responds to the following commands. All commands are appended with a carriage return.\par  \par READ=\par "/Raa" Read 4-bytes of data from hexadecimal address aa.6\par Example: Read 4-bytes of data from address 80hex.\par \tab Command: "/R80" =\par \tab Response: "/Rdddddddd" where dd is hexadecimal data\par  \par WRITED\par "/Waadddddddd" Write 4-bytes of data to hexadecimal address aa.>\par Example: Write 4-bytes of data (1,2,3,4) to address 00hex!\par \tab Command: "/W0001020304"\par \tab Response: "/W"\par  \par QUERY\par "/Q" Query card status.\par Example: Get card status\par \tab Command: "/Q"F\par \tab Response: "/Qdd" where dd=00 card absent, dd=01 card present\par D\par Remember to put the carriage return at the end of each command.\par \par \plain\f2\fs20\b \par Application code \par \plain\f2\fs20 Below is the application code for this project. To use it, select and copy (ctr-insert) the code below, paste it into a text editor and save as a 'C' file in your working directory. You may also need to change the build output path using 'Project | Options'\par \plain\f5\fs20 \par \par [\par \plain\f4\fs16 ///////////////////////////////////////////////////////////////////////L\par //// AI2CCARD.C ////L\par //// ////L\par //// Demonstrates the 'I2C card reader (ST14C02)' sub-circuit. ////L\par //// When an ST140 is inserted into the card socket the ////L\par //// string "/E01" is sent and "/E00" when the card is removed. ////L\par //// "/Waadddddddd" writes data to the card where aa is the ////L\par //// address in hex and DD are four data bytes to write. ////L\par //// "/Raa" reads four bytes of data from address aa. ////L\par //// All commands and responses are appended with a carriage ////L\par //// return. ////L\par //// ////L\par //// This program is an example of how your application code is ////L\par //// is organised. Note the #include "i2ccard.inc", this include ////L\par //// file was generated by QuickBuilder and contains all ////L\par //// dirver code. ////L\par //// ////L\par //// This demo is intended for a PIC16F84 ////L\par //// Compile using CCS 'C' visit www.quickbuilder.co.uk/qb/ccs ////L\par ///////////////////////////////////////////////////////////////////////\par #include <16f84.H>\par  \par #fuses XT,NOPROTECT,NOWDT\par  \par #case\par \par #include "i2ccard.inc"\par \par \par // Comms vars\par int RxCmd = 0;\par int RxData[8];\par int RxIP=0;\par int RxState = 0;\par \par void BlinkLED(void) \{\par LED_1OFF();\par delay_ms(100);\par LED_1ON();\par \}\par !\par int HexToNibble( char c ) \{(\par if ( (c >= '0') && (c <= '9') )\par return c-'0';-\par else if ( (c >= 'A') && (c <= 'F') )!\par return c-('A'-0x0a); \par else\par return 0;\par \}\par \par int GetCommand( void ) \{\par int c,d,n; \par \par :\par if ( RS232_1INCOMING()==0 ) // incomming char\par return 0;\par \par c = RS232_1IN();\par if (c=='/')\par RxState = 0; \par \par switch ( RxState ) \{&\par case 0 : // command start\par RxIP = 0;\par n = 0;@\par RxCmd = RS232_1IN(); // get command char\par RxState = 1;\par break;!\par case 1 : // get dataG\par if (c==0x0d) \{ // end of commad hex data!\par RxState = 0;\par return 1;:\par \} else \{ // get data)\par c = HexToNibble( c);<\par if ( !bit_test(n,0) ) \{ // high nibble/\par RxData[ RxIP ] = c<<4;\par n++;<\par \} else \{ // low nibble,\par RxData[ RxIP] |= c;B\par RxIP++; // inc index and wrap$\par RxIP &=0x7;\par n++;\par \}\par \}\par break;&\par default: // illegal state\par RxState = 0; \par \}\par return 0;\par \}\par \par void DoCommand( void ) \{\par int addr,i,d;\par \par BlinkLED();\par switch (RxCmd) \{2\par case 'R' : // read 4-bytes from card)\par printf(RS232_1OUT,"/R");(\par for (i=0 ; i<4; i++) \{5\par d = ST1402_1READ( RxData[0]++ );2\par printf(RS232_1OUT,"%02X", d);\par \}*\par printf(RS232_1OUT,"\\n");\par break;2\par case 'W' : // write 4-bytes to card (\par for (i=1 ; i<5; i++) \{<\par ST1402_1WRITE( RxData[0]++,RxData[i] );\par \},\par printf(RS232_1OUT,"/W\\n");\par break;,\par case 'Q' : // query card status<\par if ( ST1402_1PRESENT() ) // card present2\par printf(RS232_1OUT,"/Q01\\n");@\par else // card not present2\par printf(RS232_1OUT,"/Q00\\n");\par break;\par +\par default: // unknown command4\par printf(RS232_1OUT,"/?\\n"); \par \}\par RxCmd = 0;\par \par \}\par \par void DoCard( void ) \{#\par static int1 CardPresent=0;\par #\par if (ST1402_1PRESENT() ) \{!\par if (!CardPresent) \{\par BlinkLED();.\par printf(RS232_1OUT,"/E01\\n");\par \}\par CardPresent = 1;\par \} else \{ \par if (CardPresent) \{\par BlinkLED();.\par printf(RS232_1OUT,"/E00\\n");\par \}\par CardPresent = 0; \par \}\par \par \}\par \par main() \{\par INIT_SUB_CIRCUITS();\par BlinkLED();\par \par while(1) \{ \par if ( GetCommand() )\par DoCommand();\par DoCard(); \par \}\par \}\plain\f5\fs20 \par }Title$Serial I2C Smart Card Reader/WritterKeywordssmart;card;serial;reader AltTemplateOptions"buildusedelay=1 buildportdefs=1 SCGENERIC0}wTPF0 tScGenericLibNameC_STANDARD.LIBCctNameRS232 Tranceiver Description$RS232 serial tranceiver using MAX232KeyWordsRS232;Tranceiver;MAX232ScTypeIoCountRefNameRS232_CctAsMetafile.Data ppX.)PT3 EMFp X   XX  ``K@0 qiqi& % 6% ( & % 6% (  RL<Arial{% T`].m7= @= @aLTVCC%&% (   & % 6 % (    & % 6< % (    & % 6 % (   0 & % 60 % (     & % '% +m   % (  % (   $ & % % 6l $ % (  RL<Arial8 h P 8 % ( % (  8 & % % 6xP % (   % TTlu= @= @ LP1% (   & % 6 % (  RL<Arial% 6l ` %( % Tx= @= @ L\T1 [??]((((((%% T`.:= @= @ LTRXi% % ( RL<Arial(   & % % 6x % (    & % 6x % % TXJQ= @= @L LP13% (   & % 6 % (  RL<Arial% Tx= @= @m L\T2 [??]((((((% (  xP & % % T`,:= @= @ LTRXo&% ( RL<Arial % 6 %     & % 6 % (   &$%  % TXJQ= @= @L LP12% (  P & % 6P % (  RL<Arial% T`/:= @= @ 1 LTTXi % ( RL<Arial{{{{% TXJQ= @= @L LP11% (   & % 6 % (  RL<Arial{{{{i% TXJQ= @= @LM LP10% (   & % 6 % (  RL<Arialb\default.htt% TTJM= @= @L LP9% (   & % 6 % (  RL<Arialfolder.htt% T`-:= @= @ } LTTXo % ( RL<Arial Q|Q:i+00#C:\1&.Windows1&DesktopDESKTOP1H+picexpPICEXP Q<Qh+&klibsourceLIBS~11W,,SerialSERIAL"2pV,u rs232.emfRS232.E!% TXJQ= @= @L] LP14% (  ` & % 6` % (  RL<ArialpDESKTOP1H+picexpPICEXP!1h+&kbsourceLIBSOU~11W,,SerialSERIAL8'QO :i+00#C:\1&.Windows1&DesktopDESKTOP1H+picexpPICEXP!1h+,% T`){:= @= @ A LTGND&%&% ( RL<Arial% TXJvQ= @= @L! LP15% (   ` & % 6l ` % (  RL<Arial% TTv= @= @ ! LP2% (    & % 6l  % (  RL<Arial% TT= @= @ LP5% (   P & % 6l P % (  RL<Arial{{{{% TT= @= @  LP6% (   & % 6l % (  RL<Arial{{{{% TT= @= @ M LP7% (   & % 6l % (  RL<Arial{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{% TT= @= @ LP8% (   & % 6l % (  RL<Arial% TT= @= @ LP4% (   & % 6l % (  RL<Arial% TT= @= @ ] LP3% (  $ & % 6$ % (  RL<Arial% T`*q:z= @= @  LTVCC%&% ( RL<Arial% TXJlQu= @= @LLP16% ( RLZArial% Tp^$k= @= @g LXMAX23222+&%&% (    & % '% +  Z % (  % (    & % '% +Z s Z % (  % (  \ $ & % % 6P $ % (    $ & % 6 $ % (   z  & % 6\ % (   z $ & % 6\  % (   z B & % 6\ $ % (   z ` & % 6\ B % (    $ & % 6 $ % (    $ & % 6P $ % (  RL<Arial{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{% T`ir= @= @ LT1uF% (    & % '% +Z  s % (  % (    & % '% +  % (  % (   P & % % 6 P % (   \ P & % 6P P % (    2 & % 6  % (    P & % 6 2 % (    n & % 6 P % (    & % 6 n % (    P & % 6P P % (    P & % 6 P % (  RL<Arial  & % 6 % (    & 6< % (  % T`= @= @ r LT1uF% (    & % '% +A % (  % (    & % '% +A  / % (  % (  | 4 & % % 6| @ % (   | & % 6| % (     & % 6 4 % (   |  & % 6 4 % (   ^  & % 6| 4 % (   @  & % 6^ 4 % (   | & % 6| % (   | | & % 6| @ % (  RL<Arial ( RL<Arial(   & % % 6x% (   % T`= @= @ LT1uF% (    & % '% +  l% (  % (    & % '% +  l% (  % (   4& % % 6 4% (    4& % 6 4% (    R& % 6 p% (    4& % 6 R% (    & % 6 4% (    & % 6 % (   \ 4& % 6 4% (   l 4& % 6 4% (  RL<Arial% T`/:@= @ 1 LTTXi% T`>G= @= @I LT1uF% (    & % '% *(:% (  % (    & % '% *m  % (  % (    & % '% *I o4 % (  % (  F$ & % % 6$ % (  RL<Arial TXJQ= @= @LM LP10% (   & %6 % (  R% Tpqz= @= @ LXTX_OUT %&% (    & % '% *I o % (  % (  F & % % 6 % (  RL<ArialRL<Arifolder.htt% Tl= @= @} LXRX_IN@& &% (  X &$% 6 % (     & % 'z% V,X X v X % (  % ( % RL<ArialQ= @= @L] LP14% (  ` & % 6% (  RL<TO% T= @= @ LlTARGET ________0 %& % (    & % 'z% V,8 h P 8 % (  % (  8 & % % 6xP % (   h & % 6xP % (  RL<Arial% TXJvQ@= @L! LP15% (   ` &% 6l ` % ( % T= @= @ LdT1 ________ % (    & % 'z% V,    % (  % (   & % % 6x % (    & % 6x % (  RL<Arial TT= @= @ L% T= @= @m LdT2 ________ % (  xP & % 6P % (   P & % 6 % (   x & % 6 % (    & % 6 % (   &$% W$  % (   & % W$vv $  $ % (   & % W,v $  $ % (   & % W, P  P % (   & % W(     P % (   & % W( P | P | % (   & % W,P ` | ` | 4l 4% (   & % W$fFfP4% (   & % W(SPfv$ $ 4% (   & % W$#PfP\ 44% (   & % W$ff | % (   & % W(Sf` ` | % (   & % W0f| | | | | % (   & % W,Sv < <$ $ % (   & % W,S x x  % (   & % W$SzxP P % (   & % W,Szx    % (   SwModuleAsStrings.Strings//
 //
*/4#use RS232(BAUD=_BD_,XMIT=PIN_TP_TX_,RCV=PIN_RP_RX_)//*****************int RS232_IN() { return getch(); }//*****************void RS232_OUT(int c) { putc(c); }//*****************int RS232_INCOMING() { return kbhit(); } ///section> PartCountPreScale? SCGENERIC0TPF0 tScGenericLibNameC_STANDARD.LIBCctNameLED Description Single LEDKeyWords LED;singleScTypeIoCountRefNameLED_CctAsMetafile.Data XC4Y% EMF X   XX  ``K@0       & % 'z% V,`sX% (   % ( & % % 6X% ( & % 6 % ( & % 6*% ( *& % 6*% ( *& % 6 % (  & % 6 % (  & % 6% ( H& % 6% ( & % 6% (  RLZArial% TX= @= @MLPD1+&% (    & % '% +~% (  % (  & % % 6% (    & % 6% (  RLZArial{% TXsVc= @= @LPR1+&% ( RL<Arial{% Tdsdm= @= @rLT100R&% (  8& % 6t% (   Xt& % 6t% (   v& % 6% (   & % 6% (     & % 'z% V,C?MG% (  % (  & % % 6% (   & % 6% (  RLHCourier New% TT4?= @= @C L`T1 ______&%&%&%&%&% (  & % W$j}jH % (   & % W$jj8% (   & % W(VCjM% (   SwModuleAsStrings.Strings//
//
*/#define P__ PORT_P_,_b_#define TRISP__ TRIS_P_,_b_#define LED_ON() bit_set(*P__)!#define LED_OFF() bit_clear(*P__)//******************int LED_SET(int state) { if ( bit_test(state,0) ) bit_set(*P__); else bit_clear(*P__);}//******************int LED_GET() { if (bit_test(* P__) ) return(1); else return(0);}//******************void LED_INIT() {#asm BSF _RP0 BCF TRISP__#endasm } ///SECTION>//
PartCountPreScale? SCGENERIC0TPF0 tScGenericLibNameC_STANDARD.LIBCctNameI2C card reader (ST14C02) DescriptioniCard reader for I2C cards such as the ST14C02. Read/write to memory locations, card insert detection etc.KeyWordsST14C02;SMART;CARD;READERScTypeIoCountRefNameST1402_CctAsMetafile.Data ||XE D;6 EMF|   XX  ``K@0 qiqi T& % 6 % (  & % 6" % (  RL<Arial{{{% T`@UU@ LTVCC%&% (   & % 6 % (   P & % 6 % (   n  & % 6  % (    0 & % 6 0 % (     & % '% +`  G% (  % (  $ 4& % % 6` 4% (   P 4& % 6 4% (  RLZArial{{{% TXlBxO@UU@LPR3+&% ( RL<Arial{{% TdAJ@UU@\ LT100R&% (    & % '% +s ; % (  % (   | & % % 6 @ % (    P & % 6 % (  RLZArial{% TX@UU@ LPR6+&% ( RL<Arial% T`@UU@ LT10K% (    & % '% *a Mt `% (  % (    & % '% *a t % (  % (  r & % % 6 b% (   l & % 6l % (   l D& % 6l >% (   | & % 6l % (   l D& % 6l % (   | 4& % 6l 4% (   l & % 6l 4% (    $ & % 6| $ % (    & % 6| % (     & % 6|  % (   & % U,   % (   & % U,   % (   & % U,  !  ,  , % (   & % U,     % (   & % U,vz $ 1  <  < % (   & % U,sv $    % (  RL<Arial4 P~XTtqs0t  i/s0 ittpUp i͍U0 ih itt8)c0 A4 i)z4 i A4S0 A0 A4 i i*4 i4 i4 ipa<4 i ipa0 it  p t% T`r{@UU@0  LTSDA&% ( RL<Arial>Rpa8 i[K:8VCk:;il ipah it i<'ddda͒lq;;tŒ[œ[[Q 4iͧ`1 it[i1Z% T`@UU@0 ~ LTSCL&% ( RL<ArialP1$1 t(i+t@iq]0 atdix-p a a at a͐ a aQ^hp b$| |A!| |'!|b$|M|% T`@UU@0 LTGND&%&% (   p& % 6 P % (    p& % 6 p% (    P & % 6 P % (    p& % 6 P % (   & % U,cg    % (   & % U,_c    % (    & % 6| % (  RL<Arial abcdefghijklmnopqrstuvwxyzABCDEFGJKLMNOPQRSTUVWXYZ% T`^g@UU@0 LTVCC%&% ( RL<Arial% TX@UU@ LPSW2% ( RL<Arial% TXFO@UU@ LPSW2% ( RL<Arial% T E@UU@@ L|I2C SMART CARD CONNECTOR & ,& %&% %&%&&%&% (  | & % 6| % (   | & % 6 % (    & % 6 % (    & % 6| % (  RL<Arial% Td4@UU@ LTCARD,%,,% (  @ & % 6| % (   @ 4& % 6| 4% (   @ $ & % 6| $ % (  RL<ArialƇڇ (0HbvȈ .BPf~ԉ0@^n̊܊*>N^n~ԋ ,% TTlu@UU@' LP3g% (  @ & % 6| % (  RL<ArialonEnterCriticalSectionExitThread,CloseHe8TlsGetValueZGetLastErrorResumeThreadeCreateThread7TlsFreeSetLastError1GetCurrentThread6TlsAllocFiNextFileAFindFirstFileAFindCloseFindNextFileWFind% TT@UU@' ] LP4Re% (  @  & % 6|  % (  RL<ArialmentStringsFreeEnvironmentStringsWiWideCharToiByteAGetEnvironmentStringsWInitializeCriticalSectionBUnhandledExceptionFilter LCMapStringA!LCMapStringWGetSingTypeAGetStringTypeWSetConsoleCtrlHandler~QueryPerGe% TX@UU@ LP15% (  @ & % 6| % (  RL<Arial[VirtualProtectGetSystemInfo]VirtualQueryushFileBuffersSetFilePointer SetStdHandle2CompareStringA3CompareStringW)SleepBeepFileTimeToSystemTimeFileTimeToLocalFileTime9GetDiskFreeSpaceAaGetLogicalDriveste% TXYb@UU@ mLP16% ( RLZArialributesW.GetCurrentDirectoryWSetCurrentDireyWSetFileAttributesWTGetFullPathNameWECreateDirectoryWyDeleteFileWMMoveFileWRemoveDirectoryW>GetDriveTypeJMoveFileARaiseExceptionIsBadReadPtrSetUnhandledExtE% TX @UU@@ 8LPJ1&% ( RL<ArialModeIsDBCSLeadByteExGetConsoleCPReadCoeWSetEndOfFilekWriteConsoleA"GetConsoleOutputCPuWriteConsoleWDuplicateHandleLGetFileInformationByHandlelPeNamedPipeReadConsoleInputAjPeekConsoleInputAzGetNumberOnp% T@UU@@ LlMOLEX91322-0004eT,&% (   & % 6$  % (    & % 6$ % (    & % 6 % (    & % 6@ % (   | & % 6@ % (    & % 6 % (  RLZArial% TXQ]@UU@9 LPC1+&% ( RL<Arial  XX  ``K@0 qiqi T& % 6 % TdQ`@UU@9 LT100n% (   & % 6 % (    & % 6$ % (    & % 6  % (   0 & % 60 % (     & % 'p% *% (  % (    & % '% +`   4 % (  % (  P $ & % % 6 $ % (   $ $ & % 6` $ % (  RLZArial 6` 4% (  P 4& % 6 4% (  LZArial% TXog{t@UU@LPR4+&% ( RL<Arial% TXlBxO@UU@LPR3+&% ( L<Arial% Tdhq@UU@ LT820R&% (    & % '% +`  % (  % (  P & % % 6 % (   $ & % 6` % (  RLZArial 6 @ % (   P & % 6 % (  LZArial% TXoz{@UU@9 LPR5+&% ( RL<Arial% TX@UU@ LPR6+&% ( L<Arial% Td|@UU@ F LT820R&% (    & % 'z% V, &-\,D\% (  % (  \& % % 6D% (   ,& % 6D% (  RL<Arial% *a t %   % (  r & % %  b% (   % TA$@UU@ L`T1 ______ % (    & % 'z% V, sz<  $ < % (  % (  < & % % 6$ % (    & % 6$ % (  RL<Arial $ & % | $ % (    & % 6 % (   % ThAq@UU@ L`T2 ______ % (    & % 'z% V,     % (  % (   & % % 6 % (    & % 6 % (  RL<Arial% (   & % U,sv $    % (  RLArial4 P~% T{A@UU@A L`T3 ______ % (   &$% 6T % (     & % 'z% V,      % (  % ( % RL<Arial[œ[[Q 4iͧ`1 i[i1Z% T`@UU@0 ~ LTSCL&% ( % TO @UU@ LhTARGET ______i %& % (  T&$% 6T % (   T& % 6D% (   $ & % 6T% (    & % 6T` % (     & % '% +`  % (  % (  $ & % % 6` % (   P & % 6 % (  RLZArial  & % 6| % (  RL<Arial % TXl/x<@UU@fLPR1+&% ( RL<Arial% T`^g@UU@0 LTVCC%&% ( RL<Aria% T`.7@UU@\ aLT10K% (    & % '% * ( :% (  % (    & % '% * ( % (  % (    & % '% *  % (  % (    & % '% * ( :% (  % (   & % % 6 % (    & % 6@ % (     & % 6"  % (    0 & % 6 0 % (     & % '% +G% (  % (  4& % % 64% (   4& % 64% (  RLZArial% TX8FDS@UU@LPR2+&% ( RL<Arial6| % (   @ 4& % 6| 4% (  @ $ & % % T`8TD]@UU@MLT10K(% (    & % '% *  % (  % (    & % '% *( : % (  % (  & % % W$ | % (   & % W$mm|  % (   & % W(mPvc$ 44% (   & % W$mcc@ % (   & % W$mcm % (   & % W$vv@ $ P $ % (   & % W$@ P % (   & % W$PP@ 4 4% (   & % W$cvvv$ $ $ % (   & % W$ vcv$ $ % (   & % W(c=vv$ $ % (   & % W$=P 4 % (   & % W$==P  % (   & % W( *=D D % (   & % W$PPP 4 4% (   & % W$PP 4 4% (   & % W$P P 4% (   & % W(@     % (   & % W$  T % (   & % W$  @  % (   & % W(P =44 % (   & % W$Pv$ 4 % (   & % W$ P 4 % (   & % W$PmP44 % (   SwModuleAsStrings.Strings//
//
*/#if 0 // debug=1#define PIN_PDA_SDA_ PIN_B1#define PIN_PCL_SCL_ PIN_B0#define PORTPSW_ PORTB#define TRISPSW_ TRISB##define _SW_ 2 #endif=// ------------------ modified by script -------------------- #define DATA__ PIN_PDA_SDA_ #define CLOCK__ PIN_PCL_SCL_"#define SW__ PORTPSW_, _SW_"#define TRISSW__ TRISPSW_, _SW_=// ----------------------------------------------------------#define I2CADDR__ 0xa0(#use i2c(master,sda=DATA__, scl=CLOCK__)//*******************int ST1402_READ(int addr) { int r; output_low(CLOCK__); output_high(DATA__); i2c_start(); i2c_write(I2CADDR__); i2c_write(addr); i2c_start(); i2c_write(I2CADDR__ | 1); r=i2c_read(0); i2c_stop(); return(r); output_low(CLOCK__); output_low(DATA__);}//*******************&void ST1402_WRITE(int addr,int data) { output_low(CLOCK__); output_high(DATA__); i2c_start(); i2c_write(I2CADDR__); i2c_write(addr); i2c_write(data); i2c_stop(); delay_ms(20); output_low(CLOCK__); output_low(DATA__);}//*******************int ST1402_PRESENT( void ) { if (bit_test(*SW__) ) return 1; else return 0;}//*******************void ST1402_INIT() { output_low(CLOCK__); output_low(DATA__);9 bit_set( *TRISSW__); // config detection sw as input} ///section>//
PartCountPreScale? CCTOBJ0}TPF0tcctobjscaleʀ?qordxqordy IoSelectArray.Strings-1910-1-1-1-1-1 headertextRS232_1 footertextSerial communications interfaceparentfrmmain.pnSheettop#leftcctnameRS232 TranceiverrefnameRS232_1 Annotated swincluded ScGeneric.OwnerIDEnabled SelectSheetNumPropertyValue.Strings-1-1-13599-1-1-1-1 CCTOBJ0TPF0tcctobjscaleʀ?qordxqordyIoSelectArray.Strings-111-1-1-1-1-1-1 headertextLED_1 footertextBPower and activity indicator On = power Blink = command activityparentfrmmain.pnSheettopleftTcctnameLEDrefnameLED_1 Annotated swincluded ScGeneric.OwnerIDEnabled SelectSheetNumPropertyValue.Strings-1-1-1-1-1-1-1-1 CCTOBJ0XTPF0tcctobjscaleʀ?qordxQqordyIoSelectArray.Strings-1876-1-1-1-1 headertextST1402_1parentfrmmain.pnSheettopleftcctnameI2C card reader (ST14C02)refnameST1402_1 Annotated swincluded ScGeneric.OwnerIDEnabled SelectSheetNumPropertyValue.Strings-1-1-1-1-1-1-1-1