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

📄 maincc01.c

📁 CanOpen的源代码
💻 C
字号:
/**************************************************************************
MODULE:    MAIN
CONTAINS:  Example application using MicroCANopen
           Written for Atmel 89C51CC01 CANARY demo board and Atmel CANopen
           demo board
COPYRIGHT: Embedded Systems Academy, Inc. 2002-2007.
           All rights reserved. www.microcanopen.com
           This software was written in accordance to the guidelines at
           www.esacademy.com/software/softwarestyleguide.pdf
DISCLAIM:  Read and understand our disclaimer before using this code!
           www.esacademy.com/disclaim.htm
LICENSE:   THIS IS THE EDUCATIONAL VERSION OF MICROCANOPEN
           See file license_educational.txt or
           www.microcanopen.com/license_educational.txt
           A commercial MicroCANopen license is available at
           www.CANopenStore.com
VERSION:   3.30, ESA 30-JAN-07
           $LastChangedDate: 2007-01-30 10:38:13 -0800 (Tue, 30 Jan 2007) $
           $LastChangedRevision: 232 $
***************************************************************************/ 

#include "mco.h"
#include "rcc01io.h"
#ifdef __RC51__
#include "c51cc01.h"   // For Raisonance
#else
#include <Reg51CC01.h> // For Keil
#endif

// external declaration for the process image array
extern UNSIGNED8 MEM_NEAR gProcImg[];

/**************************************************************************
DOES:    The main function
RETURNS: nothing
**************************************************************************/
void main
  (
  void
  )
{
  // Reset/Initialize CANopen communication
  MCOUSER_ResetCommunication();

  // end of initialization, enable all interrupts
  EA = 1;

  // foreground loop
  while(1)
  {
    // Update process data
    // First digital inputs are real I/O
    gProcImg[P600001_DIGINPUT8_] = read_dip_switches();

    // output first digital outputs to LEDs
    switch_leds(gProcImg[P620001_DIGOUTPUT8_]); 

    // echo all other I/O values from input to output
    gProcImg[P600001_DIGINPUT8_] = gProcImg[P620002_DIGOUTPUT8_];
    gProcImg[P600001_DIGINPUT8_] = gProcImg[P620003_DIGOUTPUT8_];
    gProcImg[P600001_DIGINPUT8_] = gProcImg[P620004_DIGOUTPUT8_];

    // analog
    gProcImg[P640101_ANALOGINPUT16_]   = gProcImg[P641101_ANALOGOUTPUT16_];
    gProcImg[P640101_ANALOGINPUT16_+1] = gProcImg[P641101_ANALOGOUTPUT16_+1];
    gProcImg[P640102_ANALOGINPUT16_]   = gProcImg[P641102_ANALOGOUTPUT16_];
    gProcImg[P640102_ANALOGINPUT16_+1] = gProcImg[P641102_ANALOGOUTPUT16_+1];

    // Operate on CANopen protocol stack
    MCO_ProcessStack();
  } // end of while(1)
} // end of main

⌨️ 快捷键说明

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