Mitsubishi Electric Eclipse User Manual Page 32

  • Download
  • Add to my manuals
  • Print
  • Page
    / 60
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 31
30
2. Source code
The following describes source codes.
/***********************************************************************************************************************/
/* Function header */
/***********************************************************************************************************************/
#include <vxworks.h> /* VxWorks function header */
#include <taskLib.h> /* VxWorks function header */
#include <stdio.h> /* Standard function header */
#include "QbfFunc.h" /* Bus interface function header */
/***********************************************************************************************************************/
/* Definition */
/***********************************************************************************************************************/
/* For debugging */
#define UNIT_XY 0x0000 /* Start I/O number of the module */
#define QY_LED 0x5555 /* Initial output value of Y signal (even bit: on) */
#define SEG_LED1 0xFF /* Initial output value of 7-segment LED (ones place) */
#define SEG_LED2 0x00 /* Initial output value of 7-segment LED (tens place) */
/***********************************************************************************************************************/
/* For QBF function */
#define CPU_TYPE 2 /* CPU identification flag (CCPU: 2) */
#define WORD 1 /* 1-word specification */
#define NORMAL_ACCESS 0 /* General access specification */
#define DUMMY 0 /* Dummy */
#define MODE_MANUAL 0 /* 7-segment LED control mode */
/***********************************************************************************************************************/
/* Process outputs from Y signal and control the 7-segment LED. */
/***********************************************************************************************************************/
void Q12_SampleTask()
{
/* Declare local variables. */
short sRet; /* Return value of the QBF function */
long lPath; /* Path of a bus */
unsigned short usDataBuf; /* Y signal (in units of words) */
unsigned short usEmptyDataBuf; /* For reset of Y signal */
char pcdata[2]; /* 7-segment LED on value */
short i; /* For loop */
/* Open the bus. */
sRet = QBF_Open(CPU_TYPE, &lPath);
if(sRet != 0){
printf("ERROR : QBF_Open [%d(%04hxH)]\n", sRet, sRet);
return;
}
/* Set the output signal (Y) value (turn on the even bit). */
usDataBuf = QY_LED;
/* Set the output value of the 7-segment LED (only the ones places are all lit). */
pcdata[0] = SEG_LED1;
pcdata[1] = SEG_LED2;
/* Perform an output control and 7-segment LED control in turns by 20 times. */
for(i = 0; i < 20; i++){
/* Output control */
sRet = QBF_Y_Out_WordEx(lPath, NORMAL_ACCESS, UNIT_XY, WORD, &usDataBuf, DUMMY);
if(sRet != 0){
printf("ERROR : QBF_Y_Out_WordEx_1 [%d(%04hxH)]\n", sRet, sRet);
QBF_Close(lPath);
return;
}
/* 7-segment LED control */
sRet = QBF_Control7SegLED(lPath, MODE_MANUAL, &pcdata[0]);
if(sRet != 0){
printf("ERROR : QBF_Control7SegLED_1 [%d(%04hxH)]\n", sRet, sRet);
QBF_Close(lPath);
return;
}
/* Invert the output signal (Y) value (turn on the bits in order of odd bit
-
> even bit
-
>...). */
usDataBuf = ~usDataBuf;
Control the output
module using the bus
interface function.
Control the 7-segment
LED using the bus
interface function.
Enable the bus
interface function at the
start of the program.
Declare the file that
defined a function
list for use of the
library function.
Define values used
for the control.
Page view 31
1 2 ... 27 28 29 30 31 32 33 34 35 36 37 ... 59 60

Comments to this Manuals

No comments