亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? owiintfunctions.c

?? 達(dá)拉斯 1-Wire 主機(jī)通信 這份資料展示了如何把 1-Wire 主機(jī)通信在應(yīng)用到一個(gè)AVR系統(tǒng)中
?? C
字號(hào):
// This file has been prepared for Doxygen automatic documentation generation.
/*! \file ********************************************************************
*
* Atmel Corporation
*
* \li File:               OWIIntFunctions.c
* \li Compiler:           IAR EWAAVR 3.20a
* \li Support mail:       avr@atmel.com
*
* \li Supported devices:  All AVRs with UART or USART module. 
*
* \li Application Note:   AVR318 - Dallas 1-Wire(R) master.
*                         
*
* \li Description:        Functions and Interrupt Service Routines that 
*                         handles automated transmission and reception of 0-255 
*                         bits. 
*
*                         $Revision: 1.7 $
*                         $Date: Thursday, August 19, 2004 14:27:18 UTC $
****************************************************************************/

#include "OWIIntFunctions.h"
#include <ioavr.h>
#include "OWIInterruptDriven.h"

OWIflags OWIStatus;
unsigned char *OWIDataBuffer;
unsigned char OWIBufferLength;


/*! \brief  Initialization of the U(S)ART for 1-Wire communication.
 *  
 *  This function configures the U(S)ART for 1-Wire communication.
 *
 *  \note   Parameters are set in "OWIInterruptDriven.h"
 */
void OWI_Init(void)
{
    // Choose single or double UART speed.
    OWI_UART_STATCTRL_REG_A = (OWI_UART_2X << OWI_U2X);
    
    // Enable UART receiver, transmitter and interrupt on receive;
    OWI_UART_STATCTRL_REG_B = (1 << OWI_RXEN) | (1 << OWI_TXEN) | (1 << OWI_RXCIE);

    // Set up asynchronous mode, 8 data bits, no parity, 1 stop bit.
    // (Initial value, can be removed)
    #ifdef URSEL
    OWI_UART_STATCTRL_REG_C = (1 << OWI_URSEL) | (1 << OWI_UCSZ1) | (1 << OWI_UCSZ0);
    #else
    OWI_UART_STATCTRL_REG_C = (1 << OWI_UCSZ1) | (1 << OWI_UCSZ0);
    #endif
    
    // Clear OWI flags.
    OWIStatus.allFlags = FALSE;
}


/*! \brief   Send the Reset signal on 1-Wire bus to receive presence
 *  signal from slave devices.
 * 
 *
 *  This function configures the UART module for transmission of the
 *  Reset signal. The busy flag is TRUE until the 1-Wire driver has 
 *  completed the Reset/Presence sequence. when the busy flag becomes 
 *  FALSE, the presence flag indicates whether a Presence signal was 
 *  received.
 */
void OWI_DetectPresence(void)
{
    // Set OWI busy flag
    OWIStatus.busy = TRUE;
    
    // Set the BAUD Rate to 9600 bps for reset/presence signalling.
    OWI_UART_BAUD_RATE_REG_L = OWI_UBRR_9600;
    
    // Enable UART data register empty interrupt to start the UART
    // transmitter.
    OWI_UART_STATCTRL_REG_B |= (1 << OWI_UDRIE);
}


/*! \brief  Transmit data on the 1-Wire bus. 
 *
 *  This function configures the UART module for transmission of data.
 *  The busy flag is TRUE until transmission is complete.
 *
 *  \param  data        Pointer to the data to be transmitted.
 *  
 *  \param  dataLength  The number of bits to be transmitted.
 */
void OWI_TransmitData(unsigned char * data, unsigned char dataLength)
{
    // Set OWI busy flag
    OWIStatus.busy = TRUE;
    
    // Set the data buffer pointer and data length.
    OWIDataBuffer = data;
    OWIBufferLength = dataLength;
    
    // Enable UART data register empty interrupt to start the UART
    // transmitter.    
    OWI_UART_STATCTRL_REG_B |= (1 << OWI_UDRIE);
}


/*! \brief  Receive data from the 1-Wire bus.
 *
 *  This function configures the UART module for reception of data.
 *  The busy flag is TRUE until reception is complete.
 *
 *  \param  data        A pointer to the location in memory where the 
 *                      received data should be placed
 *
 *  \param  dataLength  The number of bits to receive.
 */
void OWI_ReceiveData(unsigned char * data, unsigned char dataLength)
{
    unsigned char numBytes;

    // Fill buffer with 1's (Write 1 and Read waveforms are similar).
    numBytes = dataLength >> 3;
    if (dataLength & 0x07)
    {
        numBytes++;
    }
    
    while(numBytes)
    {
        data[numBytes - 1] = 0xff;
        numBytes--;
    }

    // Transmit the '1'-filled buffer on the bus to receive data.
    OWI_TransmitData(data, dataLength);
}


/*! \brief  UART Receive Complete Interrupt Service Routine
 *
 *  This ISR takes care of reception and interpretation of signals
 *  from the 1-Wire bus.
 */
#pragma vector = OWI_UART_RXC_VECT
__interrupt void UART_RXC_ISR()
{
    static unsigned char bitsReceived = 0;
    static unsigned char receiveBuffer = 0;
    static unsigned char byteIndex = 0;
    unsigned char waveform;
    
    // Check for frame error.
    if (OWI_UART_STATCTRL_REG_A & (1 << OWI_FE))
    {
        // Frame error.
        // Could be caused by a slave connecting to the bus, noice
        // or a short on the bus pulling it low.

        // Read UART DATA REGISTER to clear FE and RXC flags.
        waveform = OWI_UART_DATA_REGISTER;
        
        // Flag error, and clean up.
        OWIStatus.error = TRUE;
        OWIStatus.busy = FALSE;
        OWI_UART_STATCTRL_REG_B &= ~(1 << OWI_UDRIE);
        return;
    }    

    // Read the UART data register to get the waveform for this bit.
    waveform = OWI_UART_DATA_REGISTER;
    
    // If the Baud rate is 9600, check for presence signal.
    if (OWI_UART_BAUD_RATE_REG_L == OWI_UBRR_9600)
    {
        // Set presenceDetected flag if waveform is different from 
        // what was transmitted on the bus.
        OWIStatus.presenceDetected = (waveform != OWI_UART_RESET);

        // Set UART baud rate to 115200 bps.
        OWI_UART_BAUD_RATE_REG_L = OWI_UBRR_115200;

        // Reset bits received counter.
        bitsReceived = 0;

        // Set busy flag to FALSE.
        OWIStatus.busy = FALSE;
    }
    else // Baud rate != 9600.
    {
        // Increase bits received counter.
        bitsReceived++;

        // Right shift receive buffer.
        receiveBuffer >>= 1;

        // Check value of received bit.
        if (waveform == OWI_UART_READ_BIT) // Received 1.
        {
            // Set msb of receive buffer
            receiveBuffer |= 0x80;
        }
        else // Received 0.
        {
            // Do nothing, a 0 has already been shifted in.
        }

        // Was this the last bit?
        if (bitsReceived == OWIBufferLength)
        {
            // Right shift receive buffer to align bits.
            // Only needed when the number of bits is not divisible by 8.
            while(bitsReceived++ & 0x07)  
            {
                receiveBuffer >>= 1;   
            }
            // Insert the received data in the OWI Data buffer.
            OWIDataBuffer[byteIndex] = receiveBuffer;
            
            // Clean up.
            bitsReceived = 0;
            byteIndex = 0;
            OWIStatus.busy = FALSE;
        }
        else // Not the last bit.
        {
            // Is bitsReceived divisible with 8?
            // If so, one byte has been received and the receive buffer
            // must be placed in the big OWI data buffer. 
            if (!(bitsReceived & 0x07))
            {
                // Put the received byte in the data buffer and increment byte index.
                OWIDataBuffer[byteIndex] = receiveBuffer;                
                byteIndex++;
            }
        }
    }    
    return;
}


/*! \brief  UART Data Register Empty Interrupt Service Routine
 *
 *  This ISR is run every time the UART transmit buffer is empty, thus
 *  automating the process of transmitting and receiving bits.
 */
#pragma vector = OWI_UART_UDRE_VECT
__interrupt void UART_UDRE_ISR()
{
    static unsigned char bitsSent = 0;
    static unsigned char transmitBuffer;
    static unsigned char byteIndex = 0;
    
    // If the UART Baud Rate is 9600 bps, send the Reset signal.
    if (OWI_UART_BAUD_RATE_REG_L == OWI_UBRR_9600)
    {
        //Send Reset signal.
        OWI_UART_DATA_REGISTER = OWI_UART_RESET;
        
        // Reset bits sent counter.
        bitsSent = 0;

        // Clear UDRIE flag.
        OWI_UART_STATCTRL_REG_B &= ~(1 << OWI_UDRIE);

        return;
    }
    
    // If this is the first bit in a new transmission, fetch
    // the first byte from the OWI data buffer and reset
    // byte index.
    if (bitsSent == 0)
    {
        byteIndex = 0;
        transmitBuffer = OWIDataBuffer[0];        
    } 
    
    // If this is the last bit in the transmission, clean up.  
    if (bitsSent == OWIBufferLength)
    {
        bitsSent = 0;
        OWI_UART_STATCTRL_REG_B &= ~(1 << OWI_UDRIE);
    }
    else // Not the last bit.
    {
        // Check lsb of the transmit buffer and transmit corresponding
        // waveform on the bus.
        if (transmitBuffer & 0x01)
        {
            OWI_UART_DATA_REGISTER = OWI_UART_WRITE1;
        }
        else
        {
            OWI_UART_DATA_REGISTER = OWI_UART_WRITE0;
        }
        
        // Right shift transmit buffer.
        transmitBuffer >>= 1;
        
        // Increase bits sent counter.
        bitsSent++;

        // If the number of bits sent is divisible by 8, a whole byte has
        // been shifted out. Fetch a new from the OWI data buffer.
        if (!(bitsSent & 0x07))
        {
            byteIndex++;
            transmitBuffer = OWIDataBuffer[byteIndex];
        }
    }
    return;
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影免费观看高清完整版 | 日韩免费观看高清完整版| 欧美最新大片在线看| 91精品综合久久久久久| 欧美极品美女视频| 亚洲成人第一页| 一区二区久久久久| 国产精品一区二区无线| 欧美在线免费视屏| 久久久久久久国产精品影院| 亚洲精品国产第一综合99久久| 日韩av一区二区在线影视| 成人一二三区视频| 911国产精品| 一二三区精品视频| 成人精品视频一区二区三区| 欧美一二三区精品| 亚洲免费在线看| 国产乱码精品一区二区三区忘忧草| 一本久道中文字幕精品亚洲嫩| 久久综合狠狠综合| 日韩和欧美一区二区三区| 成人av在线播放网站| 欧美xxxxxxxxx| 午夜精品一区在线观看| 91麻豆产精品久久久久久 | 色一情一乱一乱一91av| 亚洲综合小说图片| 亚洲制服丝袜av| 色婷婷亚洲精品| 国产99久久久久| 久久久久久久久久美女| 国产精品一二三区| 久久精品在这里| 成人黄色片在线观看| 国产精品三级久久久久三级| www.欧美色图| 亚洲精品国产成人久久av盗摄| 99精品一区二区| 亚洲一区二区在线观看视频 | 精品国产乱子伦一区| 极品瑜伽女神91| 久久综合精品国产一区二区三区 | 国精产品一区一区三区mba视频| 欧美videos中文字幕| 国产一区二区电影| 国产精品美女久久久久高潮| 91丝袜美腿高跟国产极品老师| 亚洲精品视频一区| 欧美一区中文字幕| 国产成人在线视频播放| 成人欧美一区二区三区黑人麻豆| 日本韩国一区二区三区| 天堂资源在线中文精品| 欧美电影免费提供在线观看| 成人午夜激情在线| 亚洲成人在线观看视频| 精品剧情在线观看| 91一区二区在线| 午夜精品一区二区三区免费视频| 精品国产伦理网| 91网站最新网址| 免费观看在线色综合| 国产午夜久久久久| 欧美伊人精品成人久久综合97 | 亚洲男帅同性gay1069| 67194成人在线观看| 欧美成人video| av毛片久久久久**hd| 日韩成人精品在线观看| 国产精品色眯眯| 日韩三级.com| 97久久超碰国产精品| 免费成人性网站| 亚洲色图制服诱惑 | 亚洲人123区| 精品人在线二区三区| 91免费视频网址| 国产精品一区二区不卡| 亚洲国产乱码最新视频| 国产精品久久午夜夜伦鲁鲁| 欧美又粗又大又爽| 国产精品一区二区免费不卡 | 亚洲免费在线视频一区 二区| 日韩视频国产视频| 欧美性猛交xxxxxxxx| 成人精品视频一区二区三区尤物| 免费精品视频最新在线| 亚洲免费观看高清完整版在线观看熊 | 精品久久国产字幕高潮| 欧美日韩一区二区三区在线| av在线不卡免费看| 国产一区二区在线影院| 蜜臀va亚洲va欧美va天堂| 亚洲午夜羞羞片| 亚洲日本护士毛茸茸| 欧美国产日产图区| 国产清纯白嫩初高生在线观看91 | 亚洲一区二区在线免费观看视频| 国产欧美一区二区精品性色超碰 | 国产色产综合产在线视频| 欧美一区二区三区影视| 日本久久一区二区三区| 成人久久18免费网站麻豆 | 蜜桃av一区二区三区电影| 亚洲午夜电影在线观看| 亚洲精品成人悠悠色影视| 国产精品理论片在线观看| 久久精品亚洲麻豆av一区二区| 日韩免费看的电影| 欧美一二区视频| 欧美本精品男人aⅴ天堂| 亚洲免费成人av| 一区二区在线观看免费| 亚洲丝袜自拍清纯另类| 一区二区三区免费看视频| 亚洲图片另类小说| 亚洲黄色在线视频| 一区二区三国产精华液| 亚洲风情在线资源站| 五月天精品一区二区三区| 亚洲成av人影院| 蜜桃久久av一区| 国产东北露脸精品视频| www.性欧美| 91国产视频在线观看| 欧美制服丝袜第一页| 在线播放中文一区| 26uuu亚洲综合色| 国产精品高潮呻吟| 亚洲靠逼com| 美日韩黄色大片| 国产毛片精品视频| 成人涩涩免费视频| 欧美日韩一区二区在线观看视频| 日韩精品一区二区三区中文不卡| 久久久蜜桃精品| 中文字幕一区二区三区精华液 | 日本韩国一区二区| 3d成人h动漫网站入口| 337p日本欧洲亚洲大胆色噜噜| 国产精品少妇自拍| 亚洲图片欧美视频| 国产麻豆精品95视频| caoporm超碰国产精品| 欧美电影在线免费观看| 国产清纯白嫩初高生在线观看91| 亚洲视频在线一区观看| 蜜乳av一区二区| 色综合网站在线| 欧美xingq一区二区| 亚洲男人的天堂在线aⅴ视频| 秋霞午夜av一区二区三区| 成人国产亚洲欧美成人综合网| 欧美性生活久久| 久久―日本道色综合久久| 亚洲国产视频网站| 国产成人av一区二区| 欧美日韩精品一区视频| 国产亚洲精品bt天堂精选| 亚洲国产精品久久人人爱蜜臀 | 麻豆视频观看网址久久| av激情亚洲男人天堂| 欧美成人a视频| 亚洲午夜免费视频| av电影在线观看一区| 欧美一卡二卡三卡| 亚洲一区免费在线观看| 9久草视频在线视频精品| 欧美成人午夜电影| 日韩在线播放一区二区| 成人性生交大合| 日韩无一区二区| 午夜不卡av在线| 91豆麻精品91久久久久久| 国产女人18毛片水真多成人如厕| 麻豆精品久久久| 欧美日韩大陆一区二区| 亚洲色图欧洲色图婷婷| 国产成人av电影| 久久精品亚洲麻豆av一区二区| 免费高清成人在线| 538在线一区二区精品国产| 国产精品国产自产拍高清av | 蜜臀av性久久久久av蜜臀妖精 | 成人av电影在线播放| 久久综合一区二区| 久久99精品网久久| 欧美一区二区在线播放| 亚洲国产一区二区三区青草影视| 99国产精品国产精品毛片| 中文字幕制服丝袜成人av| 成人午夜激情影院| 中文字幕在线观看不卡视频| 成人手机在线视频| 中文字幕一区日韩精品欧美| 99麻豆久久久国产精品免费 | 国产午夜精品理论片a级大结局 | 久久精子c满五个校花| 国产乱子伦视频一区二区三区 |