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

📄 main.lst

📁 达拉斯 1-Wire 主机通信 这份资料展示了如何把 1-Wire 主机通信在应用到一个AVR系统中
💻 LST
📖 第 1 页 / 共 4 页
字号:
   \   0000001E   01FC                       MOVW    R31 : R30,R25 : R24
   \   00000020   0FE0                       ADD     R30,R16
   \   00000022   1FF1                       ADC     R31,R17
   \   00000024   8290                       ST      Z,R9
    163                  for (j = 0; j < 8; j++)
   \   00000026   2466                       CLR     R6
   \                     ??SearchBuses_2:
   \   00000028   E008                       LDI     R16,8
   \   0000002A   1660                       CP      R6,R16
   \   0000002C   F490                       BRCC    ??SearchBuses_3
    164                  {
    165                      devices[i].id[j] = 0x00;
   \   0000002E   E000                       LDI     R16,0
   \   00000030   2E90                       MOV     R9,R16
   \   00000032   2F4B                       MOV     R20,R27
   \   00000034   E050                       LDI     R21,0
   \   00000036   E009                       LDI     R16,9
   \   00000038   E010                       LDI     R17,0
   \   0000003A   ........                   CALL    ?S_EC_MUL_L02
   \   0000003E   01FC                       MOVW    R31 : R30,R25 : R24
   \   00000040   0FE0                       ADD     R30,R16
   \   00000042   1FF1                       ADC     R31,R17
   \   00000044   2D06                       MOV     R16,R6
   \   00000046   E010                       LDI     R17,0
   \   00000048   0FE0                       ADD     R30,R16
   \   0000004A   1FF1                       ADC     R31,R17
   \   0000004C   8291                       STD     Z+1,R9
    166                  }
   \   0000004E   9463                       INC     R6
   \   00000050   CFEB                       RJMP    ??SearchBuses_2
    167              }
   \                     ??SearchBuses_3:
   \   00000052   95B3                       INC     R27
   \   00000054   CFDA                       RJMP    ??SearchBuses_0
    168              
    169              // Find the buses with slave devices.
    170              presence = OWI_DetectPresence(BUSES);
   \                     ??SearchBuses_1:
   \   00000056   E003                       LDI     R16,3
   \   00000058   ........                   CALL    OWI_DetectPresence
   \   0000005C   2EC0                       MOV     R12,R16
    171              
    172              numDevices = 0;
   \   0000005E   2477                       CLR     R7
    173              newID = devices[0].id;
   \   00000060   018C                       MOVW    R17 : R16,R25 : R24
   \   00000062   5F0F                       SUBI    R16,255
   \   00000064   4F1F                       SBCI    R17,255
   \   00000066   0128                       MOVW    R5 : R4,R17 : R16
    174              
    175              // Go through all buses with slave devices.
    176              for (currentBus = 0x01; currentBus; currentBus <<= 1)
   \   00000068   E0A1                       LDI     R26,1
   \                     ??SearchBuses_4:
   \   0000006A   23AA                       TST     R26
   \   0000006C   F189                       BREQ    ??SearchBuses_5
    177              {
    178                  lastDeviation = 0;
   \   0000006E   2488                       CLR     R8
    179                  currentID = newID;
   \   00000070   0152                       MOVW    R11 : R10,R5 : R4
    180                  if (currentBus & presence) // Devices available on this bus.
   \   00000072   2D0C                       MOV     R16,R12
   \   00000074   230A                       AND     R16,R26
   \   00000076   2300                       TST     R16
   \   00000078   F149                       BREQ    ??SearchBuses_6
    181                  {
    182                      // Do slave search on each bus, and place identifiers and corresponding
    183                      // bus "addresses" in the array.
    184                      do  
    185                      {
    186                          memcpy(newID, currentID, 8);
   \                     ??SearchBuses_7:
   \   0000007A   E048                       LDI     R20,8
   \   0000007C   E050                       LDI     R21,0
   \   0000007E   0195                       MOVW    R19 : R18,R11 : R10
   \   00000080   0182                       MOVW    R17 : R16,R5 : R4
   \   00000082   ........                   CALL    memcpy
    187                          OWI_DetectPresence(currentBus);
   \   00000086   2F0A                       MOV     R16,R26
   \   00000088   ........                   CALL    OWI_DetectPresence
    188                          lastDeviation = OWI_SearchRom(newID, lastDeviation, currentBus);
   \   0000008C   2F3A                       MOV     R19,R26
   \   0000008E   2D28                       MOV     R18,R8
   \   00000090   0182                       MOVW    R17 : R16,R5 : R4
   \   00000092   ........                   CALL    OWI_SearchRom
   \   00000096   2E80                       MOV     R8,R16
    189                          currentID = newID;
   \   00000098   0152                       MOVW    R11 : R10,R5 : R4
    190                          devices[numDevices].bus = currentBus;
   \   0000009A   2D47                       MOV     R20,R7
   \   0000009C   E050                       LDI     R21,0
   \   0000009E   E009                       LDI     R16,9
   \   000000A0   E010                       LDI     R17,0
   \   000000A2   ........                   CALL    ?S_EC_MUL_L02
   \   000000A6   01FC                       MOVW    R31 : R30,R25 : R24
   \   000000A8   0FE0                       ADD     R30,R16
   \   000000AA   1FF1                       ADC     R31,R17
   \   000000AC   83A0                       ST      Z,R26
    191                          numDevices++;
   \   000000AE   9473                       INC     R7
    192                          newID=devices[numDevices].id;                
   \   000000B0   2D47                       MOV     R20,R7
   \   000000B2   E050                       LDI     R21,0
   \   000000B4   E009                       LDI     R16,9
   \   000000B6   E010                       LDI     R17,0
   \   000000B8   ........                   CALL    ?S_EC_MUL_L02
   \   000000BC   019C                       MOVW    R19 : R18,R25 : R24
   \   000000BE   0F20                       ADD     R18,R16
   \   000000C0   1F31                       ADC     R19,R17
   \   000000C2   5F2F                       SUBI    R18,255
   \   000000C4   4F3F                       SBCI    R19,255
   \   000000C6   0129                       MOVW    R5 : R4,R19 : R18
    193                      }  while(lastDeviation != OWI_ROM_SEARCH_FINISHED);            
   \   000000C8   2088                       TST     R8
   \   000000CA   F6B9                       BRNE    ??SearchBuses_7
    194                  }
    195              }
   \                     ??SearchBuses_6:
   \   000000CC   0FAA                       LSL     R26
   \   000000CE   CFCD                       RJMP    ??SearchBuses_4
    196          
    197              // Go through all the devices and do CRC check.
    198              for (i = 0; i < numDevices; i++)
   \                     ??SearchBuses_5:
   \   000000D0   E0B0                       LDI     R27,0
   \                     ??SearchBuses_8:
   \   000000D2   15B7                       CP      R27,R7
   \   000000D4   F4A0                       BRCC    ??SearchBuses_9
    199              {
    200                  // If any id has a crc error, return error.
    201                  if(OWI_CheckRomCRC(devices[i].id) != OWI_CRC_OK)
   \   000000D6   2F4B                       MOV     R20,R27
   \   000000D8   E050                       LDI     R21,0
   \   000000DA   E009                       LDI     R16,9
   \   000000DC   E010                       LDI     R17,0
   \   000000DE   ........                   CALL    ?S_EC_MUL_L02
   \   000000E2   019C                       MOVW    R19 : R18,R25 : R24
   \   000000E4   0F20                       ADD     R18,R16
   \   000000E6   1F31                       ADC     R19,R17
   \   000000E8   5F2F                       SUBI    R18,255
   \   000000EA   4F3F                       SBCI    R19,255
   \   000000EC   0189                       MOVW    R17 : R16,R19 : R18
   \   000000EE   ........                   CALL    OWI_CheckRomCRC
   \   000000F2   2300                       TST     R16
   \   000000F4   F011                       BREQ    ??SearchBuses_10
    202                  {
    203                      return SEARCH_CRC_ERROR;
   \   000000F6   E001                       LDI     R16,1
   \   000000F8   C003                       RJMP    ??SearchBuses_11
    204                  }
    205              }
   \                     ??SearchBuses_10:
   \   000000FA   95B3                       INC     R27
   \   000000FC   CFEA                       RJMP    ??SearchBuses_8
    206              // Else, return Successful.
    207              return SEARCH_SUCCESSFUL;
   \                     ??SearchBuses_9:
   \   000000FE   E000                       LDI     R16,0
   \                     ??SearchBuses_11:
   \   00000100   E0EF                       LDI     R30,15
   \   00000102   ........                   JMP     ?EPILOGUE_B15_L09
    208          }
    209          
    210          /*! \brief  Find the first device of a family based on the family id
    211           *
    212           *  This function returns a pointer to a device in the device array
    213           *  that matches the specified family.
    214           *
    215           *  \param  familyID    The 8 bit family ID to search for.
    216           *
    217           *  \param  devices     An array of devices to search through.
    218           *
    219           *  \param  size        The size of the array 'devices'
    220           *
    221           *  \return A pointer to a device of the family.
    222           *  \retval NULL    if no device of the family was found.
    223           */

   \                                 In segment CODE, align 2, keep-with-next
    224          OWI_device * FindFamily(unsigned char familyID, OWI_device * devices, unsigned char size)
   \                     FindFamily:
    225          {
   \   00000000   2F40                       MOV     R20,R16
   \   00000002   2F61                       MOV     R22,R17
    226              unsigned char i = 0;
   \   00000004   E050                       LDI     R21,0
    227              
    228              // Search through the array.
    229              while (i < size)
   \                     ??FindFamily_0:
   \   00000006   1756                       CP      R21,R22
   \   00000008   F450                       BRCC    ??FindFamily_1
    230              {
    231                  // Return the pointer if there is a family id match.
    232                  if ((*devices).id[0] == familyID)
   \   0000000A   01F9                       MOVW    R31 : R30,R19 : R18
   \   0000000C   8101                       LDD     R16,Z+1
   \   0000000E   1704                       CP      R16,R20
   \   00000010   F411                       BRNE    ??FindFamily_2
    233                  {
    234                      return devices;
   \   00000012   0189                       MOVW    R17 : R16,R19 : R18
   \   00000014   9508                       RET
    235                  }
    236                  devices++;
   \                     ??FindFamily_2:
   \   00000016   5F27                       SUBI    R18,247
   \   00000018   4F3F                       SBCI    R19,255
    237                  i++;
   \   0000001A   9553                       INC     R21
   \   0000001C   CFF4                       RJMP    ??FindFamily_0
    238              }
    239              // Else, return NULL.
    240              return NULL;
   \                     ??FindFamily_1:
   \   0000001E   E000                       LDI     R16,0
   \   00000020   E010                       LDI     R17,0
   \   00000022   9508                       RET
    241          }
    242          
    243          
    244          /*! \brief  Read the temperature from a DS1820 temperature sensor.
    245           *
    246           *  This function will start a conversion and read back the temperature
    247           *  from a DS1820 temperature sensor.
    248           *
    249           *  \param  bus A bitmask of the bus where the DS1820 is located.
    250           *  
    251           *  \param  id  The 64 bit identifier of the DS1820.
    252           *
    253           *  \return The 16 bit signed temperature read from the DS1820.
    254           */

   \                                 In segment CODE, align 2, keep-with-next
    255          signed int DS1820_ReadTemperature(unsigned char bus, unsigned char * id)
   \                     DS1820_ReadTemperature:
    256          {
   \   00000000   ........                   CALL    ?PROLOGUE6_L09
   \   00000004                              REQUIRE ?Register_R4_is_cg_reg
   \   00000004                              REQUIRE ?Register_R5_is_cg_reg
   \   00000004   2F80                       MOV     R24,R16
   \   00000006   01D9                       MOVW    R27 : R26,R19 : R18
    257              signed int temperature;
    258              
    259              // Reset, presence.
    260              if (!OWI_DetectPresence(bus))
   \   00000008   2F08                       MOV     R16,R24
   \   0000000A   ........                   CALL    OWI_DetectPresence
   \   0000000E   2300                       TST     R16
   \   00000010   F419                       BRNE    ??DS1820_ReadTemperature_0
    261              {
    262                  return DS1820_ERROR; // Error
   \   00000012   E108                       LDI     R16,24
   \   00000014   EF1C                       LDI     R17,252
   \   00000016   C02A                       RJMP    ??DS1820_ReadTemperature_1
    263              }
    264              // Match the id found earlier.
    265              OWI_MatchRom(id, bus);
   \                     ??DS1820_ReadTemperature_0:
   \   00000018   2F28                       MOV     R18,R24
   \   0000001A   018D                       MOVW    R17 : R16,R27 : R26
   \   0000001C   ........                   CALL    OWI_MatchRom
    266              // Send start conversion command.
    267              OWI_SendByte(DS1820_START_CONVERSION, bus);
   \   00000020   2F18                       MOV     R17,R24
   \   00000022   E404                       LDI     R16,68
   \   00000024   ........                   CALL    OWI_SendByte
    268              // Wait until conversion is finished.
    269              // Bus line is held low until conversion is finished.
    270              while (!OWI_ReadBit(bus))
   \                     ??DS1820_ReadTemperature_2:
   \   00000028   2F08                       MOV     R16,R24
   \   0000002A   ........                   CALL    OWI_ReadBit
   \   0000002E   2300                       TST     R16
   \   00000030   F3D9                       BREQ    ??DS1820_ReadTemperature_2
    271              {
    272              
    273              }
    274              // Reset, presence.
    275              if(!OWI_DetectPresence(bus))
   \   00000032   2F08                       MOV     R16,R24
   \   00000034   ........                   CALL    OWI_DetectPresence
   \   00000038   2300                       TST     R16
   \   0000003A   F419                       BRNE    ??DS1820_ReadTemperature_3
    276              {
    277                  return -1000; // Error
   \   0000003C   E108                       LDI     R16,24
   \   0000003E   EF1C                       LDI     R17,252

⌨️ 快捷键说明

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