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

📄 owiswbitfunctions.lst

📁 达拉斯 1-Wire 主机通信 这份资料展示了如何把 1-Wire 主机通信在应用到一个AVR系统中
💻 LST
📖 第 1 页 / 共 3 页
字号:
##############################################################################
#                                                                            #
# IAR Atmel AVR C/EC++ Compiler V3.20A/W32             19/Aug/2004  16:08:04 #
# Copyright 1996-2004 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Source file  =  Z:\qvcs\AVR318 Dallas 1-wire Communication              #
#                    Interface\Source Code\IAR\polled\OWISWBitFunctions.c    #
#    Command line =  --cpu=m32 -ms -o "Z:\qvcs\AVR318 Dallas 1-wire          #
#                    Communication Interface\Source                          #
#                    Code\IAR\polled\Debug\Obj\" -lC "Z:\qvcs\AVR318 Dallas  #
#                    1-wire Communication Interface\Source                   #
#                    Code\IAR\polled\Debug\List\" -lA "Z:\qvcs\AVR318        #
#                    Dallas 1-wire Communication Interface\Source            #
#                    Code\IAR\polled\Debug\List\" --initializers_in_flash    #
#                    --root_variables -z2 --no_cse --no_inline               #
#                    --no_code_motion --no_cross_call --no_clustering        #
#                    --debug -DENABLE_BIT_DEFINITIONS -e -I "C:\Program      #
#                    Files\IAR Systems\Embedded Workbench 3.2\avr\INC\" -I   #
#                    "C:\Program Files\IAR Systems\Embedded Workbench        #
#                    3.2\avr\INC\CLIB\" --eeprom_size 1024 "Z:\qvcs\AVR318   #
#                    Dallas 1-wire Communication Interface\Source            #
#                    Code\IAR\polled\OWISWBitFunctions.c"                    #
#    List file    =  Z:\qvcs\AVR318 Dallas 1-wire Communication              #
#                    Interface\Source Code\IAR\polled\Debug\List\OWISWBitFun #
#                    ctions.lst                                              #
#    Object file  =  Z:\qvcs\AVR318 Dallas 1-wire Communication              #
#                    Interface\Source Code\IAR\polled\Debug\Obj\OWISWBitFunc #
#                    tions.r90                                               #
#                                                                            #
#                                                                            #
##############################################################################

Z:\qvcs\AVR318 Dallas 1-wire Communication Interface\Source Code\IAR\polled\OWISWBitFunctions.c
      1          // This file has been prepared for Doxygen automatic documentation generation.
      2          /*! \file ********************************************************************
      3          *
      4          * Atmel Corporation
      5          *
      6          * \li File:               OWISWBitFunctions.c
      7          * \li Compiler:           IAR EWAAVR 3.20a
      8          * \li Support mail:       avr@atmel.com
      9          *
     10          * \li Supported devices:  All AVRs.
     11          *
     12          * \li Application Note:   AVR318 - Dallas 1-Wire(R) master.
     13          *                         
     14          *
     15          * \li Description:        Polled software only implementation of the basic 
     16          *                         bit-level signalling in the 1-Wire(R) protocol.
     17          *
     18          *                         $Revision: 1.6 $
     19          *                         $Date: Thursday, August 19, 2004 09:02:02 UTC $
     20          ****************************************************************************/
     21          
     22          #include "OWIPolled.h"
     23          
     24          #ifdef OWI_SOFTWARE_DRIVER
     25          
     26          #include <ioavr.h>
     27          #include <inavr.h>
     28          
     29          #include "OWIBitFunctions.h"
     30          
     31          
     32          /*! \brief Initialization of the one wire bus(es). (Software only driver)
     33           *  
     34           *  This function initializes the 1-Wire bus(es) by releasing it and
     35           *  waiting until any presence sinals are finished.
     36           *
     37           *  \param  pins    A bitmask of the buses to initialize.
     38           */

   \                                 In segment CODE, align 2, keep-with-next
     39          void OWI_Init(unsigned char pins)
   \                     OWI_Init:
     40          {
     41              OWI_RELEASE_BUS(pins);
   \   00000000   2F10                       MOV     R17,R16
   \   00000002   9510                       COM     R17
   \   00000004   B321                       IN      R18,0x11
   \   00000006   2321                       AND     R18,R17
   \   00000008   BB21                       OUT     0x11,R18
   \   0000000A   B312                       IN      R17,0x12
   \   0000000C   2B10                       OR      R17,R16
   \   0000000E   BB12                       OUT     0x12,R17
     42              // The first rising edge can be interpreted by a slave as the end of a
     43              // Reset pulse. Delay for the required reset recovery time (H) to be 
     44              // sure that the real reset is interpreted correctly.
     45              __delay_cycles(OWI_DELAY_H_STD_MODE);
   \   00000010   EB2C                       LDI     R18,188
   \   00000012   E033                       LDI     R19,3
   \   00000014   5021                       SUBI    R18,1
   \   00000016   4030                       SBCI    R19,0
   \   00000018   F7E9                       BRNE    $-4
   \   0000001A   C000                       RJMP    $+2
     46          }
   \   0000001C   9508                       RET
     47          
     48          
     49          /*! \brief  Write a '1' bit to the bus(es). (Software only driver)
     50           *
     51           *  Generates the waveform for transmission of a '1' bit on the 1-Wire
     52           *  bus.
     53           *
     54           *  \param  pins    A bitmask of the buses to write to.
     55           */

   \                                 In segment CODE, align 2, keep-with-next
     56          void OWI_WriteBit1(unsigned char pins)
   \                     OWI_WriteBit1:
     57          {
     58              unsigned char intState;
     59              
     60              // Disable interrupts.
     61              intState = __save_interrupt();
   \   00000000   B72F                       IN      R18,0x3F
   \   00000002   2F12                       MOV     R17,R18
     62              __disable_interrupt();
   \   00000004   94F8                       CLI
     63              
     64              // Drive bus low and delay.
     65              OWI_PULL_BUS_LOW(pins);
   \   00000006   B321                       IN      R18,0x11
   \   00000008   2B20                       OR      R18,R16
   \   0000000A   BB21                       OUT     0x11,R18
   \   0000000C   2F20                       MOV     R18,R16
   \   0000000E   9520                       COM     R18
   \   00000010   B332                       IN      R19,0x12
   \   00000012   2332                       AND     R19,R18
   \   00000014   BB32                       OUT     0x12,R19
     66              __delay_cycles(OWI_DELAY_A_STD_MODE);
   \   00000016   E02B                       LDI     R18,11
   \   00000018   952A                       DEC     R18
   \   0000001A   F7F1                       BRNE    $-2
   \   0000001C   C000                       RJMP    $+2
     67              
     68              // Release bus and delay.
     69              OWI_RELEASE_BUS(pins);
   \   0000001E   2F20                       MOV     R18,R16
   \   00000020   9520                       COM     R18
   \   00000022   B331                       IN      R19,0x11
   \   00000024   2332                       AND     R19,R18
   \   00000026   BB31                       OUT     0x11,R19
   \   00000028   B322                       IN      R18,0x12
   \   0000002A   2B20                       OR      R18,R16
   \   0000002C   BB22                       OUT     0x12,R18
     70              __delay_cycles(OWI_DELAY_B_STD_MODE);
   \   0000002E   EA26                       LDI     R18,166
   \   00000030   952A                       DEC     R18
   \   00000032   F7F1                       BRNE    $-2
   \   00000034   0000                       NOP
     71              
     72              // Restore interrupts.
     73              __restore_interrupt(intState);
   \   00000036   BF1F                       OUT     0x3F,R17
     74          }
   \   00000038   9508                       RET
     75          
     76          
     77          /*! \brief  Write a '0' to the bus(es). (Software only driver)
     78           *
     79           *  Generates the waveform for transmission of a '0' bit on the 1-Wire(R)
     80           *  bus.
     81           *
     82           *  \param  pins    A bitmask of the buses to write to.
     83           */

   \                                 In segment CODE, align 2, keep-with-next
     84          void OWI_WriteBit0(unsigned char pins)
   \                     OWI_WriteBit0:
     85          {
     86              unsigned char intState;
     87              
     88              // Disable interrupts.
     89              intState = __save_interrupt();
   \   00000000   B72F                       IN      R18,0x3F
   \   00000002   2F12                       MOV     R17,R18
     90              __disable_interrupt();
   \   00000004   94F8                       CLI
     91              
     92              // Drive bus low and delay.
     93              OWI_PULL_BUS_LOW(pins);
   \   00000006   B321                       IN      R18,0x11
   \   00000008   2B20                       OR      R18,R16
   \   0000000A   BB21                       OUT     0x11,R18
   \   0000000C   2F20                       MOV     R18,R16
   \   0000000E   9520                       COM     R18
   \   00000010   B332                       IN      R19,0x12
   \   00000012   2332                       AND     R19,R18
   \   00000014   BB32                       OUT     0x12,R19
     94              __delay_cycles(OWI_DELAY_C_STD_MODE);
   \   00000016   E92B                       LDI     R18,155
   \   00000018   952A                       DEC     R18
   \   0000001A   F7F1                       BRNE    $-2
   \   0000001C   C000                       RJMP    $+2
     95              
     96              // Release bus and delay.
     97              OWI_RELEASE_BUS(pins);
   \   0000001E   2F20                       MOV     R18,R16
   \   00000020   9520                       COM     R18
   \   00000022   B331                       IN      R19,0x11
   \   00000024   2332                       AND     R19,R18
   \   00000026   BB31                       OUT     0x11,R19
   \   00000028   B322                       IN      R18,0x12
   \   0000002A   2B20                       OR      R18,R16
   \   0000002C   BB22                       OUT     0x12,R18
     98              __delay_cycles(OWI_DELAY_D_STD_MODE);
   \   0000002E   E126                       LDI     R18,22
   \   00000030   952A                       DEC     R18
   \   00000032   F7F1                       BRNE    $-2
   \   00000034   0000                       NOP
     99              
    100              // Restore interrupts.
    101              __restore_interrupt(intState);
   \   00000036   BF1F                       OUT     0x3F,R17
    102          }
   \   00000038   9508                       RET
    103          
    104          
    105          /*! \brief  Read a bit from the bus(es). (Software only driver)
    106           *
    107           *  Generates the waveform for reception of a bit on the 1-Wire(R) bus(es).
    108           *
    109           *  \param  pins    A bitmask of the bus(es) to read from.
    110           *
    111           *  \return A bitmask of the buses where a '1' was read.
    112           */

   \                                 In segment CODE, align 2, keep-with-next
    113          unsigned char OWI_ReadBit(unsigned char pins)
   \                     OWI_ReadBit:
    114          {
   \   00000000   2F10                       MOV     R17,R16
    115              unsigned char intState;
    116              unsigned char bitsRead;
    117              
    118              // Disable interrupts.
    119              intState = __save_interrupt();
   \   00000002   B73F                       IN      R19,0x3F
   \   00000004   2F23                       MOV     R18,R19
    120              __disable_interrupt();
   \   00000006   94F8                       CLI
    121              
    122              // Drive bus low and delay.
    123              OWI_PULL_BUS_LOW(pins);
   \   00000008   B331                       IN      R19,0x11
   \   0000000A   2B31                       OR      R19,R17
   \   0000000C   BB31                       OUT     0x11,R19
   \   0000000E   2F31                       MOV     R19,R17
   \   00000010   9530                       COM     R19
   \   00000012   B342                       IN      R20,0x12

⌨️ 快捷键说明

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