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

📄 init.h

📁 This library is Copyright (c) Raphael Zulliger <zulli@gmx.net>. It is licensed under the GNU L
💻 H
字号:
/***************************************************************************
                          init.h  -  description
                             -------------------
    begin                : Fri May 17 2002
    copyright            : (C) 2002 by Raphael Zulliger
    email                : zulli@hsr.ch
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is Copyright (c) Raphael Zulliger <zulli@gmx.net>.       *
 *   It is licensed under the GNU Library General Public License (LGPL).   *
 *                                                                         *
 ***************************************************************************/


/** \file
 *  \brief Functions for initialisation of the SlaveLib & CAN-interface
 *
 *  Functions, vars and definitions which are canopen-lowlevel nature.
 *  such as init canopen, deinit canopen, ...
 */

#ifndef __init_h__
#define __init_h__

#include <def.h>
 
/** eBaudRate is an enumeration which defines all possible baudrates. Of course
 *  more baudrates could be defined here, if neccessary
 */
enum eBaudRate { b10kBit=10, b20k=20, b50k=50, b100k=100, b125k=125, b250k=250, b500k=500, b800k=800, b1M=1000 };

/** This struct is used for initialising the CAN controller/interface. Therefore baudrate, node-id, processor-
 *  speed, irq and IO adress are needed (the latter two are only used for PC based can-controllers)
 */
typedef struct td_s_sInitParameter
{
    /** Node-Id of this device (1..127)
     */
    BYTE    bNodeID;  		
    /** Baudrate (see above) possible values: see eBaudRate enumeration
     */
    WORD    wBaudRateIndex;
    /** Processor speed in kHz (e.g. 4000 for 4MHz). Needed for setting up timer and baudrate
     */
    WORD    wProcSpeed;
    /** IRQ number (only used for PC-based cards)
     */
    BYTE    bIRQ; 			
    /** IO-Adress (only used for PC-based cards)
     */
    WORD    wIO;  			
} sInitParameter;


/** Sets the ID of this node, initializes CAN-interface (by calling t platform dependent
 *  setupCanInterface from canop.h.
 *  \param initParameter Struct that contains all relevant data for initialising the slavelib
 *                       and the CAN-interface.
 */
BYTE initConnection( sInitParameter* initParameter );

/** Closes connection to the CANbus. Probably only needed for PC based CAN cards
 */
void closeConnection( void );


// variable which holds the node-id of this device
/** the node-id of this device
 */
extern BYTE bDeviceNodeId;			
/** the actual state of this device: INITIALISATION, PRE_OPERATIONAL,OPERATIONAL or STOPPED
 */
extern BYTE bStateMachineState;



// defines for the state-machine
// -----------------------------
// state-change commands
/** change state machine state into: operational
 */
#define START_REMOTE_NODE				0x01
/** change state machine state into: stopped
 */
#define STOP_REMOTE_NODE				0x02
/** change state machine state into: pre-operational
 */
#define ENTER_PRE_OPERATIONAL_STATE		0x80
/** change state machine state into: reset node
 */
#define RESET_REMOTE_NODE				0x81
/** change state machine state into: reset communication
 */
#define RESET_REMOTE_COMMUNICATION		0x82

// possible state machine states
// values are choosen so, that they can be sent directly for
// heartbeat messages...
/** state machine is in state: operational
 */
#define OPERATIONAL 					(BYTE)0x05
/** state machine is in state: stopped
 */
#define STOPPED							(BYTE)0x04
/** state machine is in state: pre-operational
 */
#define PRE_OPERATIONAL					(BYTE)0x7F
/** state machine is in state: initialisation of the node
 */
#define INITIALISATION_NODE				(BYTE)0x00
/** state machine is in state: initialisation of the communication
 */
#define INITIALISATION_COMMUNICATION	(BYTE)0x10

#endif // __init_h__

⌨️ 快捷键说明

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