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

📄 owiuartbitfunctions.s90

📁 达拉斯 1-Wire 主机通信 这份资料展示了如何把 1-Wire 主机通信在应用到一个AVR系统中
💻 S90
📖 第 1 页 / 共 2 页
字号:
// union <unnamed> volatile __io _A_UBRRL
_A_UBRRL:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,02aH
// union <unnamed> volatile __io _A_UCSRB
_A_UCSRB:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,02bH
// union <unnamed> volatile __io _A_UCSRA
_A_UCSRA:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,02cH
// union <unnamed> volatile __io _A_UDR
_A_UDR:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,02dH
// union <unnamed> volatile __io _A_SPCR
_A_SPCR:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,02eH
// union <unnamed> volatile __io _A_SPSR
_A_SPSR:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,02fH
// union <unnamed> volatile __io _A_SPDR
_A_SPDR:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,030H
// union <unnamed> volatile __io _A_PIND
_A_PIND:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,031H
// union <unnamed> volatile __io _A_DDRD
_A_DDRD:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,032H
// union <unnamed> volatile __io _A_PORTD
_A_PORTD:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,033H
// union <unnamed> volatile __io _A_PINC
_A_PINC:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,034H
// union <unnamed> volatile __io _A_DDRC
_A_DDRC:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,035H
// union <unnamed> volatile __io _A_PORTC
_A_PORTC:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,036H
// union <unnamed> volatile __io _A_PINB
_A_PINB:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,037H
// union <unnamed> volatile __io _A_DDRB
_A_DDRB:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,038H
// union <unnamed> volatile __io _A_PORTB
_A_PORTB:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,039H
// union <unnamed> volatile __io _A_PINA
_A_PINA:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,03aH
// union <unnamed> volatile __io _A_DDRA
_A_DDRA:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,03bH
// union <unnamed> volatile __io _A_PORTA
_A_PORTA:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,03cH
// union <unnamed> volatile __io _A_EECR
_A_EECR:
        DS 1

        ASEGN ABSOLUTE:DATA:ROOT,03dH
// union <unnamed> volatile __io _A_EEDR
_A_EEDR:
        DS 1

        ASEGN ABSOLUTE:DATA:NOROOT,01cH
__?EECR:

        ASEGN ABSOLUTE:DATA:NOROOT,01dH
__?EEDR:

        ASEGN ABSOLUTE:DATA:NOROOT,01eH
__?EEARL:

        ASEGN ABSOLUTE:DATA:NOROOT,01fH
__?EEARH:

        END
// Z:\qvcs\AVR318 Dallas 1-wire Communication Interface\Source Code\IAR\polled\OWIUARTBitFunctions.c
//    1 // This file has been prepared for Doxygen automatic documentation generation.
//    2 /*! \file ********************************************************************
//    3 *
//    4 * Atmel Corporation
//    5 *
//    6 * \li File:               OWIUARTFunctions.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 UART implementation of the basic bit-level
//   16 *                         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 /*****************************************************************************
//   23 *
//   24 * Atmel Corporation
//   25 *
//   26 * File              : OWIUARTFunctions.c
//   27 * Compiler          : IAR EWAAVR 3.20a
//   28 * Revision          : $Revision: 1.6 $
//   29 * Date              : $Date: Thursday, August 19, 2004 09:02:02 UTC $
//   30 * Updated by        : $Author: tsundre $
//   31 *
//   32 * Support mail      : avr@atmel.com
//   33 *
//   34 * Supported devices : All AVRs with UART or USART module.
//   35 *
//   36 * AppNote           : AVR318 - 1-Wire(R) interface Master Implementation
//   37 *
//   38 * Description       : Polled UART implementation of the basic bit-level
//   39 *                     signalling in the 1-Wire(R) protocol.
//   40 *
//   41 ****************************************************************************/
//   42 
//   43 #include "OWIPolled.h"
//   44 
//   45 #ifdef OWI_UART_DRIVER
//   46 
//   47 #include <ioavr.h>
//   48 
//   49 #include "OWIBitFunctions.h"
//   50 
//   51 
//   52 
//   53 /*! \brief Initialization of the one wire bus. (Polled UART driver)
//   54  *  
//   55  *  This function initializes the 1-Wire bus by configuring the UART.
//   56  */
//   57 void OWI_Init()
//   58 {
//   59     // Choose single or double UART speed.
//   60     OWI_UART_STATCTRL_REG_A = (OWI_UART_2X << OWI_U2X);
//   61 
//   62     // Enable UART transmitter and receiver.
//   63     OWI_UART_STATCTRL_REG_B = (1 << OWI_TXEN) | (1 << OWI_RXEN);
//   64     
//   65     // Set up asynchronous mode, 8 data bits, no parity, 1 stop bit.
//   66     // (Initial value, can be removed)
//   67 #ifdef URSEL
//   68     OWI_UART_STATCTRL_REG_C = (1 << OWI_URSEL) | (1 << OWI_UCSZ1) | (1 << OWI_UCSZ0);
//   69 #else
//   70     OWI_UART_STATCTRL_REG_C = (1 << OWI_UCSZ1) | (1 << OWI_UCSZ0);
//   71 #endif
//   72 
//   73     OWI_UART_BAUD_RATE_REG_L = OWI_UBRR_115200;    
//   74 }
//   75 
//   76 
//   77 /*! \brief  Write and read one bit to/from the 1-Wire bus. (Polled UART driver)
//   78  *
//   79  *  Writes one bit to the bus and returns the value read from the bus.
//   80  *
//   81  *  \param  outValue    The value to transmit on the bus.
//   82  *
//   83  *  \return The value received by the UART from the bus.
//   84  */
//   85 unsigned char OWI_TouchBit(unsigned char outValue)
//   86 {
//   87     // Place the output value in the UART transmit buffer, and wait
//   88     // until it is received by the UART receiver.
//   89     OWI_UART_DATA_REGISTER = outValue;
//   90     while(!(OWI_UART_STATCTRL_REG_A & (1 << OWI_RXC)))
//   91     {
//   92 
//   93     }
//   94     // Set the UART Baud Rate back to 115200kbps when finished.
//   95     OWI_UART_BAUD_RATE_REG_L = OWI_UBRR_115200;
//   96     return OWI_UART_DATA_REGISTER;
//   97 }
//   98 
//   99 /*! \brief Write a '1' bit to the bus(es). (Polled UART DRIVER)
//  100  *
//  101  *  Generates the waveform for transmission of a '1' bit on the 1-Wire
//  102  *  bus.
//  103  */
//  104 void OWI_WriteBit1()
//  105 {
//  106     OWI_TouchBit(OWI_UART_WRITE1);
//  107 }
//  108 
//  109 
//  110 /*! \brief  Write a '0' to the bus(es). (Polled UART DRIVER)
//  111  *
//  112  *  Generates the waveform for transmission of a '0' bit on the 1-Wire(R)
//  113  *  bus.
//  114  */
//  115 void OWI_WriteBit0()
//  116 {
//  117     OWI_TouchBit(OWI_UART_WRITE0);
//  118 }
//  119 
//  120 
//  121 /*! \brief  Read a bit from the bus(es). (Polled UART DRIVER)
//  122  *
//  123  *  Generates the waveform for reception of a bit on the 1-Wire(R) bus(es).
//  124  *
//  125  *  \return The value read from the bus (0 or 1).
//  126  */
//  127 unsigned char OWI_ReadBit()
//  128 {
//  129      // Return 1 if the value received matches the value sent.
//  130      // Return 0 else. (A slave held the bus low).
//  131      return (OWI_TouchBit(OWI_UART_READ_BIT) == OWI_UART_READ_BIT);
//  132 }
//  133 
//  134 
//  135 /*! \brief  Send a Reset signal and listen for Presence signal. (Polled 
//  136  *  UART DRIVER)
//  137  *
//  138  *  Generates the waveform for transmission of a Reset pulse on the 
//  139  *  1-Wire(R) bus and listens for presence signals.
//  140  *
//  141  *  \return A bitmask of the buses where a presence signal was detected.
//  142  */
//  143 unsigned char OWI_DetectPresence()
//  144 {
//  145     // Reset UART receiver to clear RXC register.
//  146     OWI_UART_STATCTRL_REG_B &= ~(1 << OWI_RXEN);
//  147     OWI_UART_STATCTRL_REG_B |= (1 << OWI_RXEN);
//  148     
//  149     // Set UART Baud Rate to 9600 for Reset/Presence signalling.
//  150     OWI_UART_BAUD_RATE_REG_L = OWI_UBRR_9600;
//  151     
//  152     // Return 0 if the value received matches the value sent.
//  153     // return 1 else. (Presence detected)
//  154     return (OWI_TouchBit(OWI_UART_RESET) != OWI_UART_RESET); 
//  155 }
//  156 
//  157 
//  158 #endif
// 
// 64 bytes in segment ABSOLUTE
// 
// 0 bytes of DATA memory (+ 64 bytes shared)
//
//Errors: none
//Warnings: none

⌨️ 快捷键说明

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