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

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

?? i2c_slave.c

?? CNC.rar
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// i2c_slave.c - I2C slave interface for the main microcontroller.
//
// Copyright (c) 2006-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 220 of sw01246.
//
//*****************************************************************************

#include "hw_i2c.h"
#include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_types.h"
#include "gpio.h"
#include "i2c.h"
#include "interrupt.h"
#include "i2ccmds.h"
#include "draw.h"
#include "main.h"
#include "switches.h"
#include "table.h"

//*****************************************************************************
//
//! \page main_i2c_slave_intro Introduction
//!
//! The main microcontroller receives commands from the user interface
//! microcontroller via an I2C link.  The I2C interface on the main
//! microcontroller is run in slave mode; I2C writes provide configuration and
//! commands, and I2C reads return status of the CNC machine.
//!
//! The I2C interface is operated in interrupt driven mode so that it incurs a
//! minimal overhead to the remainder of the application.  Since the I2C
//! interface operates one byte per interrupt, special handling is required for
//! multi-byte commands and status.  The first interrupt will determine what
//! operation is being performed (status read, sending the name string, etc.).
//! Flags are set that help determine how subsequent interrupts (and therefore
//! bytes) are handled.
//!
//! The code for the I2C slave interface is contained in
//! <tt>main_micro/i2c_slave.c</tt>, with <tt>main_micro/i2c_slave.h</tt>
//! containing the API definitions for use by the remainder of the
//! application.
//
//*****************************************************************************

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

//*****************************************************************************
//
//! The GPIO pin on port B that is used for the I2C clock signal.
//
//*****************************************************************************
#define PIN_SCL                 GPIO_PIN_2

//*****************************************************************************
//
//! The GPIO pin on port B that is used for the I2C data signal.
//
//*****************************************************************************
#define PIN_SDA                 GPIO_PIN_3

//*****************************************************************************
//
//! The speed used for diagnostic moves along the X axis, specified in steps
//! per second.
//
//*****************************************************************************
#define X_SPEED                 2400

//*****************************************************************************
//
//! The acceleration used for diagnostic moves along the X axis, specified in
//! steps per second^2.
//
//*****************************************************************************
#define X_ACCEL                 30000

//*****************************************************************************
//
//! The speed used for diagnostic moves along the Y axis, specified in steps
//! per second.
//
//*****************************************************************************
#define Y_SPEED                 2400

//*****************************************************************************
//
//! The acceleration used for diagnostic moves along the Y axis, specified in
//! steps per second^2.
//
//*****************************************************************************
#define Y_ACCEL                 30000

//*****************************************************************************
//
//! The speed used for diagnostic moves along the Z axis, specified in steps
//! per second.
//
//*****************************************************************************
#define Z_SPEED                 1200

//*****************************************************************************
//
//! The acceleration used for diagnostic moves along the Z axis, specified in
//! steps per second^2.
//
//*****************************************************************************
#define Z_ACCEL                 30000

//*****************************************************************************
//
//! A set of flags for controlling the I2C slave interface; contains the
//! #I2CS_FLAG_START, #I2CS_FLAG_STOP, #I2CS_FLAG_NAME, #I2CS_FLAG_ICONS, and
//! #I2CS_FLAG_TOOL flags.
//
//*****************************************************************************
static unsigned long g_ulI2CFlags;

//*****************************************************************************
//
//! The bit number in #g_ulI2CFlags of the flag that is set when an I2C start
//! condition is detected.
//
//*****************************************************************************
#define I2CS_FLAG_START         0

//*****************************************************************************
//
//! The bit number in #g_ulI2CFlags of the flag that is set when an I2C stop
//! condition is detected.
//
//*****************************************************************************
#define I2CS_FLAG_STOP          1

//*****************************************************************************
//
//! The bit number in #g_ulI2CFlags of the flag that is set when the name
//! string is being transferred via the I2C interface.
//
//*****************************************************************************
#define I2CS_FLAG_NAME          2

//*****************************************************************************
//
//! The bit number in #g_ulI2CFlags of the flag that is set when the icon set
//! is being transferred via the I2C interface.
//
//*****************************************************************************
#define I2CS_FLAG_ICONS         3

//*****************************************************************************
//
//! The bit number in #g_ulI2CFlags of the flag that is set when the tool
//! selection is being transferred via the I2C interface.
//
//*****************************************************************************
#define I2CS_FLAG_TOOL          4

//*****************************************************************************
//
//! This array contains the status being written in response to a I2C read
//! request.
//
//*****************************************************************************
static unsigned char g_pucI2CStatus[16];

//*****************************************************************************
//
//! The current index into the name string (for name writes) or the status
//! buffer (for status reads); used to sequence through the corresponding
//! buffers one byte at a time for each I2C data request.
//
//*****************************************************************************
static unsigned long g_ulI2CIndex;

//*****************************************************************************
//
//! Looks for I2C start and stop conditions.
//!
//! This interrupt handler is called in response to edges on the I2C data line.
//! If the data line changes while the I2C clock line is high, then a start or
//! stop condition has occurred.
//!
//! \return None.
//
//*****************************************************************************
void
GPIOBIntHandler(void)
{
    unsigned long ulPins;

    //
    // Clear the GPIO pin interrupt.
    //
    GPIOPinIntClear(GPIO_PORTB_BASE, PIN_SDA);

    //
    // Read the current state of the I2C clock and data lines.
    //
    ulPins = GPIOPinRead(GPIO_PORTB_BASE, PIN_SCL | PIN_SDA);

    //
    // If the clock line is high and the data line is low, then a start
    // condition has just occurred.
    //
    if(ulPins == PIN_SCL)
    {
        //
        // Indicate that a start has just occurred.
        //
        HWREGBITW(&g_ulI2CFlags, I2CS_FLAG_START) = 1;
    }

    //
    // If the clock line is high and the data line is high, then a stop
    // condition has just occurred.
    //
    else if(ulPins == (PIN_SCL | PIN_SDA))
    {
        //
        // Indicate that a stop has just occurred.
        //
        HWREGBITW(&g_ulI2CFlags, I2CS_FLAG_STOP) = 1;
    }
}

//*****************************************************************************
//
//! Handle a command sent from the I2C master.
//!
//! This function processes a command sent from the I2C master.  Most commands
//! are handled completely from the single command byte, while the name string,
//! icon set, and tool selection commands require additional I2C transfers.
//!
//! \return None.
//
//*****************************************************************************
static void
I2CHandleCommand(void)
{
    long lXPos, lYPos, lZPos;

    //
    // Read the command byte from the I2C slave and determine how to handle it.
    //
    switch(I2CSlaveDataGet(I2C_SLAVE_BASE))
    {
        //
        // A positive move along the X axis is being requested.
        //
        case CMD_X_PLUS:
        {
            //
            // See if the table is presently moving.
            //
            if(!TableIsMoving() && !DrawIsDrawing())
            {
                //
                // The table is not moving, so get the current table position.
                //
                TableGetPosition(&lXPos, &lYPos, &lZPos);

                //
                // Move in the positive direction along the X axis.
                //
                TableMoveLine(lXPos + 0x40000000, lYPos, lZPos, X_SPEED,
                              X_ACCEL);
            }

            //
            // Done with this command.
            //
            break;
        }

        //
        // A negative move along the X axis is being requested.
        //
        case CMD_X_MINUS:
        {
            //
            // See if the table is presently moving.
            //
            if(!TableIsMoving() && !DrawIsDrawing())
            {
                //
                // The table is not moving, so get the current table position.
                //
                TableGetPosition(&lXPos, &lYPos, &lZPos);

                //
                // Move in the negative direction along the X axis.
                //
                TableMoveLine(lXPos - 0x40000000, lYPos, lZPos, X_SPEED,
                              X_ACCEL);
            }

            //
            // Done with this command.
            //
            break;
        }

        //
        // A positive move along the Y axis is being requested.
        //
        case CMD_Y_PLUS:
        {
            //
            // See if the table is presently moving.
            //
            if(!TableIsMoving() && !DrawIsDrawing())
            {
                //
                // The table is not moving, so get the current table position.
                //
                TableGetPosition(&lXPos, &lYPos, &lZPos);

                //
                // Move in the positive direction along the Y axis.
                //
                TableMoveLine(lXPos, lYPos + 0x40000000, lZPos, Y_SPEED,
                              Y_ACCEL);
            }

            //
            // Done with this command.
            //
            break;
        }

        //
        // A negative move along the Y axis is being requested.
        //
        case CMD_Y_MINUS:
        {
            //
            // See if the table is presently moving.
            //
            if(!TableIsMoving() && !DrawIsDrawing())
            {
                //
                // The table is not moving, so get the current table position.
                //
                TableGetPosition(&lXPos, &lYPos, &lZPos);

                //
                // Move in the negative direction along the Y axis.
                //
                TableMoveLine(lXPos, lYPos - 0x40000000, lZPos, Y_SPEED,
                              Y_ACCEL);
            }

            //
            // Done with this command.
            //
            break;
        }

        //
        // A positive move along the Z axis is being requested.
        //
        case CMD_Z_PLUS:
        {
            //
            // See if the table is presently moving.
            //
            if(!TableIsMoving() && !DrawIsDrawing())
            {
                //
                // The table is not moving, so get the current table position.
                //
                TableGetPosition(&lXPos, &lYPos, &lZPos);

                //
                // Move in the positive direction along the Z axis.
                //
                TableMoveLine(lXPos, lYPos, lZPos + 0x40000000, Z_SPEED,
                              Z_ACCEL);
            }

            //
            // Done with this command.
            //
            break;
        }

        //
        // A negative move along the Z axis is being requested.
        //
        case CMD_Z_MINUS:
        {
            //
            // See if the table is presently moving.
            //
            if(!TableIsMoving() && !DrawIsDrawing())
            {
                //
                // The table is not moving, so get the current table position.
                //
                TableGetPosition(&lXPos, &lYPos, &lZPos);

                //
                // Move in the negative direction along the Z axis.
                //
                TableMoveLine(lXPos, lYPos, lZPos - 0x40000000, Z_SPEED,
                              Z_ACCEL);
            }

            //
            // Done with this command.
            //
            break;
        }

        //
        // Demo mode one is being selected.
        //
        case CMD_DEMO1:
        {
            //
            // Set the demo mode to one.
            //
            g_ulDemoMode = 1;

            //
            // Done with this command.
            //
            break;
        }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合成人在线视频| 日本va欧美va精品发布| 制服丝袜日韩国产| 国产激情视频一区二区在线观看| 国产精品第四页| 日韩午夜小视频| 日本电影欧美片| 春色校园综合激情亚洲| 日本亚洲最大的色成网站www| 成人免费在线观看入口| 欧美成人性战久久| 欧美三级资源在线| 99这里只有久久精品视频| 婷婷综合五月天| 亚洲精品国产一区二区三区四区在线| 欧美成人r级一区二区三区| 欧美亚洲自拍偷拍| 成人性生交大片| 国产在线精品国自产拍免费| 免费观看日韩电影| 亚洲va欧美va人人爽| 一区二区在线看| 国产精品萝li| 中文天堂在线一区| 国产亚洲短视频| 精品久久一区二区三区| 91精品一区二区三区久久久久久| 91福利区一区二区三区| 波多野结衣中文一区| 国产剧情一区二区| 国产精品亚洲午夜一区二区三区 | 亚洲欧洲美洲综合色网| 久久这里只有精品首页| 欧美tickling网站挠脚心| 777久久久精品| 欧美亚洲国产一区在线观看网站| av电影一区二区| 北条麻妃国产九九精品视频| 成人午夜电影小说| 成人免费观看视频| 高清久久久久久| 成人福利视频在线看| 懂色一区二区三区免费观看| 成人三级伦理片| 不卡一区中文字幕| 不卡一区在线观看| eeuss鲁一区二区三区| 94色蜜桃网一区二区三区| 不卡在线视频中文字幕| 91在线观看成人| 色中色一区二区| 欧美日韩亚洲不卡| 欧美二区三区的天堂| 日韩一区二区在线观看| 欧美大片国产精品| 国产色产综合色产在线视频| 欧美国产一区二区| 亚洲手机成人高清视频| 亚洲国产成人91porn| 美美哒免费高清在线观看视频一区二区| 强制捆绑调教一区二区| 国产一区二区免费看| 不卡视频免费播放| 91麻豆swag| 69堂国产成人免费视频| 久久久久久99久久久精品网站| 国产精品视频免费| 亚洲另类春色国产| 视频一区二区三区入口| 国产一区二区三区电影在线观看| 99视频在线精品| 欧美精品丝袜中出| 久久久久久久综合日本| 亚洲精品国产一区二区精华液 | 91 com成人网| 久久综合色天天久久综合图片| 中文一区在线播放| 一区二区免费在线| 久久成人久久爱| 成av人片一区二区| 91精品在线麻豆| 国产精品久久网站| 喷水一区二区三区| 国产91精品欧美| 欧美另类z0zxhd电影| 久久久久久一级片| 亚洲gay无套男同| 国产精品一区二区黑丝| 欧美日韩综合色| 国产日韩欧美制服另类| 同产精品九九九| 91色视频在线| 久久五月婷婷丁香社区| 亚洲韩国精品一区| 国产.欧美.日韩| 4hu四虎永久在线影院成人| 国产精品久久精品日日| 蜜桃91丨九色丨蝌蚪91桃色| 99精品视频中文字幕| 精品剧情在线观看| 亚洲国产成人av好男人在线观看| 成人美女在线观看| 精品少妇一区二区三区在线播放 | 亚洲欧美日韩在线| 国产福利91精品一区| 欧美日韩午夜精品| 成人欧美一区二区三区白人| 国产精品一区二区三区网站| 91精品国产乱码久久蜜臀| 亚洲欧洲综合另类| 成人综合日日夜夜| www成人在线观看| 日本中文字幕一区二区有限公司| 色综合久久久网| 国产精品网站导航| 国产剧情av麻豆香蕉精品| 欧美一区二区三区电影| 亚洲成a人v欧美综合天堂下载 | 中日韩av电影| 久久99国产精品麻豆| 制服丝袜一区二区三区| 午夜精品成人在线视频| 色天天综合久久久久综合片| 国产精品每日更新| 成人综合婷婷国产精品久久| 欧美精品一区二区三区蜜桃| 免费成人av资源网| 日韩一区二区三区四区五区六区| 亚洲成a天堂v人片| 欧美日韩另类一区| 日韩一区精品视频| 欧美精品高清视频| 日韩—二三区免费观看av| 欧美日韩中字一区| 五月天激情综合| 欧美精品久久99| 蜜臀av性久久久久蜜臀aⅴ | 亚洲免费观看高清| 91麻豆国产自产在线观看| 一区二区三区自拍| 欧美曰成人黄网| 亚洲成人动漫在线免费观看| 欧美精品九九99久久| 免费精品视频在线| 久久久久久久久免费| 成人免费看黄yyy456| 亚洲欧洲在线观看av| 在线欧美小视频| 亚洲第一福利一区| 欧美电影一区二区| 久久国产免费看| 中文字幕精品综合| 色狠狠色狠狠综合| 午夜影院在线观看欧美| 91精品国产欧美一区二区成人| 蜜臀99久久精品久久久久久软件| 精品人伦一区二区色婷婷| 国产精品1024| 亚洲欧美综合网| 欧美日韩一区在线观看| 久久丁香综合五月国产三级网站| 久久综合九色综合97_久久久| 丰满白嫩尤物一区二区| 亚洲精品五月天| 69堂国产成人免费视频| 国产一区二区三区最好精华液| 国产精品你懂的在线| 欧美性色综合网| 黑人巨大精品欧美黑白配亚洲| 国产精品久久久久久久久动漫| 在线观看亚洲精品| 久久精品国产免费| 综合久久一区二区三区| 4438x亚洲最大成人网| 国产高清不卡一区二区| 一区二区三区在线看| 欧美大片日本大片免费观看| 成人黄色网址在线观看| 午夜精品久久久久久久99水蜜桃| 久久精品亚洲国产奇米99| 日本久久精品电影| 精品一区二区三区免费| 亚洲麻豆国产自偷在线| 精品久久久久久久久久久院品网| a4yy欧美一区二区三区| 麻豆国产精品一区二区三区 | 久久一区二区三区四区| 97久久精品人人做人人爽| 免费在线观看精品| 日韩一区欧美小说| 欧美videos中文字幕| 色呦呦网站一区| 国产一区二区三区在线看麻豆| 亚洲一区二区三区四区在线| 久久婷婷综合激情| 欧美另类变人与禽xxxxx| 99re这里只有精品6| 精品无码三级在线观看视频| 亚洲国产wwwccc36天堂| 综合久久国产九一剧情麻豆|