home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s220 / 2.ddi / BIO51.C next >
Encoding:
C/C++ Source or Header  |  1988-02-10  |  2.1 KB  |  82 lines

  1. /*    BIO51.C
  2.  
  3. Tests the in-line pre-defined functions (enabled with the '-e' option)
  4. of the 8051 C-compiler system.
  5.  
  6. Note: ICE = Integral Constant Expression
  7.       SFR = Special Function Register
  8.  
  9. The in-line functions conceptually work like the following ANSI-type
  10. (casts performed automatically) function declarations:
  11.  
  12.         =======================================
  13.         == Read any internal RAM/SFR address ==
  14.         == Read value: 0 - 255             ==
  15.         =======================================
  16.  
  17. unsigned char input(ICE address);
  18.  
  19.  
  20.  
  21.         ===========================================
  22.         == Write to any internal RAM/SFR address ==
  23.         == Written value: 0 - 255                ==
  24.         ===========================================
  25.  
  26. void output(ICE address, unsigned char data);
  27.  
  28.  
  29.  
  30.         ===========================================
  31.         == Read any internal RAM/SFR bit address ==
  32.         == Read value: 0 or 1                 ==
  33.         ===========================================
  34.  
  35. unsigned char read_bit(ICE bit_address);
  36.  
  37.  
  38.  
  39.         ==========================================
  40.         == Set any internal RAM/SFR bit address ==
  41.         ==========================================
  42.  
  43. void set_bit(ICE bit_address);
  44.  
  45.  
  46.  
  47.         ============================================
  48.         == Clear any internal RAM/SFR bit address ==
  49.         ============================================
  50.  
  51. void clear_bit(ICE bit_address);
  52.  
  53.  
  54.  
  55.         =============================================
  56.         == Read and clear any internal RAM/SFR bit ==
  57.         == address using the JBC instruction       ==
  58.         == Read value: 0 or 1                       ==
  59.         =============================================
  60.  
  61. unsigned char read_bit_and_clear(ICE bit_address);
  62.  
  63.  
  64. */
  65.  
  66. #include "io51.h"
  67.  
  68. static char c;
  69.  
  70. void main(void)
  71.   {
  72.     output(P0,c);        /* Clear P0.0 - P0.7 */
  73.     set_bit(P0_1_bit);        /* Raise P0.1 */
  74.     clear_bit(P0_1_bit);    /* And down with it again */
  75.     if (! read_bit(P0_1_bit))
  76.       c = input(P0);        /* Get that byte */
  77.     set_bit(P0_1_bit);        /* Raise P0.1 */
  78.     if (read_bit_and_clear(P0_1_bit))
  79.       c = input(P0);        /* Get that byte */
  80.     output(0x182,c);            /* And write it into internal RAM[130] */
  81.   }
  82.