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

📄 tool.c

📁 CNC.rar
💻 C
字号:
//*****************************************************************************
//
// tool.c - Routines for controlling the tool.
//
// 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_memmap.h"
#include "hw_types.h"
#include "gpio.h"

//*****************************************************************************
//
//! \page main_tool_intro Introduction
//!
//! Some tools that can be attached to the CNC machine (such as a router) are
//! powered; these routines provide control of power to such tools.
//!
//! The code for the tool control is contained in <tt>main_micro/tool.c</tt>,
//! with <tt>main_micro/tool.h</tt> containing the API definitions for use by
//! the remainder of the application.
//
//*****************************************************************************

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

//*****************************************************************************
//
//! The GPIO pin on port E to which the panic switch is connected.
//
//*****************************************************************************
#define SHUTDOWN                GPIO_PIN_2

//*****************************************************************************
//
//! The GPIO pin on port E to which the tool power control is connected.
//
//*****************************************************************************
#define TOOL                    GPIO_PIN_3

//*****************************************************************************
//
//! Turns on the tool power.
//!
//! This function turns on the power to the tool.  The power will not be turned
//! on if the panic switch is engaged.
//!
//! \return None.
//
//*****************************************************************************
void
ToolOn(void)
{
    //
    // Only allow the tool to be turned on if the panic switch is not engaged.
    //
    if(GPIOPinRead(GPIO_PORTE_BASE, SHUTDOWN) == SHUTDOWN)
    {
        //
        // Turn on the tool.
        //
        GPIOPinWrite(GPIO_PORTE_BASE, TOOL, TOOL);
    }
}

//*****************************************************************************
//
//! Turns off the tool power.
//!
//! This function turns off the power to the tool.
//!
//! \return None.
//
//*****************************************************************************
void
ToolOff(void)
{
    //
    // Turn off the tool.
    //
    GPIOPinWrite(GPIO_PORTE_BASE, TOOL, 0);
}

//*****************************************************************************
//
//! Initializes the tool control routines.
//!
//! This function prepares the tool control routines for use.  The tool is
//! turned off by default.
//!
//! \return None.
//
//*****************************************************************************
void
ToolInit(void)
{
    //
    // Configure the tool control GPIO as an output and disable turn off the
    // tool.
    //
    GPIODirModeSet(GPIO_PORTE_BASE, TOOL, GPIO_DIR_MODE_OUT);
    GPIOPinWrite(GPIO_PORTE_BASE, TOOL, 0);
}

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

⌨️ 快捷键说明

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