📄 pcmaster.h
字号:
/******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2001 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
*******************************************************************************
*
* FILE NAME: pcmaster.h
*
* DESCRIPTION: Header file for PC Master
*
* MODULES INCLUDED: none
*
* NOTES:
*
*******************************************************************************/
#ifndef _PCMASTER_H_
#define _PCMASTER_H_
/*-----------------------------------------------------------------------------
PC Master communication protocol specific part:
!!! DO NOT MODIFY !!!
---------------------------------------------------------------------------*/
/*-------------------------------------
command message - standard commands
-------------------------------------*/
#define PCMASTER_CMD_READMEM 0x01 /* read block of memory */
#define PCMASTER_CMD_WRITEMEM 0x02 /* write block of memory */
#define PCMASTER_CMD_WRITEMEMMASK 0x03 /* write block of memory with mask */
#define PCMASTER_CMD_SETUPSCOPE 0x08 /* setup scope */
#define PCMASTER_CMD_SETUPREC 0x09 /* setup recorder */
#define PCMASTER_CMD_CALLAPPCMD 0x10 /* call user application command */
/*-------------------------------------
command message - special commands
-------------------------------------*/
/* no data part */
#define PCMASTER_CMD_GETINFO 0xC0 /* get system information */
#define PCMASTER_CMD_GETINFOBRIEF 0xC8 /* get brief system information */
#define PCMASTER_CMD_STARTREC 0xC1 /* start recorder */
#define PCMASTER_CMD_STOPREC 0xC2 /* stop recorder */
#define PCMASTER_CMD_GETRECSTS 0xC3 /* get recorder status */
#define PCMASTER_CMD_GETRECBUFF 0xC4 /* get recorder buffer information */
#define PCMASTER_CMD_READSCOPE 0xC5 /* read scope variables */
#define PCMASTER_CMD_GETAPPCMDSTS 0xC6 /* get user application command status */
/* 2 bytes data part */
#define PCMASTER_CMD_READVAR8 0xD0 /* read 8-bit variable from 16-bit address */
#define PCMASTER_CMD_READVAR16 0xD1 /* read 16-bit variable from 16-bit address */
#define PCMASTER_CMD_READVAR32 0xD2 /* read 32-bit variable from 16-bit address */
/* 4 bytes data part */
#define PCMASTER_CMD_READVAR8EX 0xE0 /* read 8-bit variable from 32-bit address */
#define PCMASTER_CMD_READVAR16EX 0xE1 /* read 16-bit variable from 32-bit address */
#define PCMASTER_CMD_READVAR32EX 0xE2 /* read 32-bit variable from 32-bit address */
/* get info command parameters */
#define PCMASTER_PROT_VER 2 /* PC Master protocol version 2.0 */
#define PCMASTER_DATABUSWDT 2 /* data bud width 16 bit */
#define PCMASTER_CFG_FLAFGS 0x0004 /* little endian data format + no fast writes */
#define PCMASTER_IDT_STRING_LEN 25 /* length of identification string */
/*-------------------------------------
response message - status byte
-------------------------------------*/
/* confirmation codes */
#define PCMASTER_STC_OK 0x00 /* operation succesful */
#define PCMASTER_STC_RECRUN 0x01 /* recorder running */
#define PCMASTER_STC_RECDONE 0x02 /* recorder finished */
/* error codes */
#define PCMASTER_STC_INVCMD 0x81 /* invalid command */
#define PCMASTER_STC_CMDSERR 0x82 /* checksum error */
#define PCMASTER_STC_CMDBUFFOVF 0x83 /* command too long */
#define PCMASTER_STC_RSPBUFFOVF 0x84 /* response would be too long */
#define PCMASTER_STC_INVBUFF 0x85 /* invalid buffer length specified */
#define PCMASTER_STC_INVSIZE 0x86 /* invalid size */
#define PCMASTER_STC_SERVBUSY 0x87 /* service is busy */
#define PCMASTER_STC_NOTINIT 0x88 /* scope/recorder not configured */
#define PCMASTER_STC_UNKNOWN 0xFF /* reserved */
/* recorder trigger modes */
#define PCMASTER_REC_TRIGOFF 0 /* manual mode (trigger disabled) */
#define PCMASTER_REC_TRIGRIS 1 /* rising edge */
#define PCMASTER_REC_TRIGFAL 2 /* falling edge */
/*-----------------------------------------------------------------------------
PC Master buffer lengths and other default values:
PCMASTER_BUFFER_SIZE - PC Master input/output buffer size,
PCMASTER_REC_BUFF_LEN - PC Master Recorder buffer size,
PCMASTER_APPCMD_BUFF_LEN - PC Master Applciation Command buffer size,
PCMASTER_RECORDER_TIME_BASE - PC Master Recorder time base value,
PCMASTER_GLOB_VERSION_MAJOR - board firmware major number
PCMASTER_GLOB_VERSION_MINOR - board firmware minor number
PCMASTER_IDT_STRING - device identification string
NOTE: This values should be defined in the appconfig.h file
E.G.
#define PCMASTER_BUFFER_SIZE 150
(this code placed in the appconfig.h file will enlarge the PC Master
input/output buffer size to 150 from default value 40)
---------------------------------------------------------------------------*/
#ifndef PCMASTER_BUFFER_SIZE
/* PC Master input/output buffer size */
#define PCMASTER_BUFFER_SIZE 40
#endif
#ifndef PCMASTER_REC_BUFF_LEN
/* recorder buffer length */
#define PCMASTER_REC_BUFF_LEN 200
#endif
#ifndef PCMASTER_RECORDER_TIME_BASE
/* recorder time base default value */
#define PCMASTER_RECORDER_TIME_BASE 0x8000
#endif
#ifndef PCMASTER_APPCMD_BUFF_LEN
/* Application Command buffer length */
#define PCMASTER_APPCMD_BUFF_LEN 10
#endif
#ifndef PCMASTER_GLOB_VERSION_MAJOR
/* board firmware version major number */
#define PCMASTER_GLOB_VERSION_MAJOR 0
#endif
#ifndef PCMASTER_GLOB_VERSION_MINOR
/* board firmware version minor number */
#define PCMASTER_GLOB_VERSION_MINOR 0
#endif
#ifndef PCMASTER_IDT_STRING
/* device identification string */
#define PCMASTER_IDT_STRING "PC Master communication !"
#endif
/*-----------------------------------------------------------------------------
FUNCTION PROTOTYPES
---------------------------------------------------------------------------*/
/*
Initialization of PC Master Communication Algorithm
This function must be called first, before start of communication.
*/
Word16 pcmasterInit(void);
/*
Get Application Command Status
This function is used to check if an application command has been received from PC
*/
#ifdef PCMASTER_INCLUDE_CMD_APPCMD
UWord16 pcmasterGetAppCmdSts(void);
#else
/* #pragma warning_errors off
#warning pcmasterGetAppCmdSts function call will be removed!!!
#pragma warning_errors reset
*/
#define pcmasterGetAppCmdSts() 0 /* no new command received */
#endif
/*
Write Application Command Status
This function clears the flags in application command status word
and it says to PC that the last application command was served and
new application command from PC will be accepted
*/
#ifdef PCMASTER_INCLUDE_CMD_APPCMD
Word16 pcmasterWriteAppCmdSts(UWord16 state);
#else
/* #pragma warning_errors off
#warning pcmasterWriteAppCmdSts function call will be removed!!!
#pragma warning_errors reset
*/
#define pcmasterWriteAppCmdSts(x) 0
#endif
/*
Main PC Master Communication routine which provide receiving,
decoding of incoming message and sending response to PC -
must be called in interrupt
*/
void pcmasterRxTxIsr(void);
/* This function performs clearing of SCI module exceptions,
must be called in SCI Rx Error interrupt */
void pcmasterRxErrorIsr(void);
/*
Recorder Routine
It performs sampling of data into internal recorderBuff buffer
*/
#ifdef PCMASTER_INCLUDE_CMD_RECORDER
void pcmasterRecorder(void);
/*
#ifdef PCMASTER_INCLUDE_CMD_GETINFO_BRIEF
#pragma warning_errors off
#warning PC Master Recorder buffer size will not be transfered to PC!!! - use #undef PCMASTER_INCLUDE_CMD_GETINFO_BRIEF
#pragma warning_errors reset
#endif
*/
#else
/* #pragma warning_errors off
#warning pcmasterRecorder function call will be removed!!!
#pragma warning_errors reset
*/
#define pcmasterRecorder()
#endif
#endif
/*-----------------------------------------------------------------------------
SPECIAL FEATURES FUNCTIONS
---------------------------------------------------------------------------*/
/*
Main PC Master Communication routine which provide receiving,
decoding of incoming message and sending response to PC -
must be called periodically (not in interrupt)
*/
void pcmasterRxTxPoll(void);
/* return address of the PC Master Recorder buffer */
UWord16 *pcmasterGetRecBuffPtr(void);
/* mark recorder buffer as full, then it is ready to be transfered to PC */
void pcmasterRecBuffFull(void);
/* check whether whole buffer was already downloaded to PC and the recorder was started again */
UWord16 pcmasterGetRecBuffEmpty(void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -