maincc01.c

来自「Canopen 最小实现源码, 只支持最小的CANOPEN功能」· C语言 代码 · 共 73 行

C
73
字号
/**************************************************************************
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 - 2004
           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
VERSION:   2.10, ESA 12-JAN-05
           $LastChangedDate: 2005-01-12 13:53:59 -0700 (Wed, 12 Jan 2005) $
           $LastChangedRevision: 48 $
***************************************************************************/ 

#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[IN_digi_1] = read_dip_switches();

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

    // echo all other I/O values from input to output
    // digital
    gProcImg[IN_digi_2] = gProcImg[OUT_digi_2];
    gProcImg[IN_digi_3] = gProcImg[OUT_digi_3];
    gProcImg[IN_digi_4] = gProcImg[OUT_digi_4];

    // analog
    gProcImg[IN_ana_1]   = gProcImg[OUT_ana_1];
    gProcImg[IN_ana_1+1] = gProcImg[OUT_ana_1+1];
    gProcImg[IN_ana_2]   = gProcImg[OUT_ana_2];
    gProcImg[IN_ana_2+1] = gProcImg[OUT_ana_2+1];

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

⌨️ 快捷键说明

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