⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i2crtc.lst

📁 lcd interface code for lpc214x series micro controllers
💻 LST
字号:
ARM COMPILER V0.07,  I2CRTC                                                                24/11/04  10:12:49  PAGE 1   


ARM COMPILER V0.07, COMPILATION OF MODULE I2CRTC
OBJECT MODULE PLACED IN I2CRTC.OBJ
COMPILER INVOKED BY: C:\KEIL\ARM\BIN\CA.EXE I2CRTC.c TABS(4) 

stmt  level    source

    1          #include "reg591.h"
*** ERROR C318 IN LINE 1 OF I2CRTC.c: can't open file 'reg591.h'
    2          #include "i2crtc.h"
    3          
    4          #define RTC_ADDRESS 0xA2                 // I2C address of Real Time Clock
    5          #define TIMEOUT 0xAA0F                   // timer reload value gives 22ms timeout period
    6                                                   // for waiting on SLAve address + Write ack
    7          
    8          void init_i2c(void);
    9          void rtc_write_byte(unsigned char address, unsigned char byte);
   10          unsigned char rtc_read_byte(unsigned char address, unsigned char maskoff);
   11          unsigned char bcdtochar(unsigned char bcdnum);
   12          unsigned char chartobcd(unsigned char n);
   13          void i2c_isr(void);
   14          void start_timer(void);
   15          void stop_timer(void);
   16          
   17          unsigned char mask[] = {0xA8, 0x1F, 0x7F, 0x7F, 0x3F, 0x3F, 0x07, 0x1F,
   18                                  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
   19                                                    // mask values for registers
   20          
   21          enum i2c_states { DATA_BYTE, FINISHED, DUMMY_WRITE }; // states of operations
   22                                                                // during a write the DATA_BYTE state is when the n
             -ext byte to
   23                                                                // be written is the data byte. The FINISHED state is when the
   24                                                                // data byte has been written
   25                                                                // during a read the DUMMY_WRITE is the state during the dummy
   26                                                                // write to set the register address to read
   27          enum i2c_operations { READ, WRITE };                  // possible I2C operations are Read and Write
   28          
   29          unsigned char i2c_storage_address;                    // holds the address of the register to read or wri
             -te
   30          unsigned char i2c_byte;                               // holds the value to write or the value read from 
             -a register
   31          unsigned char i2c_state;                              // holds the I2C state - DATA_BYTE, FINISHED or DUM
             -MY_WRITE
   32          unsigned char i2c_status;                             // holds the status - I2C_BUSY, I2C_OK or I2C_ERROR
   33          unsigned char i2c_operation;                          // holds the operation - READ or WRITE
   34          
   35          // function init_i2c
   36          // initializes the I2C peripheral
   37          void init_i2c(void)
   38          {
   39   1        P1M1 |= 0xC0;                      // set P1.6 and P1.7 open drain
*** ERROR C67 IN LINE 39 OF I2CRTC.C: 'P1M1': undefined identifier
   40   1        P1M2 |= 0xC0;
*** ERROR C67 IN LINE 40 OF I2CRTC.C: 'P1M2': undefined identifier
   41   1        TMOD |= 0x01;                      // timer 0 mode 1
*** ERROR C67 IN LINE 41 OF I2CRTC.C: 'TMOD': undefined identifier
   42   1        ES1 = 1;                           // enable SIO1 interrupts
*** ERROR C67 IN LINE 42 OF I2CRTC.C: 'ES1': undefined identifier
   43   1        EA = 1;                            // global interrupt enable
*** ERROR C67 IN LINE 43 OF I2CRTC.C: 'EA': undefined identifier
   44   1      }
   45          
   46          // function chartobcd
   47          // converts a decimal value to the BCD equivalent
   48          // decimal values must be stored in the Real Time Clock in BCD format
   49          // passed is the decimal value to convert
ARM COMPILER V0.07,  I2CRTC                                                                24/11/04  10:12:49  PAGE 2   

   50          // returned is the BCD equivalent
   51          unsigned char chartobcd(unsigned char n)
   52          {
   53   1        return ((n / 10) << 4) | (n % 10);  
   54   1      }
   55          
   56          // function bcdtochar
   57          // converts a number in BCD format to the decimal equivalent
   58          // decimal values must be stored in the Real Time Clock in BCD format
   59          // passed is the BCD format value
   60          // returned is the decimal equivalent
   61          unsigned char bcdtochar(unsigned char bcdnum)
   62          {
   63   1        return (bcdnum & 0x0f) + (bcdnum >> 4) * 10;
   64   1      }
   65          
   66          // function rtc_write_byte
   67          // stores a byte in a specific register in the Real Time Clock
   68          // passed is the register address and the byte to store
   69          // nothing is returned
   70          // result of the operation is stored in i2c_status and may be
   71          // I2C_OK or I2C_ERROR
   72          void rtc_write_byte(unsigned char address, unsigned char byte)
   73          {
   74   1        i2c_storage_address = address;     // copy the register address
   75   1        i2c_byte = chartobcd(byte);        // convert to BCD and copy the byte
   76   1        i2c_status = I2C_BUSY;             // I2C is now busy
   77   1        i2c_operation = WRITE;             // a write operation is being performed
   78   1        S1CON = 0x40;                      // enable the I2C perhiperal
*** ERROR C67 IN LINE 78 OF I2CRTC.C: 'S1CON': undefined identifier
   79   1                                           // no acknowledgements will be returned
   80   1        STA = 1;                           // request a start condition is transmitted
*** ERROR C67 IN LINE 80 OF I2CRTC.C: 'STA': undefined identifier
   81   1                                           // therefore putting I2C perhiperal in Master Transmitter mode
   82   1        while(i2c_status == I2C_BUSY);     // wait until I2C is not busy
   83   1      }
   84          
   85          // function rtc_read_byte
   86          // reads a byte from a specific register in the Real Time Clock, performing
   87          // optional masking of the result
   88          // passed is the address of the register to read and a flag to indicate
   89          // if masking is required - may be MASK or NOMASK
   90          // the decimal value is returned
   91          // result of the operation is stored in i2c_status and may be
   92          // I2C_OK or I2C_ERROR 
   93          unsigned char rtc_read_byte(unsigned char address, unsigned char maskoff)
   94          {
   95   1        i2c_storage_address = address;     // copy the register address
   96   1        i2c_status = I2C_BUSY;             // I2C is now busy
   97   1        i2c_operation = READ;              // read operation is being performed
   98   1        i2c_state = DUMMY_WRITE;           // initially a dummy write has to be
   99   1                                           // performed to set the register address
  100   1        S1CON = 0x40;                      // enable the I2C peripheral
*** ERROR C67 IN LINE 100 OF I2CRTC.C: 'S1CON': undefined identifier
  101   1                                           // no acknowledgements will be returned
  102   1        STA = 1;                           // request a start condition is transmitted
*** ERROR C67 IN LINE 102 OF I2CRTC.C: 'STA': undefined identifier
  103   1                                           // therefore putting I2C peripheral in Master Transmitter mode
  104   1        while(i2c_status == I2C_BUSY);     // wait until I2C is no longer busy
  105   1        if (maskoff) i2c_byte &= mask[address];  // mask result if required
  106   1        return bcdtochar(i2c_byte);        // convert to decimal and return result
  107   1      }
  108          
  109          // function start_timer
  110          // sets up and starts timer 0 - start of timeout period
  111          // nothing is passed. nothing is returned
ARM COMPILER V0.07,  I2CRTC                                                                24/11/04  10:12:49  PAGE 3   

  112          void start_timer(void)
  113          {
  114   1        TL0 = TIMEOUT & 0xFF;              // set up timer 0 reload value
*** ERROR C67 IN LINE 114 OF I2CRTC.C: 'TL0': undefined identifier
  115   1        TH0 = (TIMEOUT >> 8) & 0xFF;
*** ERROR C67 IN LINE 115 OF I2CRTC.C: 'TH0': undefined identifier
  116   1        TR0 = 1;                           // start timer 0
*** ERROR C67 IN LINE 116 OF I2CRTC.C: 'TR0': undefined identifier
  117   1      }
  118          
  119          // function stop_timer
  120          // stops timer 0 and clears overflow flag
  121          // nothing is passed. nothing is returned
  122          void stop_timer(void)
  123          {
  124   1        TR0 = 0;                           // stop timer 0
*** ERROR C67 IN LINE 124 OF I2CRTC.C: 'TR0': undefined identifier
  125   1        TF0 = 0;                           // clear overflow flag
*** ERROR C67 IN LINE 125 OF I2CRTC.C: 'TF0': undefined identifier
  126   1      }
  127          
  128          // function i2c_isr
  129          // I2C interrupt service routine
  130          // the interrupt is triggered on each I2C event. The I2C peripheral state
  131          // is stored in the S1STA SFR
  132          // different actions are performed depending on the peripheral state
  133          // nothing is passed. nothing is returned.
  134          // Note: if debugging printfs are inserted into this function the execution
  135          // will be slowed down to the point where the timeout occurs.
  136          void i2c_isr(void) interrupt 5 using 1
*** WARNING C34 IN LINE 136 OF I2CRTC.C: 'interrupt': missing declaration specifiers
*** ERROR C42 IN LINE 136 OF I2CRTC.C: 'interrupt': not in formal parameter list
*** ERROR C25 IN LINE 136 OF I2CRTC.C: syntax error near '5'
*** WARNING C34 IN LINE 136 OF I2CRTC.C: 'using': missing declaration specifiers
*** ERROR C42 IN LINE 136 OF I2CRTC.C: 'using': not in formal parameter list
  137          {
  138            switch(S1STA)
  139            {
*** WARNING C34 IN LINE 139 OF I2CRTC.C: 'S1STA': missing declaration specifiers
*** ERROR C42 IN LINE 139 OF I2CRTC.C: 'S1STA': not in formal parameter list
*** ERROR C25 IN LINE 139 OF I2CRTC.C: syntax error near '{'
  140              // START CONDITION TRANSMITTED
  141              case 0x08:
  142                STA = 0;                       // clear flag so another start condition is not transmitted
*** ERROR C142 IN LINE 142 OF I2CRTC.C: illegal initialization
*** ERROR C53 IN LINE 142 OF I2CRTC.C: redefinition of 'STA': different basic types
  143                start_timer();                 // start timer to measure timeout period
*** ERROR C42 IN LINE 143 OF I2CRTC.C: 'start_timer': not in formal parameter list
  144                S1DAT = RTC_ADDRESS & 0xFE;    // transmit Slave Address + Write command (SLA + W)
*** ERROR C142 IN LINE 144 OF I2CRTC.C: illegal initialization
  145                break;
*** ERROR C25 IN LINE 145 OF I2CRTC.C: syntax error near 'break'
  146              // REPEATED START CONDITION TRANSMITTED
  147              case 0x10:
  148                STA = 0;                       // clear flag so another start condition is not transmitted
*** ERROR C53 IN LINE 148 OF I2CRTC.C: redefinition of 'STA': different basic types
*** ERROR C73 IN LINE 148 OF I2CRTC.C: sizeof illegal operand taken
  149                if (i2c_operation == READ && i2c_state != DUMMY_WRITE)  // if performing a read and we have complet
             -ed the dummy write then...
*** ERROR C25 IN LINE 149 OF I2CRTC.C: syntax error near 'if'
*** ERROR C25 IN LINE 149 OF I2CRTC.C: syntax error near '=='
*** ERROR C25 IN LINE 149 OF I2CRTC.C: syntax error near '&&'
*** ERROR C25 IN LINE 149 OF I2CRTC.C: syntax error near '!='
*** ERROR C25 IN LINE 149 OF I2CRTC.C: syntax error near ')'
  150                {
  151                  S1DAT = RTC_ADDRESS | 0x01;  // transmit Slave Address + Read command (SLA + R)
ARM COMPILER V0.07,  I2CRTC                                                                24/11/04  10:12:49  PAGE 4   

  152                }
*** ERROR C25 IN LINE 152 OF I2CRTC.C: syntax error near '}'
  153                else
  154                {
  155                  S1DAT = RTC_ADDRESS & 0xFE;  // transmit Slave Address + Write command (SLA + W)
  156                                               // this situation arises when no response was received from the
  157                                               // Real Time Clock and another attempt is being made
  158                }
*** ERROR C25 IN LINE 158 OF I2CRTC.C: syntax error near '}'
  159                break;
  160              // SLAVE ADDRESS + WRITE TRANSMITTED - ACK RECEIVED
  161              case 0x18:
  162                stop_timer();                  // stop timer - response was received within the timeout period
*** ERROR C53 IN LINE 162 OF I2CRTC.C: redefinition of 'stop_timer': different return types
  163                S1DAT = i2c_storage_address;   // transmit the register address
*** ERROR C143 IN LINE 163 OF I2CRTC.C: 'scalar': initializer is not a constant
  164                i2c_state = DATA_BYTE;         // next byte to be sent is the data byte
*** ERROR C53 IN LINE 164 OF I2CRTC.C: redefinition of 'i2c_state': different basic types
  165                break;
*** ERROR C25 IN LINE 165 OF I2CRTC.C: syntax error near 'break'
*** ERROR C7 IN LINE 165 OF I2CRTC.C: compilation aborted

ARM COMPILATION COMPLETE.  3 WARNING(S),  39 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -