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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sensors.c

?? eaayarm101自制小車源代碼 周立功公司原創
?? C
字號:
//*****************************************************************************
//
// sensors.c - Code for sampling the car sensors.
//
// Copyright (c) 2005-2007 Luminary Micro, Inc.  All rights reserved.
//
// Software License Agreement
//
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
// exclusively on LMI's microcontroller products.
//
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  Any use in violation
// of the foregoing restrictions may subject the user to criminal sanctions
// under applicable laws, as well as to civil liability for the breach of the
// terms and conditions of this license.
//
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 199 of an01245.
//
//*****************************************************************************

#include "../../hw_adc.h"
#include "../../hw_ints.h"
#include "../../hw_memmap.h"
#include "../../hw_nvic.h"
#include "../../hw_timer.h"
#include "../../hw_types.h"
#include "compiler.h"
#include "random.h"
#include "sensors.h"
#include "system.h"

//*****************************************************************************
//
//! \page sensors_intro Introduction
//!
//! There are three infra-red ranging sensors on the car; one is pointed
//! forward, one is pointed approximately 30 degrees to the left, and one is
//! pointed approximately 30 degrees to the right.  These sensors are used to
//! determine the presence of and distance to obstacles.  The sensors provide
//! an analog voltage that is inversely proportional to the measured distance.
//!
//! Additionally, there is a current sense resistor on the low side of the two
//! H bridges for the motors that provides a voltage proportional to the
//! current through the two bridges, and there is an internal temperature
//! sensor measuring junction temperature of the microcontroller itself.
//!
//! All of these analog signals are sampled in a periodic fashion in order to
//! obtain knowledge about the environment in which the car resides.  The
//! captured data is inserted into the entropy pool for the random number
//! generator, and is low pass filtered for use by the car's decision making
//! process.
//!
//! The code for handling the sensors is contained in <tt>sensors.c</tt>,
//! with <tt>sensors.h</tt> containing the API definitions for use by the
//! remainder of the application.
//
//*****************************************************************************

//*****************************************************************************
//
//! \defgroup sensors_api Definitions
//! @{
//
//*****************************************************************************

//*****************************************************************************
//
//! The current averaged samples from the ADC for all five ADC inputs (three
//! ranging sensors in samples zero through two, the motor bridge current in
//! sample three, and the internal temperature sensor in sample four).
//!
//! The contents of this array may change at any time (in response to an ADC
//! interrupt), so any processing which depends upon these values begin stable
//! should copy them locally and use the local copies for any processing.
//
//*****************************************************************************
ZERO_INIT unsigned short g_pusSamples[5];

//*****************************************************************************
//
//! Handles the ADC sequence 0 interrupt.
//!
//! This function is called when ADC sequence 0 generates an interrupt.  The
//! newly captured samples are read from the ADC FIFO and feed through the low
//! pass filter into the set of current averaged samples.  The low order byte
//! of the raw sample is placed into the entropy pool as environmental data.
//!
//! The low pass filter is a single pole IIR with coefficients a0 = 0.1 and
//! b1 = 0.9.  The filter is processed in the integer domain with a fixed-point
//! 16.16 representation.
//!
//! \return None.
//
//*****************************************************************************
void
ADC0IntHandler(void)
{
    unsigned long ulIdx, ulData;

    //
    // Clear the ADC interrupt.
    //
    HWREG(ADC_BASE + ADC_O_ISC) = ADC_ISC_IN0;

    //
    // Loop through the five new samples.
    //
    for(ulIdx = 0; ulIdx < 5; ulIdx++)
    {
        //
        // Read this sample.
        //
        ulData = HWREG(ADC_BASE + ADC_O_SSFIFO0);

        //
        // Add the sample to the bucket.
        //
        g_pusSamples[ulIdx] = (((g_pusSamples[ulIdx] * 58982) +
                                (ulData * 6554)) / 65536);

        //
        // Add the sample to the entropy pool.
        //
        RandomAddEntropy(ulData);
    }

    //
    // Remove any remaining samples from the FIFO.  There should be none, but
    // if there are it will forever mix up the ordering that is read above.
    //
    while(!(HWREG(ADC_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT_EMPTY))
    {
        HWREG(ADC_BASE + ADC_O_SSFIFO0);
    }
}

//*****************************************************************************
//
//! Configures the sensors.
//!
//! This function prepares the sensors for normal operation.  The ADC is
//! configured to capture all five of its inputs (four input pins and the
//! internal temperature sensor) at a fixed rate, triggered by the expiration
//! of a timer.
//!
//! \return None.
//
//*****************************************************************************
void
SensorsInit(void)
{
    //
    // Configure and enable the first sample sequencer.
    //
    HWREG(ADC_BASE + ADC_O_EMUX) = ADC_EMUX_EM0_TIMER;
    HWREG(ADC_BASE + ADC_O_SSMUX0) = ((0 << ADC_SSMUX_MUX0_SHIFT) |
                                      (1 << ADC_SSMUX_MUX1_SHIFT) |
                                      (2 << ADC_SSMUX_MUX2_SHIFT) |
                                      (3 << ADC_SSMUX_MUX3_SHIFT));
    HWREG(ADC_BASE + ADC_O_SSCTL0) = (ADC_SSCTL_TS4 | ADC_SSCTL_IE4 |
                                      ADC_SSCTL_END4);
    HWREG(ADC_BASE + ADC_O_ACTSS) = ADC_ACTSS_ASEN0;

    //
    // Enable the ADC interrupt.
    //
    HWREG(ADC_BASE + ADC_O_IM) = ADC_IM_MASK0;
    HWREG(NVIC_EN0) = 1 << (INT_ADC0 - 16);

    //
    // Configure the timer as two 16-bit timers.
    //
    HWREG(TIMER2_BASE + TIMER_O_CFG) = TIMER_CFG_16_BIT;

    //
    // Configure timer B as a periodic timer.
    //
    HWREG(TIMER2_BASE + TIMER_O_TBMR) = TIMER_TNMR_TNTMR_PERIOD;

    //
    // Set the period on timer B so that it times out every 1/500th of a
    // second.
    //
    HWREG(TIMER2_BASE + TIMER_O_TBPR) = 15;
    HWREG(TIMER2_BASE + TIMER_O_TBILR) = (SYSTEM_CLOCK / (500 * 16)) - 1;

    //
    // Enable timer B.
    //
    HWREG(TIMER2_BASE + TIMER_O_CTL) |= TIMER_CTL_TBOTE | TIMER_CTL_TBEN;
}

//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合视频在线观看| 国产一区二区免费看| 日韩欧美国产综合一区 | 日韩欧美国产麻豆| 蜜臀99久久精品久久久久久软件| 91精品在线麻豆| 狠狠色综合播放一区二区| 亚洲国产精品黑人久久久| 99精品在线观看视频| 亚洲成av人片在线观看| 精品88久久久久88久久久| 一个色在线综合| 日韩一级在线观看| 成人黄色在线网站| 亚洲愉拍自拍另类高清精品| 制服丝袜中文字幕亚洲| 国产精一区二区三区| 亚洲狠狠丁香婷婷综合久久久| 欧美日韩国产综合一区二区| 国产一区二区三区免费看| 中文字幕日韩av资源站| 欧美巨大另类极品videosbest| 国内国产精品久久| 亚洲女同ⅹxx女同tv| 日韩欧美专区在线| 97国产精品videossex| 美女尤物国产一区| 亚洲免费av高清| 亚洲精品一区二区三区在线观看 | 亚洲国产日韩综合久久精品| 51精品视频一区二区三区| 懂色av中文字幕一区二区三区| 亚洲老司机在线| 精品奇米国产一区二区三区| 99v久久综合狠狠综合久久| 石原莉奈一区二区三区在线观看| 久久精品视频在线看| 欧洲另类一二三四区| 国产福利不卡视频| 日韩激情一区二区| 亚洲精品久久嫩草网站秘色| 久久综合999| 8v天堂国产在线一区二区| 99re这里都是精品| 精品一区二区免费看| 亚洲一区二区三区中文字幕在线 | 亚洲激情自拍视频| 国产亚洲欧洲997久久综合| 欧美美女一区二区在线观看| 99久久99久久精品国产片果冻| 韩国视频一区二区| 日本成人在线一区| 国产一二精品视频| 午夜av电影一区| 亚洲一区二区三区在线播放| 国产精品你懂的在线| 久久久久综合网| 欧美成人精品1314www| 欧美日韩亚州综合| 91美女在线观看| 成人国产精品免费观看动漫| 国产麻豆视频一区二区| 黄页网站大全一区二区| 亚洲综合图片区| 樱桃国产成人精品视频| 最新成人av在线| 国产欧美日韩中文久久| 久久久不卡影院| 精品成a人在线观看| 精品少妇一区二区三区视频免付费 | 中文字幕在线不卡| 欧美国产欧美综合| 国产欧美精品国产国产专区| 久久久国产精品麻豆| 久久天堂av综合合色蜜桃网| 26uuu另类欧美| 337p粉嫩大胆噜噜噜噜噜91av| 精品精品欲导航| www国产亚洲精品久久麻豆| 欧美草草影院在线视频| 精品精品国产高清a毛片牛牛| 日韩免费一区二区| 日本成人在线电影网| 日日摸夜夜添夜夜添亚洲女人| 日韩电影在线观看网站| 精品亚洲成a人| 国产成人自拍在线| 91色九色蝌蚪| 在线精品视频一区二区| 欧美日韩久久久一区| 日韩一级片网址| 久久久综合精品| 亚洲欧洲一区二区在线播放| 亚洲最色的网站| 日本中文字幕一区| 经典三级视频一区| 粉嫩欧美一区二区三区高清影视| jlzzjlzz亚洲日本少妇| 91成人网在线| 精品免费一区二区三区| 国产精品天美传媒沈樵| 亚洲精品乱码久久久久久久久| 图片区小说区国产精品视频| 紧缚捆绑精品一区二区| 99精品久久只有精品| 欧美人牲a欧美精品| 国产亚洲成av人在线观看导航| 国产精品国模大尺度视频| 亚洲成人先锋电影| 韩国av一区二区三区四区| 99久久婷婷国产综合精品| 欧美高清www午色夜在线视频| 精品国产一区二区三区av性色 | 色94色欧美sute亚洲线路一ni| 欧美福利电影网| 国产精品网友自拍| 午夜精品久久久久久久蜜桃app| 国产在线播精品第三| 色婷婷精品久久二区二区蜜臂av| 日韩亚洲欧美一区二区三区| 国产精品毛片久久久久久| 爽爽淫人综合网网站| 成人丝袜高跟foot| 欧美一卡二卡三卡| 国产精品成人网| 美女视频黄 久久| 色哟哟亚洲精品| 精品成人在线观看| 日日欢夜夜爽一区| 91论坛在线播放| 欧美国产精品中文字幕| 久久精品国产色蜜蜜麻豆| 一本色道久久综合亚洲aⅴ蜜桃| 精品日韩欧美一区二区| 亚洲国产综合色| www.欧美.com| 久久久久国产成人精品亚洲午夜| 亚欧色一区w666天堂| 99久久精品免费看国产免费软件| 精品国产露脸精彩对白| 午夜免费欧美电影| 日本韩国精品在线| 国产精品久久99| 国产黄色精品视频| 26uuu精品一区二区在线观看| 图片区小说区区亚洲影院| 在线免费观看日本一区| 中文字幕亚洲一区二区av在线| 国产精品一区二区久久精品爱涩| 91精品午夜视频| 亚洲.国产.中文慕字在线| 在线视频中文字幕一区二区| 亚洲欧美日韩国产一区二区三区 | 成人av影院在线| 国产婷婷精品av在线| 久久电影网站中文字幕| 欧美色图第一页| 亚洲精品国久久99热| 91在线精品一区二区| 亚洲国产精品精华液2区45| 国产精品一区二区在线观看网站| 日韩欧美国产综合| 久草在线在线精品观看| 精品少妇一区二区三区在线视频| 蜜桃一区二区三区四区| 欧美一级精品在线| 精品无码三级在线观看视频| 日韩精品专区在线影院重磅| 精品一区二区在线免费观看| 精品精品欲导航| 国产激情一区二区三区四区| 国产亚洲美州欧州综合国| 国产成人午夜精品5599| 中文字幕高清一区| 色综合中文字幕国产 | 欧美日韩成人在线一区| 青青草伊人久久| 精品999在线播放| 国产电影精品久久禁18| 国产精品日韩精品欧美在线| aa级大片欧美| 性感美女久久精品| 日韩欧美国产麻豆| 成人午夜av在线| 亚洲精品少妇30p| 欧美男生操女生| 久久疯狂做爰流白浆xx| 中文字幕成人av| 欧美色爱综合网| 激情综合五月天| 国产精品高潮呻吟久久| 欧美午夜在线观看| 青青草91视频| 中文字幕成人av| 欧美日韩另类一区| 国产精品一区二区黑丝| 一区二区三区加勒比av| 欧美一级欧美三级在线观看| 国产69精品一区二区亚洲孕妇| 一区二区三区四区亚洲|