上传文件至 /
This commit is contained in:
264
SSC.C
Normal file
264
SSC.C
Normal file
@@ -0,0 +1,264 @@
|
||||
//****************************************************************************
|
||||
// @Module High Speed Synchronous Serial Interface(SSC)
|
||||
// @Filename SSC.C
|
||||
// @Project CL2.0.dav
|
||||
//----------------------------------------------------------------------------
|
||||
// @Controller Infineon XC886CLM-8FF
|
||||
//
|
||||
// @Compiler Keil
|
||||
//
|
||||
// @Codegenerator 1.9
|
||||
//
|
||||
// @Description: This file contains functions that use the SSC module.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2013-11-11 12:29:47
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,1)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Project Includes
|
||||
//****************************************************************************
|
||||
|
||||
#include "MAIN.H"
|
||||
|
||||
// USER CODE BEGIN (SSC_General,2)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Macros
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,3)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Defines
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,4)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Typedefs
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,5)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Imported Global Variables
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,6)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Global Variables
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,7)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @External Prototypes
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,8)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Prototypes Of Local Functions
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_General,9)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void SSC_vInit(void)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description This is the initialization function of the SSC function
|
||||
// library. It is assumed that the SFRs used by this library
|
||||
// are in their reset state.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2013-11-11
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (Init,1)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
void SSC_vInit(void)
|
||||
{
|
||||
// USER CODE BEGIN (Init,2)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
/// - Port Selection
|
||||
SSC_PISEL = 0x01; // load SSC Port Input Select Register to
|
||||
// Port A
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of the used SSC Port Pins:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Pin SCLK (P0.3) is selected for SCLK ouput
|
||||
/// Pin MTSR_1 (P0.4) is selected for Master Transmit Output
|
||||
/// Pin MRST_1 (P0.5) is selected for Master Receive Input
|
||||
|
||||
SFR_PAGE(_pp2, noSST); // switch to page 2 without saving
|
||||
P0_ALTSEL0 |= 0x18; // set AltSel0
|
||||
P0_ALTSEL1 &= ~(ubyte)0x18; // set AltSel1
|
||||
|
||||
SFR_PAGE(_pp0, noSST); // switch to page 0 without saving
|
||||
P0_DIR |= 0x18; // set OutPut Direction
|
||||
|
||||
|
||||
/// Pin SCLK (P1.2) is Not selected for SCLK ouput
|
||||
/// Pin MTSR_0 (P1.3) is Not selected for Master Transmit Output
|
||||
/// Pin MRST_0 (P1.4) Not is selected for Master Receive Input
|
||||
|
||||
SSC_CONH_P &= ~(ubyte)0x80; // enable access to control bits
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of the SSC Baud Rate Generator:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - required baud rate = 2000.000 kbaud
|
||||
/// - real baud rate = 2000.000 kbaud
|
||||
/// - deviation = 0.000 %
|
||||
|
||||
SSC_BRH = 0x00; // load SSC baud rate time reload register
|
||||
// high
|
||||
SSC_BRL = 0x05; // load SSC baud rate time reload register
|
||||
// low
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of the SSC Operation Mode:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - this device is configured as SSC master
|
||||
/// - transfer data width is 8 bit
|
||||
/// - transfer/receive MSB first
|
||||
/// - shift transmit data on the leading clock edge, latch on trailing edge
|
||||
/// - idle clock line is low, leading clock edge is low-to-high transition
|
||||
/// - ignore receive error
|
||||
/// - ignore phase error
|
||||
|
||||
|
||||
SSC_CONH_P = 0x40; // load SSC control register
|
||||
|
||||
SSC_CONL_P = 0x17; // load SSC control register
|
||||
|
||||
SSC_CONH_P |= 0x80; // disable access to control bits
|
||||
|
||||
/// - SSC interrupt is disabled
|
||||
|
||||
// USER CODE BEGIN (Init,3)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
} // End of function SSC_vInit
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void SSC_vSendData(ubyte Data)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description The master device can initiate the first data transfer by
|
||||
// writing the transmit data into transmit buffer. This value
|
||||
// is copied into the shift register (which is assumed to be
|
||||
// empty at this time), and the selected first bit of the
|
||||
// transmit data is placed onto the MTSR line on the next
|
||||
// clock from the baud rate generator.
|
||||
// A slave device immediately outputs the selected first bit
|
||||
// (MSB or LSB of the transfer data) at pin MRST, when the
|
||||
// contents of the transmit buffer are copied into the slave's
|
||||
// shift register.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters Data:
|
||||
// Data to be send
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2013-11-11
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SendData,1)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
void SSC_vSendData(ubyte Data)
|
||||
{
|
||||
SSC_TBL = Data; // load transmit buffer register
|
||||
|
||||
} // End of function SSC_vSendData
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Function ubyte SSC_vGetData(void)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description This function returns the contents of the receive buffer.
|
||||
// When the receive interrupt request flag is set this implies
|
||||
// that data is available for reading in the receive buffer.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue Received data
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2013-11-11
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (GetData,1)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
ubyte SSC_vGetData(void)
|
||||
{
|
||||
return(SSC_RBL); // return receive buffer register
|
||||
|
||||
} // End of function SSC_vGetData
|
||||
|
||||
|
||||
|
||||
// USER CODE BEGIN (SSC_General,10)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
107
SSC.H
Normal file
107
SSC.H
Normal file
@@ -0,0 +1,107 @@
|
||||
//****************************************************************************
|
||||
// @Module High Speed Synchronous Serial Interface(SSC)
|
||||
// @Filename SSC.H
|
||||
// @Project CL2.0.dav
|
||||
//----------------------------------------------------------------------------
|
||||
// @Controller Infineon XC886CLM-8FF
|
||||
//
|
||||
// @Compiler Keil
|
||||
//
|
||||
// @Codegenerator 1.9
|
||||
//
|
||||
// @Description: This file contains all function prototypes and macros for
|
||||
// the SSC module.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2013-11-11 12:29:47
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,1)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
|
||||
#ifndef _SSC_H_
|
||||
#define _SSC_H_
|
||||
|
||||
//****************************************************************************
|
||||
// @Project Includes
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,2)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Macros
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,3)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Defines
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,4)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Typedefs
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,5)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Imported Global Variables
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,6)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Global Variables
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,7)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Prototypes Of Global Functions
|
||||
//****************************************************************************
|
||||
|
||||
void SSC_vInit(void);
|
||||
void SSC_vSendData(ubyte Data);
|
||||
ubyte SSC_vGetData(void);
|
||||
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,8)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Interrupt Vectors
|
||||
//****************************************************************************
|
||||
|
||||
|
||||
// USER CODE BEGIN (SSC_Header,9)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
#endif // ifndef _SSC_H_
|
||||
505
START_XC.a51
Normal file
505
START_XC.a51
Normal file
@@ -0,0 +1,505 @@
|
||||
$NOMOD51
|
||||
;------------------------------------------------------------------------------
|
||||
; This file is part of the C51 Compiler package
|
||||
; Startup Code for the Infineon XC8xx devices
|
||||
; Copyright (c) 1988-2005 Keil Elektronik GmbH and Keil Software, Inc.
|
||||
; Version 20100601
|
||||
; -------- Revision ---------
|
||||
; - Previous version 20100405
|
||||
; - Added XC864 with option for LIN_BSL parameters
|
||||
; - Renamed NDIV_XC866 to NDIV_XC86x
|
||||
;
|
||||
; *** <<< Use Configuration Wizard in Context Menu >>> ***
|
||||
;------------------------------------------------------------------------------
|
||||
; STARTUP.A51: This code is executed after processor reset.
|
||||
;
|
||||
; To translate this file use A51 with the following invocation:
|
||||
;
|
||||
; A51 STARTUP.A51
|
||||
;
|
||||
; To link the modified STARTUP.OBJ file to your application use the following
|
||||
; Lx51 invocation:
|
||||
;
|
||||
; Lx51 your object file list, STARTUP.OBJ controls
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
;<e> Use off-chip XTAL
|
||||
;<i> XC8xx series runs by default from on-chip osciallator.
|
||||
;<i> optionally you may use a off-chip XTAL
|
||||
;
|
||||
XTAL EQU 1 ; set to 0 On-chip oscillator/ not used for XC82x devices
|
||||
;
|
||||
;<e> Device = " XC82x "
|
||||
XC82x_CHIP EQU 0 ;applicable to XC83x
|
||||
;---------------------------------------------------------------------
|
||||
;resulting in fsys = 80MHz for XC866/XC864 and fsys = 96MHz for XC88x unless otherwise mentioned
|
||||
;
|
||||
;<e> Device = " XC866 "
|
||||
XC866_CHIP EQU 0
|
||||
;<e> Device = " XC864 "
|
||||
XC864_CHIP EQU 0
|
||||
;
|
||||
; <o> PLL N-Divider
|
||||
; <i> PLL N-Divider must result in fsys = 80MHz
|
||||
; <0=> N=14
|
||||
; <1=> N=15
|
||||
; <2=> N=16 (10 MHz XTAL)
|
||||
; <3=> N=17
|
||||
; <4=> N=18
|
||||
; <5=> N=19
|
||||
; <6=> N=20 (8 MHz XTAL)
|
||||
; <7=> N=21
|
||||
; <8=> N=24
|
||||
; <9=> N=28
|
||||
; <10=> N=30
|
||||
; <11=> N=32 (5 MHz XTAL)
|
||||
; <12=> N=40
|
||||
; <13=> N=42
|
||||
; <14=> N=45
|
||||
; <15=> N=50
|
||||
;
|
||||
NDIV_XC86x EQU 2 ; default 2
|
||||
;</e>
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
;<e> Device = " XC88x "
|
||||
XC88x_CHIP EQU 1
|
||||
;
|
||||
; <o> PLL N-Divider for *NON-SAL* device fsys = 96 MHz
|
||||
; <0=> N=10
|
||||
; <1=> N=12
|
||||
; <2=> N=13
|
||||
; <3=> N=14
|
||||
; <4=> N=15
|
||||
; <5=> N=16 (12 MHz XTAL)
|
||||
; <6=> N=17
|
||||
; <7=> N=18
|
||||
; <8=> N=19
|
||||
; <9=> N=20 (9.6 MHz On-Chip XTAL)
|
||||
; <10=> N=24 (8 MHz XTAL)
|
||||
; <11=> N=30
|
||||
; <12=> N=32 (6 MHz XTAL)
|
||||
; <13=> N=36
|
||||
; <14=> N=40
|
||||
; <15=> N=48 (4 MHz XTAL)
|
||||
;
|
||||
; <o> PLL N-Divider for *SAL* device -> fsys = 80 MHz
|
||||
; <0=> N=10
|
||||
; <1=> N=12
|
||||
; <2=> N=13
|
||||
; <3=> N=14
|
||||
; <4=> N=15
|
||||
; <5=> N=16 (10 MHz On-Chip XTAL)
|
||||
; <6=> N=17
|
||||
; <7=> N=18
|
||||
; <8=> N=19
|
||||
; <9=> N=20 (8 MHz XTAL)
|
||||
; <10=> N=24
|
||||
; <11=> N=30
|
||||
; <12=> N=32 (5 MHz XTAL)
|
||||
; <13=> N=36
|
||||
; <14=> N=40 (4 MHz XTAL)
|
||||
; <15=> N=48
|
||||
;
|
||||
|
||||
NDIV_XC88x EQU 10 ; default 10
|
||||
;</e>
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
;<e> Device = " XC87x "
|
||||
XC878_CHIP_16FF EQU 0
|
||||
XC878_CHIP_13FF EQU 0
|
||||
XC874_CHIP_16FF EQU 0
|
||||
XC874_CHIP_13FF EQU 0
|
||||
|
||||
;4 MHz
|
||||
NDIV_XC87x_PLL_CON EQU 0x18
|
||||
NDIV_XC87x_PLL_CON1 EQU 0x20
|
||||
NR_XC87x EQU 0x00
|
||||
OD_XC87x EQU 0x00
|
||||
|
||||
;6 MHz
|
||||
;NDIV_XC87x_PLL_CON EQU 0x18
|
||||
;NDIV_XC87x_PLL_CON1 EQU 0x20
|
||||
;NR_XC87x EQU 0x01
|
||||
;OD_XC87x EQU 0x00
|
||||
|
||||
;8 MHz default
|
||||
;NDIV_XC87x_PLL_CON EQU 0x18
|
||||
;NDIV_XC87x_PLL_CON1 EQU 0x20
|
||||
;NR_XC87x EQU 0x02
|
||||
;OD_XC87x EQU 0x00
|
||||
|
||||
;</e>
|
||||
|
||||
;</e>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; User-defined <h> Power-On Initialization of Memory
|
||||
;
|
||||
; With the following EQU statements the initialization of memory
|
||||
; at processor reset can be defined:
|
||||
;
|
||||
;<o> IDATA memory length <0x0-0x100>
|
||||
;<i> Note: The absolute start-address of IDATA memory is always 0
|
||||
;<i> The IDATA space overlaps physically the DATA and BIT areas.
|
||||
IDATALEN EQU 0x100
|
||||
;
|
||||
; <o> XDATA memory start address <0x0-0xFFFF>
|
||||
; <i> absolute start-address of XDATA memory
|
||||
XDATASTART EQU 0xF000
|
||||
;
|
||||
; <o> XDATA memory length <0x0-0xFFFF>
|
||||
; <i> length of XDATA memory in bytes.
|
||||
IF (XC82x_CHIP)
|
||||
XDATALEN EQU 0x100
|
||||
ELSEIF (XC866_CHIP || XC864_CHIP)
|
||||
XDATALEN EQU 0x200
|
||||
ELSEIF (XC88x_CHIP)
|
||||
XDATALEN EQU 0x600
|
||||
ELSEIF (XC878_CHIP_16FF || XC878_CHIP_13FF)
|
||||
XDATALEN EQU 0xC00
|
||||
ELSEIF (XC874_CHIP_16FF || XC874_CHIP_13FF)
|
||||
XDATALEN EQU 0xC00
|
||||
|
||||
ENDIF
|
||||
|
||||
;
|
||||
; <o> PDATA memory start address <0x0-0xFFFF>
|
||||
; <i> absolute start-address of PDATA memory
|
||||
PDATASTART EQU 0xF000
|
||||
;
|
||||
; <o> PDATA memory length <0x0-0xFF>
|
||||
; <i> length of PDATA memory in bytes.
|
||||
PDATALEN EQU 0
|
||||
;
|
||||
; </h>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; <h> Reentrant Stack Initilization
|
||||
;
|
||||
; The following EQU statements define the stack pointer for reentrant
|
||||
; functions and initialized it:
|
||||
;
|
||||
; Stack Space for reentrant functions in the SMALL model.
|
||||
; <e> Activate reentrant Stack (SMALL model)
|
||||
IBPSTACK EQU 0 ; set to 1 if small reentrant is used.
|
||||
; <o> top of stack <0x0-0xFF>
|
||||
; <i> set top of stack to highest location+1
|
||||
IBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1
|
||||
; </e>
|
||||
;
|
||||
; Stack Space for reentrant functions in the LARGE model.
|
||||
; <e> Activate reentrant Stack (LARGE model)
|
||||
XBPSTACK EQU 0 ; set to 1 if large reentrant is used.
|
||||
; <o> top of stack <0x0-0xFFFF>
|
||||
; <i> set top of stack to highest location+1.
|
||||
XBPSTACKTOP EQU 0xFFFF +1 ; default 0FFFFH+1
|
||||
; </e>
|
||||
;
|
||||
; Stack Space for reentrant functions in the COMPACT model.
|
||||
; <e> Activate reentrant Stack (COMPACT model)
|
||||
PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.
|
||||
;
|
||||
; <o> top of stack <0x0-0xFF>
|
||||
; <i> set top of stack to highest location+1.
|
||||
PBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1
|
||||
; </e>
|
||||
; </h>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; <e>Set Memory Page for Using the Compact Model with 64 KByte xdata RAM
|
||||
;
|
||||
; <i>Define the xdata page used for pdata variables.
|
||||
; <i>PPAGE must conform with the PPAGE set in the linker invocation.
|
||||
;
|
||||
; Enable pdata memory page initalization
|
||||
PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.
|
||||
;
|
||||
; <o> PPAGE number <0x0-0xFF>
|
||||
; <i> uppermost 256-byte address of the page used for pdata variables.
|
||||
PPAGE EQU 0xF0
|
||||
;
|
||||
; </e>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; <e>Parameters for LIN Boostrap Loader (XC864 only)
|
||||
; <i>When these values are not defined, an XC864 device stays in
|
||||
; <i>LIN-BSL mode and does not start the user application
|
||||
;
|
||||
; Enable LIN BSL parameter initialization
|
||||
LIN_BSL EQU 1 ; set to 1 if LIN BSL parameters should be generated in flash table
|
||||
;
|
||||
; <o> NAC: No. Activity Count <0x00-0xFF>
|
||||
; <i> specifies the delay (n * 5ms) before jumping to user mode.
|
||||
; <i> 0x01: 0 ms delay. Jump to User Mode immediately
|
||||
; <i> 0x02: 5 ms delay before jumping to User Mode
|
||||
; <i> 0x03: 10 ms delay before jumping to User Mode
|
||||
; <i> 0x04 - 0x0C: 15 - 55 ms delay before jumping to User Mode
|
||||
; <i> 0x0D - 0xFF, 0x00: Enter LIN BSL Mode (Invalid NAC)
|
||||
LIN_NAC EQU 0x01
|
||||
;
|
||||
; <o> NAD: Node Address for Diagnostic <0x00-0xFF>
|
||||
; <i> specifies the address of the active slave node.
|
||||
LIN_NAD EQU 0x01
|
||||
;
|
||||
; </e>
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;Check the chip selection
|
||||
IF ((XC82x_CHIP + XC866_CHIP + XC864_CHIP + XC88x_CHIP + XC878_CHIP_16FF + XC878_CHIP_13FF + XC874_CHIP_16FF + XC874_CHIP_13FF) > 1)
|
||||
__ERROR__ "Please select only one chip!"
|
||||
ELSEIF ((XC82x_CHIP + XC866_CHIP + XC864_CHIP + XC88x_CHIP + XC878_CHIP_16FF + XC878_CHIP_13FF + XC874_CHIP_16FF + XC874_CHIP_13FF) == 0)
|
||||
__ERROR__ "Please select a chip!"
|
||||
ENDIF
|
||||
|
||||
IF (XTAL <> 0)
|
||||
IF (XC866_CHIP <> 0 || XC864_CHIP <> 0)
|
||||
NDIV EQU NDIV_XC86x
|
||||
ELSEIF (XC88x_CHIP <> 0)
|
||||
NDIV EQU NDIV_XC88x
|
||||
ELSEIF (XC878_CHIP_16FF <> 0 || XC878_CHIP_13FF <> 0)
|
||||
;nothing
|
||||
ELSEIF (XC874_CHIP_16FF <> 0 || XC874_CHIP_13FF <> 0)
|
||||
;nothing
|
||||
ELSEIF (XC82x_CHIP <> 0)
|
||||
;nothing
|
||||
ELSE
|
||||
__WARNING__ "Default NDIV selection is XC866"
|
||||
NDIV EQU NDIV_XC86x ;Default
|
||||
ENDIF
|
||||
ENDIF ;End of XTAL selection
|
||||
|
||||
; Standard SFR Symbols
|
||||
ACC DATA 0E0H
|
||||
B DATA 0F0H
|
||||
SP DATA 81H
|
||||
DPL DATA 82H
|
||||
DPH DATA 83H
|
||||
|
||||
; XC8xx specific SFR Symbols used in STARTUP code
|
||||
IF (XC82x_CHIP == 0)
|
||||
; Take note of different SFR addresses for XC82x. Currently not used.
|
||||
sfr SCU_PAGE = 0xBF
|
||||
sfr PLL_CON = 0xB7
|
||||
sfr PLL_CON1 = 0xEA;//SCU,RMAP=0,Page=1
|
||||
sfr CMCON = 0xBA
|
||||
sfr OSC_CON = 0xB6
|
||||
sfr PASSWD = 0xBB
|
||||
sfr XADDRH = 0xB3
|
||||
sfr MEX3 = 0x96
|
||||
ENDIF
|
||||
|
||||
IF(XC874_CHIP_13FF == 1 || XC874_CHIP_16FF == 1)
|
||||
sfr PORT_PAGE = 0xB2
|
||||
sfr P3_PUDEN = 0xB1
|
||||
sfr P4_PUDEN = 0xC9
|
||||
ENDIF
|
||||
|
||||
NAME ?C_STARTUP
|
||||
|
||||
?C_C51STARTUP SEGMENT CODE
|
||||
?STACK SEGMENT IDATA
|
||||
|
||||
RSEG ?STACK
|
||||
DS 1
|
||||
|
||||
EXTRN CODE (?C_START)
|
||||
PUBLIC ?C_STARTUP
|
||||
|
||||
CSEG AT 0x2000
|
||||
?C_STARTUP: LJMP STARTUP1
|
||||
|
||||
RSEG ?C_C51STARTUP
|
||||
|
||||
STARTUP1:
|
||||
|
||||
IF (XTAL <> 0)
|
||||
; switch to external XTAL
|
||||
IF(XC878_CHIP_16FF <> 0 || XC878_CHIP_13FF <> 0 || XC874_CHIP_16FF <> 0 || XC874_CHIP_13FF <> 0)
|
||||
MOV SCU_PAGE,#1;
|
||||
MOV PASSWD, #11000000B ;Disable Bit-Protection
|
||||
ANL OSC_CON, #~(0x01 << 2) ;OSCSS = 0
|
||||
ORL OSC_CON, #(0x01 << 6) ;Bypass PLL Output ( PLLBYP = 1 )
|
||||
ORL OSC_CON, #(0x01 << 5) ;Set PLL Power Down Mode ( PLLPD = 1)
|
||||
ANL OSC_CON, #~(0x01 << 3) ;XPD = 0, XTAL not powered down
|
||||
|
||||
|
||||
WAIT_XTAL_STABLE: ; delay necssary for external clock to stablise
|
||||
MOV R2,#0x1E ; wait about 1.5 ms ( varies with oscillator freq )
|
||||
LOOP:
|
||||
MOV R3,#0x64
|
||||
DJNZ R3, $
|
||||
DJNZ R2, LOOP
|
||||
OSC_WDT:
|
||||
ORL OSC_CON, #(0x01 << 1) ;Restart external oscillator watchdog
|
||||
MOV R0,#0x41 ;Wait for 65 cycles
|
||||
DJNZ R0, $
|
||||
;user may want to add an error counter for oscillator detection
|
||||
CHECK_EXTOSCR:
|
||||
MOV A, OSC_CON
|
||||
JNB ACC.0, OSC_WDT
|
||||
ORL OSC_CON, #(0x01 << 2) ;Select external oscillator
|
||||
MOV PLL_CON, #NDIV_XC87x_PLL_CON ; NDIV value
|
||||
MOV PLL_CON1, #NDIV_XC87x_PLL_CON1 ; NDIV Value
|
||||
MOV A, #NR_XC87x ; PDIV Value
|
||||
ORL PLL_CON1, A
|
||||
MOV A, #OD_XC87x ; KDIV Value
|
||||
ORL CMCON, A
|
||||
ANL OSC_CON, #~(0x01 << 5) ;Change to PLL Normal Mode ( PLLPD = 0)
|
||||
ORL OSC_CON, #(0x01 << 7) ;Restart the PLL watchdog ( PLLRDRES = 1)
|
||||
|
||||
;user may want to add an error counter for PLL lock detection
|
||||
PLLNOTRUN:
|
||||
MOV A, PLL_CON
|
||||
JNB ACC.1, PLLNOTRUN ;PLL_Run Status
|
||||
|
||||
PLLNOTLOCKED:
|
||||
MOV A, PLL_CON
|
||||
JNB ACC.0, PLLNOTLOCKED ;PLL_Lock Status
|
||||
|
||||
ANL OSC_CON, #~(0x01 << 6) ;Disable bypass PLL output
|
||||
MOV PASSWD, #11000011B ;Enable Bit-Protection
|
||||
MOV SCU_PAGE,#0
|
||||
|
||||
ELSEIF(XC866_CHIP <> 0 || XC864_CHIP <> 0 || XC88x_CHIP <> 0)
|
||||
MOV SCU_PAGE,#1
|
||||
ORL PLL_CON, #0x08 ; VCOBYP = 1
|
||||
ORL PLL_CON, #0x04 ; OSCDISC = 1 _ _ _ NDIV, VCOBYP, OSCDISC, RESLD, LOCK
|
||||
ANL OSC_CON, #0xF7 ; XPD = 0 power xtal
|
||||
ORL OSC_CON, #0x04 ; OSCSS = 1 0, 0, 0, OSCPD, XPD, OSCSS, ORDRES, OSCR
|
||||
;all calculations are based on no wait state
|
||||
MOV R1,#0
|
||||
DelayXTAL0:
|
||||
MOV R0,#10 ; delay necssary for external clock to stablise (amplitude >= 0.4 * VDDC - refer to product data sheet)
|
||||
DelayXTAL: ; delay time should be adjusted according to different external osciallators
|
||||
DJNZ R1,$
|
||||
DJNZ R0,DelayXTAL
|
||||
|
||||
; redetection of osc
|
||||
OSCR_NOTSET:
|
||||
MOV R0, #86
|
||||
ORL OSC_CON, #0x02 ; ORDRES = 1 ;restart oscillator run detection
|
||||
;assume no wait state, K = 2,
|
||||
;Apollo requires to wait for 256 clock cycles -> 2048 vco cycles
|
||||
;Elektra requires to wait for 342 clock cycles -> 2048 vco cycles
|
||||
;djnz = 4 cc
|
||||
DJNZ R0, $
|
||||
MOV A,OSC_CON
|
||||
JNB ACC.0, OSCR_NOTSET
|
||||
|
||||
;reprogram the NDIV factor to required value
|
||||
;ORL PLL_CON, #0x08 ; VCOBYP = 1 to change N-Divider
|
||||
MOV PASSWD, #0x98 ; open access to writing protected bit
|
||||
ANL PLL_CON, #0x0F
|
||||
ORL PLL_CON, #NDIV*16
|
||||
ANL PLL_CON, #0xFB ; OSCDISC = 0, reconnect oscillator to the PLL
|
||||
|
||||
;PLL lock detection
|
||||
ORL PLL_CON, #0x02 ; detect PLL lock
|
||||
MOV R0, #100 ; LOCK flag should be set within 200us, user need to adapt accordingly
|
||||
; assume a 10MHz XTAL for XC866/XC864 device
|
||||
; device is in prescaler mode, k = 2 therefore fsys = 5MHz
|
||||
; ## 1cclk = 1/(5MHz/3) = 600 ns
|
||||
; DJNZ requires 4 x 600ns = 2.4 us therefore 100 DJNZ -> 240us
|
||||
; for XC88x, the factor 3 (##) is changed to 4 then the calculated value is
|
||||
; 320 us based on a 10MHz XTAL
|
||||
WAIT_LOCK:
|
||||
DJNZ R0, $
|
||||
MOV A, PLL_CON
|
||||
JNB ACC.0, OSCR_NOTSET
|
||||
; reconnect to PLL
|
||||
ANL PLL_CON, #0xF7 ; VCOBYP = 0
|
||||
MOV SCU_PAGE,#0
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
IF IDATALEN <> 0
|
||||
MOV R0,#IDATALEN - 1
|
||||
CLR A
|
||||
IDATALOOP: MOV @R0,A
|
||||
DJNZ R0,IDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF (XC878_CHIP_16FF <> 0 || XC874_CHIP_16FF <> 0)
|
||||
MOV MEX3, #0x1F
|
||||
ENDIF
|
||||
|
||||
IF (XC874_CHIP_13FF <> 0 || XC874_CHIP_16FF <> 0)
|
||||
MOV PORT_PAGE, #0x01
|
||||
ORL P3_PUDEN, #0x80
|
||||
ORL P4_PUDEN, #0xF0
|
||||
MOV PORT_PAGE, #0x00
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
IF XDATALEN <> 0
|
||||
MOV DPTR,#XDATASTART
|
||||
MOV R7,#LOW (XDATALEN)
|
||||
IF (LOW (XDATALEN)) <> 0
|
||||
MOV R6,#(HIGH (XDATALEN)) +1
|
||||
ELSE
|
||||
MOV R6,#HIGH (XDATALEN)
|
||||
ENDIF
|
||||
CLR A
|
||||
XDATALOOP: MOVX @DPTR,A
|
||||
INC DPTR
|
||||
DJNZ R7,XDATALOOP
|
||||
DJNZ R6,XDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF PPAGEENABLE <> 0
|
||||
MOV SCU_PAGE,#3
|
||||
MOV XADDRH,#PPAGE
|
||||
MOV SCU_PAGE,#0
|
||||
ENDIF
|
||||
|
||||
IF PDATALEN <> 0
|
||||
MOV R0,#LOW (PDATASTART)
|
||||
MOV R7,#LOW (PDATALEN)
|
||||
CLR A
|
||||
PDATALOOP: MOVX @R0,A
|
||||
INC R0
|
||||
DJNZ R7,PDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF IBPSTACK <> 0
|
||||
EXTRN DATA (?C_IBP)
|
||||
|
||||
MOV ?C_IBP,#LOW IBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
IF XBPSTACK <> 0
|
||||
EXTRN DATA (?C_XBP)
|
||||
|
||||
MOV ?C_XBP,#HIGH XBPSTACKTOP
|
||||
MOV ?C_XBP+1,#LOW XBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
IF PBPSTACK <> 0
|
||||
EXTRN DATA (?C_PBP)
|
||||
MOV ?C_PBP,#LOW PBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
MOV SP,#?STACK-1
|
||||
|
||||
LJMP ?C_START
|
||||
|
||||
; Overwrite ?C?DPSEL address for XC866 Device
|
||||
PUBLIC ?C?DPSEL
|
||||
?C?DPSEL DATA 0A2H ; DPSEL address for Mentor M8051EW
|
||||
|
||||
IF XC864_CHIP <> 0
|
||||
; Optional ROM-table for XC864 LIN-BSL
|
||||
IF LIN_BSL <> 0
|
||||
CSEG AT 0FFCH
|
||||
DB LIN_NAC
|
||||
DB NOT(LIN_NAC)
|
||||
DB LIN_NAD
|
||||
DB NOT(LIN_NAD)
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
END
|
||||
496
SwDriver.C
Normal file
496
SwDriver.C
Normal file
@@ -0,0 +1,496 @@
|
||||
#include "MAIN.h"
|
||||
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//<2F><><EFBFBD>ݽṹ
|
||||
//*****************************************************************************
|
||||
//ÿ<><C3BF>33993<39>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߸<EFBFBD><DFB8>ŵ<EFBFBD><C5B5><EFBFBD>33993<39>ڲ<EFBFBD><DAB2><EFBFBD>λʱ<CEBB><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>״̬<D7B4>ָ<EFBFBD><D6B8><EFBFBD>
|
||||
struct StaMc33993CmdSet
|
||||
{
|
||||
unsigned char CmdSetting ;
|
||||
unsigned char CmdInt_Sp ;
|
||||
unsigned int CmdInt_Sg ;
|
||||
unsigned char CmdMetallic_Sp ;
|
||||
unsigned int CmdMetallic_Sg ;
|
||||
unsigned char CmdWetCurr_Sp ;
|
||||
unsigned int CmdWetCurr_Sg ;
|
||||
unsigned char CmdTriState_Sp ;
|
||||
unsigned int CmdTriState_Sg ;
|
||||
unsigned char CmdAnalog ;
|
||||
};
|
||||
//33993<39>Ŀ<EFBFBD><C4BF><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ֽڷ<D6BD><DAB7>ʣ<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>//XC886<38><36>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
union ByteBitAccess
|
||||
{
|
||||
struct
|
||||
{
|
||||
ubyte SoMc33993Byte1;
|
||||
ubyte SoMc33993Byte0;
|
||||
ubyte SoMc33993Byte3;
|
||||
ubyte SoMc33993Byte2;
|
||||
}ByteData;
|
||||
struct
|
||||
{
|
||||
unsigned int FlgSg0 : 1;
|
||||
unsigned int FlgSg1 : 1;
|
||||
unsigned int FlgSg2 : 1;
|
||||
unsigned int FlgSg3 : 1;
|
||||
unsigned int FlgSg4 : 1;
|
||||
unsigned int FlgSg5 : 1;
|
||||
unsigned int FlgSg6 : 1;
|
||||
unsigned int FlgSg7 : 1;
|
||||
unsigned int FlgSg8 : 1;
|
||||
unsigned int FlgSg9 : 1;
|
||||
unsigned int FlgSg10 : 1;
|
||||
unsigned int FlgSg11 : 1;
|
||||
unsigned int FlgSg12 : 1;
|
||||
unsigned int FlgSg13 : 1;
|
||||
unsigned int FlgSp0 : 1;
|
||||
unsigned int FlgSp1 : 1;
|
||||
unsigned int FlgSp2 : 1;
|
||||
unsigned int FlgSp3 : 1;
|
||||
unsigned int FlgSp4 : 1;
|
||||
unsigned int FlgSp5 : 1;
|
||||
unsigned int FlgSp6 : 1;
|
||||
unsigned int FlgSp7 : 1;
|
||||
unsigned int FlgInt : 1;
|
||||
unsigned int FlgThem : 1;
|
||||
unsigned int : 8;
|
||||
}BitData;
|
||||
};
|
||||
//33993<39>Ŀ<EFBFBD><C4BF><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ֽڷ<D6BD><DAB7>ʣ<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
union WordByteBitAccess
|
||||
{
|
||||
uword StaSg;
|
||||
struct
|
||||
{
|
||||
ubyte StaSgH;
|
||||
ubyte StaSgL;
|
||||
}ByteData;
|
||||
struct
|
||||
{
|
||||
unsigned int FlgSg0_FlgSp0 : 1;
|
||||
unsigned int FlgSg1_FlgSp1 : 1;
|
||||
unsigned int FlgSg2_FlgSp2 : 1;
|
||||
unsigned int FlgSg3_FlgSp3 : 1;
|
||||
unsigned int FlgSg4_FlgSp4 : 1;
|
||||
unsigned int FlgSg5_FlgSp5 : 1;
|
||||
unsigned int FlgSg6_FlgSp6 : 1;
|
||||
unsigned int FlgSg7_FlgSp7 : 1;
|
||||
unsigned int FlgSg8 : 1;
|
||||
unsigned int FlgSg9 : 1;
|
||||
unsigned int FlgSg10 : 1;
|
||||
unsigned int FlgSg11 : 1;
|
||||
unsigned int FlgSg12 : 1;
|
||||
unsigned int FlgSg13 : 1;
|
||||
unsigned int : 1;
|
||||
unsigned int : 1;
|
||||
}BitData;
|
||||
};
|
||||
//*****************************************************************************
|
||||
//ȫ<>ֱ<EFBFBD><D6B1><EFBFBD>
|
||||
//*****************************************************************************
|
||||
static struct StaMc33993CmdSet PntSta[2] = {0};
|
||||
//*****************************************************************************
|
||||
//<2F><><EFBFBD>ļ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><D6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//*****************************************************************************
|
||||
bit Mc33993StaRcvOneBit(ubyte NumMc,ubyte Sp0ToSg13);
|
||||
ubyte Mc33993CmdSendOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13,bit Status);
|
||||
void InitMc33993Sec(void);
|
||||
void ToggleOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13);
|
||||
|
||||
union ByteBitAccess *Mc33993CmdSend(ubyte NumMc,ubyte CmdBit,ubyte SetBitH,ubyte SetBitL);
|
||||
|
||||
|
||||
|
||||
////****************************************************************************
|
||||
//// @Function ubyte Mc33993AnalogChSel(struct StaMc33993CmdSet *PntSta,ubyte NumMc,ubyte Mode,ubyte Channal)
|
||||
////
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Description ģ<><C4A3>ͨ<EFBFBD><CDA8>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ģʽѡ<CABD><D1A1>
|
||||
////
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Returnvalue ͨ<><CDA8><EFBFBD>л<EFBFBD><D0BB>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>1
|
||||
//// Mode,<2C><><EFBFBD>裬2mA<6D><41>16mA
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Parameters None
|
||||
////
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Date 2008-12-2
|
||||
////
|
||||
////****************************************************************************
|
||||
//ubyte Mc33993AnalogChSel(ubyte NumMc,ubyte Mode,ubyte Channal)
|
||||
//{
|
||||
// union WordByteBitAccess RcvSoMc33993;
|
||||
////----------------------------------------------------------------------------
|
||||
// if(NumMc > (NumChipSw-1))NumMc = (NumChipSw-1); //<2F><><EFBFBD><EFBFBD>NumChipSwƬ
|
||||
// RcvSoMc33993.ByteData.StaSgL = 0;
|
||||
// RcvSoMc33993.ByteData.StaSgL = (RcvSoMc33993.ByteData.StaSgL | Channal);
|
||||
// switch(Mode)
|
||||
// {
|
||||
// case DF_AN_HIMP:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 0;//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 0;
|
||||
// break;
|
||||
// case DF_AN_2MA:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 0;
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 1;
|
||||
// break;
|
||||
// case DF_AN_16MA:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 1;
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 0;
|
||||
// break;
|
||||
// default:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 0;
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 0;
|
||||
// }
|
||||
// Mc33993CmdSend(NumMc,DF_CMDANALOG,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//
|
||||
// (*(PntSta+NumMc)).CmdAnalog = RcvSoMc33993.ByteData.StaSgL;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
//
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
|
||||
//*****************************************************************************
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
//*****************************************************************************
|
||||
|
||||
////****************************************************************************
|
||||
//// @Function void SwStaSample(UnSwSample *ptmp,ubyte NumSampleChip)
|
||||
////
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Description <20>ɼ<EFBFBD>33993<39>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>źš<C5BA>
|
||||
////
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Returnvalue None
|
||||
////
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Parameters ptmp<6D><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>ָ<EFBFBD>룬NumSampleChip<69><70>33993оƬ<D0BE><C6AC><EFBFBD><EFBFBD>
|
||||
////
|
||||
////----------------------------------------------------------------------------
|
||||
//// @Date 2008-12-2
|
||||
////
|
||||
////****************************************************************************
|
||||
void SwStaSample(UnSwSample *ptmp)
|
||||
{
|
||||
union ByteBitAccess *pStaSwIn;
|
||||
uword i,k;
|
||||
//----<2D><>ʼ<EFBFBD><CABC>------------------------------------------------------------------------
|
||||
InitMc33993Sec();//һ<><D2BB><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>12V<32><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD>33993<39><33>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF>Իָ<D4BB><D6B8><EFBFBD>
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>IO
|
||||
for(i=0;i<DF_SwInNum;i++)
|
||||
{
|
||||
for(k=0;k<10;k++);
|
||||
// Mc33993CmdSend(i,DF_CMDTRISTATE_SP,0,0); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>24V <09><><EFBFBD><EFBFBD>KGFģ<46>飬ֱ<E9A3AC>Ӳɼ<D3B2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>øı俪<C4B1><E4BFAA>״̬
|
||||
// Mc33993CmdSend(i,DF_CMDTRISTATE_SG,0,0); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>24V <09><><EFBFBD><EFBFBD>KGFģ<46>飬ֱ<E9A3AC>Ӳɼ<D3B2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>øı俪<C4B1><E4BFAA>״̬
|
||||
// Mc33993CmdSendOneBit(DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP0 ,D24V);
|
||||
//<2F><><EFBFBD>زɼ<D8B2>
|
||||
pStaSwIn = Mc33993CmdSend(i,DF_CMDSWSTATUS,0xff,0xff);
|
||||
|
||||
(*ptmp).ArrData.Arr[i][0] = (*pStaSwIn).ByteData.SoMc33993Byte1;
|
||||
(*ptmp).ArrData.Arr[i][1] = (*pStaSwIn).ByteData.SoMc33993Byte0;
|
||||
(*ptmp).ArrData.Arr[i][2] = 0x0;//20130706<30>ģ<DEB8><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><D7B3><EFBFBD>û<EFBFBD>п<EFBFBD><D0BF>ر仯Ҳ<E4BBAF>ᷢ<EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>⡣
|
||||
(*ptmp).ArrData.Arr[i][3] = (*pStaSwIn).ByteData.SoMc33993Byte2;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void LedLight(UnSwOut *tmpUn)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>ӦLED<45><44>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters tmpUn<55><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LED<45><44>״̬<D7B4><CCAC>1<EFBFBD><31>ʾ<EFBFBD><CABE>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
////****************************************************************************
|
||||
void LedLight(UnSwOut *tmpUn)
|
||||
{
|
||||
ubyte i,j;
|
||||
//----------------------------------------------------------------------------
|
||||
// InitMc33993Sec();
|
||||
|
||||
for(i=0;i<DF_SwOutNum;i++)
|
||||
{
|
||||
for(j=0;j<22;j++)
|
||||
{
|
||||
switch(j)
|
||||
{
|
||||
case 0 :if(((((*tmpUn).ArrData.Arr[i][1])>>0 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP0 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP0 ,Gnd);break;
|
||||
case 1 :if(((((*tmpUn).ArrData.Arr[i][1])>>1 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP1 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP1 ,Gnd);break;
|
||||
case 2 :if(((((*tmpUn).ArrData.Arr[i][1])>>2 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP2 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP2 ,Gnd);break;
|
||||
case 3 :if(((((*tmpUn).ArrData.Arr[i][1])>>3 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP3 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP3 ,Gnd);break;
|
||||
case 4 :if(((((*tmpUn).ArrData.Arr[i][1])>>4 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP4 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP4 ,Gnd);break;
|
||||
case 5 :if(((((*tmpUn).ArrData.Arr[i][1])>>5 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP5 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP5 ,Gnd);break;
|
||||
case 6 :if(((((*tmpUn).ArrData.Arr[i][1])>>6 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP6 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP6 ,Gnd);break;
|
||||
case 7 :if(((((*tmpUn).ArrData.Arr[i][1])>>7 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP7 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP7 ,Gnd);break;
|
||||
case 8 :if(((((*tmpUn).ArrData.Arr[i][0])>>0 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG0 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG0 ,Gnd);break;
|
||||
case 9 :if(((((*tmpUn).ArrData.Arr[i][0])>>1 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG1 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG1 ,Gnd);break;
|
||||
case 10:if(((((*tmpUn).ArrData.Arr[i][0])>>2 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG2 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG2 ,Gnd);break;
|
||||
case 11:if(((((*tmpUn).ArrData.Arr[i][0])>>3 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG3 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG3 ,Gnd);break;
|
||||
case 12:if(((((*tmpUn).ArrData.Arr[i][0])>>4 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG4 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG4 ,Gnd);break;
|
||||
case 13:if(((((*tmpUn).ArrData.Arr[i][0])>>5 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG5 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG5 ,Gnd);break;
|
||||
case 14:if(((((*tmpUn).ArrData.Arr[i][0])>>6 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG6 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG6 ,Gnd);break;
|
||||
case 15:if(((((*tmpUn).ArrData.Arr[i][0])>>7 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG7 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG7 ,Gnd);break;
|
||||
case 16:if(((((*tmpUn).ArrData.Arr[i][3])>>0 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG8 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG8 ,Gnd);break;
|
||||
case 17:if(((((*tmpUn).ArrData.Arr[i][3])>>1 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG9 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG9 ,Gnd);break;
|
||||
case 18:if(((((*tmpUn).ArrData.Arr[i][3])>>2 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG10,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG10,Gnd);break;
|
||||
case 19:if(((((*tmpUn).ArrData.Arr[i][3])>>3 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG11,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG11,Gnd);break;
|
||||
case 20:if(((((*tmpUn).ArrData.Arr[i][3])>>4 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG12,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG12,Gnd);break;
|
||||
case 21:if(((((*tmpUn).ArrData.Arr[i][3])>>5 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG13,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG13,Gnd);break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void InitMc33993Sec(struct StaMc33993CmdSet *PntSta)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD>MC33993<39><33><EFBFBD>γ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ÿ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>33993ʱ<33><CAB1><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0>״̬<D7B4><CCAC>ʼ<EFBFBD><CABC>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters MC33993״̬<D7B4>洢<EFBFBD>ṹ<EFBFBD><E1B9B9>ָ<EFBFBD><D6B8>PntSta
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
void InitMc33993Sec(void)
|
||||
{
|
||||
ubyte i;
|
||||
for(i=DF_SwInNum;i<NumChipSw;i++)
|
||||
{
|
||||
Mc33993CmdSend(i,DF_CMDSETTING, 0, (*(PntSta+i)).CmdSetting); //1<><31><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Դ
|
||||
Mc33993CmdSend(i,DF_CMDINT_SP, 0, (*(PntSta+i)).CmdInt_Sp ); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDINT_SG, (ubyte)((((*(PntSta+i)).CmdInt_Sg) >>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdInt_Sg)&0x00ff)); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SP, 0, (*(PntSta+i)).CmdMetallic_Sp); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SG, (ubyte)((((*(PntSta+i)).CmdMetallic_Sg)>>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdMetallic_Sg)&0x00ff)); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDANALOG, 0, (*(PntSta+i)).CmdAnalog); //0<><30><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>κ<EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SP, 0, (*(PntSta+i)).CmdWetCurr_Sp); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SG, (ubyte)((((*(PntSta+i)).CmdWetCurr_Sg) >>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdWetCurr_Sg)&0x00ff)); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SP, 0, (*(PntSta+i)).CmdTriState_Sp); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SG, (ubyte)((((*(PntSta+i)).CmdTriState_Sg)>>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdTriState_Sg)&0x00ff)); //0<><30>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>̬
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void InitMc33993(struct StaMc33993CmdSet *PntSta)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD>MC33993<39>ڵ<EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD>ϵ<EFBFBD>ʱ<EFBFBD><CAB1>ʼ<EFBFBD><CABC>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
void InitSW(void)
|
||||
{
|
||||
ubyte i;
|
||||
for(i=0;i<NumChipSw;i++)
|
||||
{
|
||||
Mc33993CmdSend(i,DF_CMDSETTING,0,0); //0<><30><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDINT_SP,0,0xff); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDINT_SG,0x3f,0xff); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SP,0,0); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SG,0,0); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDANALOG,0,0); //0<><30><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>κ<EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SP,0,0); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SG,0,0); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SP,0xff,0xff); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SG,0xff,0xff); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Function ubyte Mc33993CmdSendOneBit(struct StaMc33993CmdSet *PntSta,ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13,bit Status)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description дMC33993<39><33><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>1
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
ubyte Mc33993CmdSendOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13,bit Status)
|
||||
{
|
||||
union WordByteBitAccess RcvSoMc33993;
|
||||
//----------------------------------------------------------------------------
|
||||
if(NumMc > (NumChipSw-1))NumMc = (NumChipSw-1);
|
||||
switch(CmdBit)
|
||||
{
|
||||
//DF_CMDTRISTATE_SP
|
||||
case DF_CMDTRISTATE_SP:
|
||||
RcvSoMc33993.ByteData.StaSgL = (*(PntSta+NumMc)).CmdTriState_Sp;
|
||||
if(Sp0ToSg13 == DF_FLGSP7)RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP6)RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP5)RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP4)RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP3)RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP2)RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP1)RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP0)RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdTriState_Sp = RcvSoMc33993.ByteData.StaSgL;
|
||||
break;
|
||||
//DF_CMDTRISTATE_SG
|
||||
case DF_CMDTRISTATE_SG:
|
||||
RcvSoMc33993.StaSg = (*(PntSta+NumMc)).CmdTriState_Sg;
|
||||
if(Sp0ToSg13 == DF_FLGSG13) RcvSoMc33993.BitData.FlgSg13 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG12) RcvSoMc33993.BitData.FlgSg12 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG11) RcvSoMc33993.BitData.FlgSg11 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG10) RcvSoMc33993.BitData.FlgSg10 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG9 ) RcvSoMc33993.BitData.FlgSg9 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG8 ) RcvSoMc33993.BitData.FlgSg8 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG7 ) RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG6 ) RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG5 ) RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG4 ) RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG3 ) RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG2 ) RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG1 ) RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG0 ) RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdTriState_Sg = RcvSoMc33993.StaSg;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>20Ƭ<30><C6AC>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
void ChangeCsMc33993(ubyte NumMc,bit HorL)
|
||||
{
|
||||
switch(NumMc)
|
||||
{
|
||||
case Mc33993_0 : CS_SwChip_0 = HorL;break;
|
||||
case Mc33993_1 : CS_SwChip_1 = HorL;break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
//****************************************************************************
|
||||
// @Function ubyte Mc33993DataSendRcv(ubyte Data)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD>CPUƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>,<2C><>ͬCPU<50><55>Ҫ<EFBFBD>ġ<DEB8>
|
||||
// <20>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>XC2765<36><35>SSC<53><43><EFBFBD>ò<EFBFBD>ѯ<EFBFBD><D1AF>ʽ
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue <20><><EFBFBD>ؽ<EFBFBD><D8BD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2011-3-4 10:28:27
|
||||
//
|
||||
//****************************************************************************
|
||||
ubyte Mc33993DataSendRcv(ubyte Data)
|
||||
{
|
||||
uword i;
|
||||
SSC_vSendData(Data);
|
||||
for(i=0;(i<6000)&&(!(IRCON1&0x02));i++);
|
||||
IRCON1 &= 0xFD;
|
||||
for(i=0;(i<6000)&&(!(IRCON1&0x04));i++);
|
||||
IRCON1 &= 0xFB;
|
||||
return((ubyte)(SSC_vGetData()));
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function union ByteBitAccess *Mc33993CmdSend(ubyte NumMc,ubyte CmdBit,ubyte SetBitH,ubyte SetBitL)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD>33993<39>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>״̬
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue <20><><EFBFBD>ؽ<EFBFBD><D8BD>յ<EFBFBD>3<EFBFBD><33><EFBFBD>ֽڵĿ<DAB5><C4BF><EFBFBD>״̬
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2011-3-4 10:36:27
|
||||
//
|
||||
//****************************************************************************
|
||||
union ByteBitAccess *Mc33993CmdSend(ubyte NumMc,ubyte CmdBit,ubyte SetBitH,ubyte SetBitL)
|
||||
{
|
||||
union ByteBitAccess RcvSoMc,*Pnt;
|
||||
union WordByteBitAccess RcvSoMc33993W;
|
||||
// uword i;
|
||||
//----------------------------------------------------------------------------
|
||||
RcvSoMc33993W.ByteData.StaSgH = SetBitH;
|
||||
RcvSoMc33993W.ByteData.StaSgL = SetBitL;
|
||||
switch(CmdBit)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
{
|
||||
case DF_CMDSETTING :(*(PntSta+NumMc)).CmdSetting = RcvSoMc33993W.ByteData.StaSgL;break;
|
||||
case DF_CMDINT_SP :(*(PntSta+NumMc)).CmdInt_Sp = RcvSoMc33993W.ByteData.StaSgL;break;
|
||||
case DF_CMDINT_SG :(*(PntSta+NumMc)).CmdInt_Sg = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDMETALLIC_SP:(*(PntSta+NumMc)).CmdMetallic_Sp = RcvSoMc33993W.ByteData.StaSgL;break;
|
||||
case DF_CMDMETALLIC_SG:(*(PntSta+NumMc)).CmdMetallic_Sg = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDANALOG :(*(PntSta+NumMc)).CmdAnalog = RcvSoMc33993W.ByteData.StaSgL;break;
|
||||
case DF_CMDWETCURR_SP :(*(PntSta+NumMc)).CmdWetCurr_Sp = RcvSoMc33993W.ByteData.StaSgL;break;
|
||||
case DF_CMDWETCURR_SG :(*(PntSta+NumMc)).CmdWetCurr_Sg = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDTRISTATE_SP:(*(PntSta+NumMc)).CmdTriState_Sp = RcvSoMc33993W.ByteData.StaSgL;break;
|
||||
case DF_CMDTRISTATE_SG:(*(PntSta+NumMc)).CmdTriState_Sg = RcvSoMc33993W.StaSg;break;
|
||||
default:;
|
||||
}
|
||||
|
||||
|
||||
if(NumMc > (NumChipSw-1))NumMc = (NumChipSw-1);
|
||||
ChangeCsMc33993(NumMc,0);
|
||||
//----------------------------
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
|
||||
//-------------------------------
|
||||
|
||||
RcvSoMc.ByteData.SoMc33993Byte2 = Mc33993DataSendRcv(CmdBit);
|
||||
|
||||
RcvSoMc.ByteData.SoMc33993Byte1 = Mc33993DataSendRcv(SetBitH);
|
||||
|
||||
RcvSoMc.ByteData.SoMc33993Byte0 = Mc33993DataSendRcv(SetBitL);
|
||||
|
||||
ChangeCsMc33993(NumMc,1);
|
||||
//----------------------------
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
//-------------------------------
|
||||
Pnt = &RcvSoMc;
|
||||
return (Pnt);
|
||||
}
|
||||
893
SwDriver.C.bak
Normal file
893
SwDriver.C.bak
Normal file
@@ -0,0 +1,893 @@
|
||||
#include "MAIN.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//<2F>궨<EFBFBD><EAB6A8>
|
||||
//*****************************************************************************
|
||||
//<2F><><EFBFBD><EFBFBD>20Ƭ<30><C6AC>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
#define Mc33993_0 0
|
||||
#define Mc33993_1 1
|
||||
#define Mc33993_2 2
|
||||
#define Mc33993_3 3
|
||||
#define Mc33993_4 4
|
||||
#define Mc33993_5 5
|
||||
#define Mc33993_6 6
|
||||
#define Mc33993_7 7
|
||||
#define Mc33993_8 8
|
||||
#define Mc33993_9 9
|
||||
#define Mc33993_10 10
|
||||
#define Mc33993_11 11
|
||||
#define Mc33993_12 12
|
||||
#define Mc33993_13 13
|
||||
#define Mc33993_14 14
|
||||
#define Mc33993_15 15
|
||||
#define Mc33993_16 16
|
||||
#define Mc33993_17 17
|
||||
#define Mc33993_18 18
|
||||
#define Mc33993_19 19
|
||||
#define Mc33993_20 20
|
||||
|
||||
|
||||
#define D24V 0
|
||||
#define Gnd 1
|
||||
|
||||
#define TriOff 0
|
||||
#define TriOn 1
|
||||
|
||||
#define WetCur2mA 0
|
||||
#define WetCur16mA 1
|
||||
|
||||
#define SwToGnd 0
|
||||
#define SwToPwr 1
|
||||
|
||||
#define ALLTRI 0xff
|
||||
#define ALLD24V 0x0
|
||||
|
||||
#define DF_CMDSWSTATUS 0x00
|
||||
#define DF_CMDSETTING 0x01
|
||||
#define DF_CMDINT_SP 0x02
|
||||
#define DF_CMDINT_SG 0x03
|
||||
#define DF_CMDMETALLIC_SP 0x04
|
||||
#define DF_CMDMETALLIC_SG 0x05
|
||||
#define DF_CMDANALOG 0x06
|
||||
#define DF_CMDWETCURR_SP 0x07
|
||||
#define DF_CMDWETCURR_SG 0x08
|
||||
#define DF_CMDTRISTATE_SP 0x09
|
||||
#define DF_CMDTRISTATE_SG 0x0A
|
||||
#define DF_CMDCALIBRATION 0x0B
|
||||
#define DF_CMDSLEEP 0x0C
|
||||
#define DF_CMDRESET 0x7F
|
||||
|
||||
|
||||
#define DF_FLGTHEM 10
|
||||
#define DF_FLGINT 11
|
||||
#define DF_FLGSP7 12
|
||||
#define DF_FLGSP6 13
|
||||
#define DF_FLGSP5 14
|
||||
#define DF_FLGSP4 15
|
||||
#define DF_FLGSP3 16
|
||||
#define DF_FLGSP2 17
|
||||
#define DF_FLGSP1 18
|
||||
#define DF_FLGSP0 19
|
||||
#define DF_FLGSG13 20
|
||||
#define DF_FLGSG12 21
|
||||
#define DF_FLGSG11 22
|
||||
#define DF_FLGSG10 23
|
||||
#define DF_FLGSG9 24
|
||||
#define DF_FLGSG8 25
|
||||
#define DF_FLGSG7 26
|
||||
#define DF_FLGSG6 27
|
||||
#define DF_FLGSG5 28
|
||||
#define DF_FLGSG4 29
|
||||
#define DF_FLGSG3 30
|
||||
#define DF_FLGSG2 31
|
||||
#define DF_FLGSG1 32
|
||||
#define DF_FLGSG0 33
|
||||
|
||||
//Analog
|
||||
#define DF_AN_HIMP 1
|
||||
#define DF_AN_2MA 2
|
||||
#define DF_AN_16MA 3
|
||||
|
||||
#define DF_CH_SG0 1
|
||||
#define DF_CH_SG1 2
|
||||
#define DF_CH_SG2 3
|
||||
#define DF_CH_SG3 4
|
||||
#define DF_CH_SG4 5
|
||||
#define DF_CH_SG5 6
|
||||
#define DF_CH_SG6 7
|
||||
#define DF_CH_SG7 8
|
||||
#define DF_CH_SG8 9
|
||||
#define DF_CH_SG9 10
|
||||
#define DF_CH_SG10 11
|
||||
#define DF_CH_SG11 12
|
||||
#define DF_CH_SG12 13
|
||||
#define DF_CH_SG13 14
|
||||
#define DF_CH_SP0 15
|
||||
#define DF_CH_SP1 16
|
||||
#define DF_CH_SP2 17
|
||||
#define DF_CH_SP3 18
|
||||
#define DF_CH_SP4 19
|
||||
#define DF_CH_SP5 20
|
||||
#define DF_CH_SP6 21
|
||||
#define DF_CH_SP7 22
|
||||
|
||||
//*****************************************************************************
|
||||
//<2F><><EFBFBD>ݽṹ
|
||||
//*****************************************************************************
|
||||
//ÿ<><C3BF>33993<39>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߸<EFBFBD><DFB8>ŵ<EFBFBD><C5B5><EFBFBD>33993<39>ڲ<EFBFBD><DAB2><EFBFBD>λʱ<CEBB><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>״̬<D7B4>ָ<EFBFBD><D6B8><EFBFBD>
|
||||
struct StaMc33993CmdSet
|
||||
{
|
||||
unsigned char CmdSetting ;
|
||||
unsigned char CmdInt_Sp ;
|
||||
unsigned int CmdInt_Sg ;
|
||||
unsigned char CmdMetallic_Sp ;
|
||||
unsigned int CmdMetallic_Sg ;
|
||||
unsigned char CmdWetCurr_Sp ;
|
||||
unsigned int CmdWetCurr_Sg ;
|
||||
unsigned char CmdTriState_Sp ;
|
||||
unsigned int CmdTriState_Sg ;
|
||||
unsigned char CmdAnalog ;
|
||||
};
|
||||
//33993<39>Ŀ<EFBFBD><C4BF><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ֽڷ<D6BD><DAB7>ʣ<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>//XC886<38><36>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
union ByteBitAccess
|
||||
{
|
||||
struct
|
||||
{
|
||||
ubyte SoMc33993Byte1;
|
||||
ubyte SoMc33993Byte0;
|
||||
ubyte SoMc33993Byte3;
|
||||
ubyte SoMc33993Byte2;
|
||||
}ByteData;
|
||||
struct
|
||||
{
|
||||
unsigned int FlgSg0 : 1;
|
||||
unsigned int FlgSg1 : 1;
|
||||
unsigned int FlgSg2 : 1;
|
||||
unsigned int FlgSg3 : 1;
|
||||
unsigned int FlgSg4 : 1;
|
||||
unsigned int FlgSg5 : 1;
|
||||
unsigned int FlgSg6 : 1;
|
||||
unsigned int FlgSg7 : 1;
|
||||
unsigned int FlgSg8 : 1;
|
||||
unsigned int FlgSg9 : 1;
|
||||
unsigned int FlgSg10 : 1;
|
||||
unsigned int FlgSg11 : 1;
|
||||
unsigned int FlgSg12 : 1;
|
||||
unsigned int FlgSg13 : 1;
|
||||
unsigned int FlgSp0 : 1;
|
||||
unsigned int FlgSp1 : 1;
|
||||
unsigned int FlgSp2 : 1;
|
||||
unsigned int FlgSp3 : 1;
|
||||
unsigned int FlgSp4 : 1;
|
||||
unsigned int FlgSp5 : 1;
|
||||
unsigned int FlgSp6 : 1;
|
||||
unsigned int FlgSp7 : 1;
|
||||
unsigned int FlgInt : 1;
|
||||
unsigned int FlgThem : 1;
|
||||
unsigned int : 8;
|
||||
}BitData;
|
||||
};
|
||||
//33993<39>Ŀ<EFBFBD><C4BF><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ֽڷ<D6BD><DAB7>ʣ<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
union WordByteBitAccess
|
||||
{
|
||||
uword StaSg;
|
||||
struct
|
||||
{
|
||||
ubyte StaSgH;
|
||||
ubyte StaSgL;
|
||||
}ByteData;
|
||||
struct
|
||||
{
|
||||
unsigned int FlgSg0_FlgSp0 : 1;
|
||||
unsigned int FlgSg1_FlgSp1 : 1;
|
||||
unsigned int FlgSg2_FlgSp2 : 1;
|
||||
unsigned int FlgSg3_FlgSp3 : 1;
|
||||
unsigned int FlgSg4_FlgSp4 : 1;
|
||||
unsigned int FlgSg5_FlgSp5 : 1;
|
||||
unsigned int FlgSg6_FlgSp6 : 1;
|
||||
unsigned int FlgSg7_FlgSp7 : 1;
|
||||
unsigned int FlgSg8 : 1;
|
||||
unsigned int FlgSg9 : 1;
|
||||
unsigned int FlgSg10 : 1;
|
||||
unsigned int FlgSg11 : 1;
|
||||
unsigned int FlgSg12 : 1;
|
||||
unsigned int FlgSg13 : 1;
|
||||
unsigned int : 1;
|
||||
unsigned int : 1;
|
||||
}BitData;
|
||||
};
|
||||
//*****************************************************************************
|
||||
//ȫ<>ֱ<EFBFBD><D6B1><EFBFBD>
|
||||
//*****************************************************************************
|
||||
static struct StaMc33993CmdSet PntSta[2] = {0};
|
||||
//*****************************************************************************
|
||||
//<2F><><EFBFBD>ļ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><D6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//*****************************************************************************
|
||||
bit Mc33993StaRcvOneBit(ubyte NumMc,ubyte Sp0ToSg13);
|
||||
ubyte Mc33993CmdSendOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13,bit Status);
|
||||
void InitMc33993Sec(void);
|
||||
void ToggleOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13);
|
||||
ubyte Mc33993AnalogChSel(ubyte NumMc,ubyte Mode,ubyte Channal);
|
||||
union ByteBitAccess *Mc33993CmdSend(ubyte NumMc,ubyte CmdBit,ubyte SetBitH,ubyte SetBitL);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
|
||||
//*****************************************************************************
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
//*****************************************************************************
|
||||
void Swtest2(void)
|
||||
{
|
||||
ulong i,j;
|
||||
|
||||
UnSwOut_1.BitData.S21 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S22 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S23 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S24 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S25 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S26 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S27 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S28 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S29 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S30 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S31 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S32 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S33 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S34 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S35 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S36 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S37 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S38 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S39 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S40 = 1;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
|
||||
UnSwOut_1.BitData.S21 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S22 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S23 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S24 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S25 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S26 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S27 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S28 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S29 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S30 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S31 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S32 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S33 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S34 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S35 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S36 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S37 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S38 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S39 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
UnSwOut_1.BitData.S40 = 0;LedLight(&UnSwOut_1); for(j=0;j<200;j++){for(i=0;i<133;i++);}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void SwStaSample(UnSwSample *ptmp,ubyte NumSampleChip)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20>ɼ<EFBFBD>33993<39>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>źš<C5BA>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters ptmp<6D><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>ָ<EFBFBD>룬NumSampleChip<69><70>33993оƬ<D0BE><C6AC><EFBFBD><EFBFBD>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
void SwStaSample(UnSwSample *ptmp)
|
||||
{
|
||||
union ByteBitAccess *pStaSwIn;
|
||||
uword i,k;
|
||||
//----<2D><>ʼ<EFBFBD><CABC>------------------------------------------------------------------------
|
||||
InitMc33993Sec();//һ<><D2BB><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>12V<32><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD>33993<39><33>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF>Իָ<D4BB><D6B8><EFBFBD>
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>IO
|
||||
for(i=0;i<DF_SwInNum;i++)
|
||||
{for(k=0;k<10;k++);
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SP,0,0); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>24V
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SG,0,0); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>24V
|
||||
//<2F><><EFBFBD>زɼ<D8B2>
|
||||
pStaSwIn = Mc33993CmdSend(i,DF_CMDSWSTATUS,0xff,0xff);
|
||||
|
||||
(*ptmp).ArrData.Arr[i][1] = (*pStaSwIn).ByteData.SoMc33993Byte1;
|
||||
(*ptmp).ArrData.Arr[i][0] = (*pStaSwIn).ByteData.SoMc33993Byte0;
|
||||
(*ptmp).ArrData.Arr[i][3] = (*pStaSwIn).ByteData.SoMc33993Byte3;
|
||||
(*ptmp).ArrData.Arr[i][2] = (*pStaSwIn).ByteData.SoMc33993Byte2;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void LedLight(UnSwOut *tmpUn)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>ӦLED<45><44>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters tmpUn<55><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LED<45><44>״̬<D7B4><CCAC>1<EFBFBD><31>ʾ<EFBFBD><CABE>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
void LedLight(UnSwOut *tmpUn)
|
||||
{
|
||||
ubyte i,j;
|
||||
//----------------------------------------------------------------------------
|
||||
InitMc33993Sec();
|
||||
|
||||
for(i=0;i<DF_SwOutNum;i++)
|
||||
{
|
||||
for(j=0;j<22;j++)
|
||||
{
|
||||
switch(j)
|
||||
{
|
||||
case 0 :if(((((*tmpUn).ArrData.Arr[i][1])>>0 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP0 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP0 ,Gnd);break;
|
||||
case 1 :if(((((*tmpUn).ArrData.Arr[i][1])>>1 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP1 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP1 ,Gnd);break;
|
||||
case 2 :if(((((*tmpUn).ArrData.Arr[i][1])>>2 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP2 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP2 ,Gnd);break;
|
||||
case 3 :if(((((*tmpUn).ArrData.Arr[i][1])>>3 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP3 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP3 ,Gnd);break;
|
||||
case 4 :if(((((*tmpUn).ArrData.Arr[i][1])>>4 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP4 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP4 ,Gnd);break;
|
||||
case 5 :if(((((*tmpUn).ArrData.Arr[i][1])>>5 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP5 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP5 ,Gnd);break;
|
||||
case 6 :if(((((*tmpUn).ArrData.Arr[i][1])>>6 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP6 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP6 ,Gnd);break;
|
||||
case 7 :if(((((*tmpUn).ArrData.Arr[i][1])>>7 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP7 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SP,DF_FLGSP7 ,Gnd);break;
|
||||
case 8 :if(((((*tmpUn).ArrData.Arr[i][0])>>0 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG0 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG0 ,Gnd);break;
|
||||
case 9 :if(((((*tmpUn).ArrData.Arr[i][0])>>1 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG1 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG1 ,Gnd);break;
|
||||
case 10:if(((((*tmpUn).ArrData.Arr[i][0])>>2 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG2 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG2 ,Gnd);break;
|
||||
case 11:if(((((*tmpUn).ArrData.Arr[i][0])>>3 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG3 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG3 ,Gnd);break;
|
||||
case 12:if(((((*tmpUn).ArrData.Arr[i][0])>>4 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG4 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG4 ,Gnd);break;
|
||||
case 13:if(((((*tmpUn).ArrData.Arr[i][0])>>5 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG5 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG5 ,Gnd);break;
|
||||
case 14:if(((((*tmpUn).ArrData.Arr[i][0])>>6 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG6 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG6 ,Gnd);break;
|
||||
case 15:if(((((*tmpUn).ArrData.Arr[i][0])>>7 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG7 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG7 ,Gnd);break;
|
||||
case 16:if(((((*tmpUn).ArrData.Arr[i][3])>>0 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG8 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG8 ,Gnd);break;
|
||||
case 17:if(((((*tmpUn).ArrData.Arr[i][3])>>1 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG9 ,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG9 ,Gnd);break;
|
||||
case 18:if(((((*tmpUn).ArrData.Arr[i][3])>>2 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG10,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG10,Gnd);break;
|
||||
case 19:if(((((*tmpUn).ArrData.Arr[i][3])>>3 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG11,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG11,Gnd);break;
|
||||
case 20:if(((((*tmpUn).ArrData.Arr[i][3])>>4 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG12,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG12,Gnd);break;
|
||||
case 21:if(((((*tmpUn).ArrData.Arr[i][3])>>5 )&0x01) == 1)Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG13,D24V);else Mc33993CmdSendOneBit(i+DF_SwInNum,DF_CMDTRISTATE_SG,DF_FLGSG13,Gnd);break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void ToggleOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>оƬ<D0BE>ĸ<EFBFBD><C4B8><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ҫ<EFBFBD>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD>λ
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters MC33993״̬<D7B4>洢<EFBFBD>ṹ<EFBFBD><E1B9B9>ָ<EFBFBD><D6B8>PntSta
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
// void ToggleOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13)
|
||||
// {
|
||||
// union WordByteBitAccess RcvSoMc33993;
|
||||
// bit status;
|
||||
|
||||
// if(CmdBit == DF_CMDTRISTATE_SG)
|
||||
// {
|
||||
// RcvSoMc33993.StaSg = (*(PntSta+NumMc)).CmdTriState_Sg;
|
||||
|
||||
// switch(Sp0ToSg13)
|
||||
// {
|
||||
// case DF_FLGSG13: status = RcvSoMc33993.BitData.FlgSg13 ;break;
|
||||
// case DF_FLGSG12: status = RcvSoMc33993.BitData.FlgSg12 ;break;
|
||||
// case DF_FLGSG11: status = RcvSoMc33993.BitData.FlgSg11 ;break;
|
||||
// case DF_FLGSG10: status = RcvSoMc33993.BitData.FlgSg10 ;break;
|
||||
// case DF_FLGSG9 : status = RcvSoMc33993.BitData.FlgSg9 ;break;
|
||||
// case DF_FLGSG8 : status = RcvSoMc33993.BitData.FlgSg8 ;break;
|
||||
// case DF_FLGSG7 : status = RcvSoMc33993.BitData.FlgSg7_FlgSp7;break;
|
||||
// case DF_FLGSG6 : status = RcvSoMc33993.BitData.FlgSg6_FlgSp6;break;
|
||||
// case DF_FLGSG5 : status = RcvSoMc33993.BitData.FlgSg5_FlgSp5;break;
|
||||
// case DF_FLGSG4 : status = RcvSoMc33993.BitData.FlgSg4_FlgSp4;break;
|
||||
// case DF_FLGSG3 : status = RcvSoMc33993.BitData.FlgSg3_FlgSp3;break;
|
||||
// case DF_FLGSG2 : status = RcvSoMc33993.BitData.FlgSg2_FlgSp2;break;
|
||||
// case DF_FLGSG1 : status = RcvSoMc33993.BitData.FlgSg1_FlgSp1;break;
|
||||
// case DF_FLGSG0 : status = RcvSoMc33993.BitData.FlgSg0_FlgSp0;break;
|
||||
// default:;
|
||||
// }
|
||||
// if(status)Mc33993CmdSendOneBit(Mc33993_1,DF_CMDTRISTATE_SG,Sp0ToSg13,D24V);
|
||||
// else Mc33993CmdSendOneBit(Mc33993_1,DF_CMDTRISTATE_SG,Sp0ToSg13,Gnd);
|
||||
// }
|
||||
// else if(CmdBit == DF_CMDTRISTATE_SP)
|
||||
// {
|
||||
// RcvSoMc33993.ByteData.StaSgL = (*(PntSta+NumMc)).CmdTriState_Sp;
|
||||
|
||||
// switch(Sp0ToSg13)
|
||||
// {
|
||||
// case DF_FLGSG7 : status = RcvSoMc33993.BitData.FlgSg7_FlgSp7;break;
|
||||
// case DF_FLGSG6 : status = RcvSoMc33993.BitData.FlgSg6_FlgSp6;break;
|
||||
// case DF_FLGSG5 : status = RcvSoMc33993.BitData.FlgSg5_FlgSp5;break;
|
||||
// case DF_FLGSG4 : status = RcvSoMc33993.BitData.FlgSg4_FlgSp4;break;
|
||||
// case DF_FLGSG3 : status = RcvSoMc33993.BitData.FlgSg3_FlgSp3;break;
|
||||
// case DF_FLGSG2 : status = RcvSoMc33993.BitData.FlgSg2_FlgSp2;break;
|
||||
// case DF_FLGSG1 : status = RcvSoMc33993.BitData.FlgSg1_FlgSp1;break;
|
||||
// case DF_FLGSG0 : status = RcvSoMc33993.BitData.FlgSg0_FlgSp0;break;
|
||||
// default:;
|
||||
// }
|
||||
// if(status)Mc33993CmdSendOneBit(Mc33993_1,DF_CMDTRISTATE_SP,Sp0ToSg13,D24V);
|
||||
// else Mc33993CmdSendOneBit(Mc33993_1,DF_CMDTRISTATE_SP,Sp0ToSg13,Gnd);
|
||||
// }
|
||||
// }
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void InitMc33993Sec(struct StaMc33993CmdSet *PntSta)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD>MC33993<39><33><EFBFBD>γ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ÿ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>33993ʱ<33><CAB1><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0>״̬<D7B4><CCAC>ʼ<EFBFBD><CABC>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters MC33993״̬<D7B4>洢<EFBFBD>ṹ<EFBFBD><E1B9B9>ָ<EFBFBD><D6B8>PntSta
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
void InitMc33993Sec(void)
|
||||
{
|
||||
ubyte i;
|
||||
for(i=0;i<NumChipSw;i++)
|
||||
{
|
||||
Mc33993CmdSend(i,DF_CMDSETTING, 0, (*(PntSta+i)).CmdSetting); //1<><31><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Դ
|
||||
Mc33993CmdSend(i,DF_CMDINT_SP, 0, (*(PntSta+i)).CmdInt_Sp ); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDINT_SG, (ubyte)((((*(PntSta+i)).CmdInt_Sg) >>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdInt_Sg)&0x00ff)); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SP, 0, (*(PntSta+i)).CmdMetallic_Sp); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SG, (ubyte)((((*(PntSta+i)).CmdMetallic_Sg)>>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdMetallic_Sg)&0x00ff)); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDANALOG, 0, (*(PntSta+i)).CmdAnalog); //0<><30><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>κ<EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SP, 0, (*(PntSta+i)).CmdWetCurr_Sp); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SG, (ubyte)((((*(PntSta+i)).CmdWetCurr_Sg) >>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdWetCurr_Sg)&0x00ff)); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SP, 0, (*(PntSta+i)).CmdTriState_Sp); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SG, (ubyte)((((*(PntSta+i)).CmdTriState_Sg)>>8)&0x00ff),(ubyte)(((*(PntSta+i)).CmdTriState_Sg)&0x00ff)); //0<><30>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>̬
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function void InitMc33993(struct StaMc33993CmdSet *PntSta)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD>MC33993<39>ڵ<EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD>ϵ<EFBFBD>ʱ<EFBFBD><CAB1>ʼ<EFBFBD><CABC>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
void InitSW(void)
|
||||
{
|
||||
ubyte i;
|
||||
for(i=0;i<NumChipSw;i++)
|
||||
{
|
||||
Mc33993CmdSend(i,DF_CMDSETTING,0,0); //0<><30><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDINT_SP,0,0xff); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDINT_SG,0x3f,0xff); //1<><31><EFBFBD>ر<EFBFBD><D8B1>ж<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SP,0,0); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDMETALLIC_SG,0,0); //0<><30>2mA
|
||||
Mc33993CmdSend(i,DF_CMDANALOG,0,0); //0<><30><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>κ<EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SP,0,0); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDWETCURR_SG,0,0); //0<><30>ʪ<EFBFBD><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ر<EFBFBD>
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SP,0xff,0xff); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬
|
||||
Mc33993CmdSend(i,DF_CMDTRISTATE_SG,0xff,0xff); //0<><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>̬
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function ubyte Mc33993AnalogChSel(struct StaMc33993CmdSet *PntSta,ubyte NumMc,ubyte Mode,ubyte Channal)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description ģ<><C4A3>ͨ<EFBFBD><CDA8>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ģʽѡ<CABD><D1A1>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue ͨ<><CDA8><EFBFBD>л<EFBFBD><D0BB>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>1
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
// ubyte Mc33993AnalogChSel(ubyte NumMc,ubyte Mode,ubyte Channal)
|
||||
// {
|
||||
// union WordByteBitAccess RcvSoMc33993;
|
||||
// //----------------------------------------------------------------------------
|
||||
// if(NumMc > (NumChipSw-1))NumMc = (NumChipSw-1); //<2F><><EFBFBD><EFBFBD>NumChipSwƬ
|
||||
// RcvSoMc33993.ByteData.StaSgL = 0;
|
||||
// RcvSoMc33993.ByteData.StaSgL = (RcvSoMc33993.ByteData.StaSgL | Channal);
|
||||
// switch(Mode)
|
||||
// {
|
||||
// case DF_AN_HIMP:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 0;//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 0;
|
||||
// break;
|
||||
// case DF_AN_2MA:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 0;
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 1;
|
||||
// break;
|
||||
// case DF_AN_16MA:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 1;
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 0;
|
||||
// break;
|
||||
// default:
|
||||
// RcvSoMc33993.BitData.FlgSg6_FlgSp6 = 0;
|
||||
// RcvSoMc33993.BitData.FlgSg5_FlgSp5 = 0;
|
||||
// }
|
||||
// Mc33993CmdSend(NumMc,DF_CMDANALOG,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
|
||||
// (*(PntSta+NumMc)).CmdAnalog = RcvSoMc33993.ByteData.StaSgL;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
//****************************************************************************
|
||||
// @Function bit Mc33993StaRcvOneBit(ubyte NumMc,ubyte Sp0ToSg13)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>һλ<D2BB>Ŀ<EFBFBD><C4BF><EFBFBD>״̬
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue <20><><EFBFBD><EFBFBD>λ״̬
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
// bit Mc33993StaRcvOneBit(ubyte NumMc,ubyte Sp0ToSg13)
|
||||
// {
|
||||
// union ByteBitAccess *Pnt;
|
||||
// bit BitRcvOneBit;
|
||||
// //-----------------------------------------------------------------------------
|
||||
// if(NumMc > (NumChipSw-1))NumMc = (NumChipSw-1);
|
||||
// Pnt = Mc33993CmdSend(NumMc,DF_CMDSWSTATUS,0xff,0xff);
|
||||
|
||||
// if(Sp0ToSg13 == DF_FLGTHEM)BitRcvOneBit = (*Pnt).BitData.FlgThem;
|
||||
// else if(Sp0ToSg13 == DF_FLGINT )BitRcvOneBit = (*Pnt).BitData.FlgInt;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP7 )BitRcvOneBit = (*Pnt).BitData.FlgSp7;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP6 )BitRcvOneBit = (*Pnt).BitData.FlgSp6;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP5 )BitRcvOneBit = (*Pnt).BitData.FlgSp5;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP4 )BitRcvOneBit = (*Pnt).BitData.FlgSp4;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP3 )BitRcvOneBit = (*Pnt).BitData.FlgSp3;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP2 )BitRcvOneBit = (*Pnt).BitData.FlgSp2;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP1 )BitRcvOneBit = (*Pnt).BitData.FlgSp1;
|
||||
// else if(Sp0ToSg13 == DF_FLGSP0 )BitRcvOneBit = (*Pnt).BitData.FlgSp0;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG13)BitRcvOneBit = (*Pnt).BitData.FlgSg13;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG12)BitRcvOneBit = (*Pnt).BitData.FlgSg12;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG11)BitRcvOneBit = (*Pnt).BitData.FlgSg11;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG10)BitRcvOneBit = (*Pnt).BitData.FlgSg10;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG9 )BitRcvOneBit = (*Pnt).BitData.FlgSg9;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG8 )BitRcvOneBit = (*Pnt).BitData.FlgSg8;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG7 )BitRcvOneBit = (*Pnt).BitData.FlgSg7;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG6 )BitRcvOneBit = (*Pnt).BitData.FlgSg6;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG5 )BitRcvOneBit = (*Pnt).BitData.FlgSg5;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG4 )BitRcvOneBit = (*Pnt).BitData.FlgSg4;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG3 )BitRcvOneBit = (*Pnt).BitData.FlgSg3;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG2 )BitRcvOneBit = (*Pnt).BitData.FlgSg2;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG1 )BitRcvOneBit = (*Pnt).BitData.FlgSg1;
|
||||
// else if(Sp0ToSg13 == DF_FLGSG0 )BitRcvOneBit = (*Pnt).BitData.FlgSg0;
|
||||
// else ;
|
||||
// return BitRcvOneBit;
|
||||
// }
|
||||
|
||||
//****************************************************************************
|
||||
// @Function ubyte Mc33993CmdSendOneBit(struct StaMc33993CmdSet *PntSta,ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13,bit Status)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description дMC33993<39><33><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>1
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2008-12-2
|
||||
//
|
||||
//****************************************************************************
|
||||
ubyte Mc33993CmdSendOneBit(ubyte NumMc,ubyte CmdBit,ubyte Sp0ToSg13,bit Status)
|
||||
{
|
||||
union WordByteBitAccess RcvSoMc33993;
|
||||
//----------------------------------------------------------------------------
|
||||
if(NumMc > (NumChipSw-1))NumMc = (NumChipSw-1);
|
||||
switch(CmdBit)
|
||||
{
|
||||
//DF_CMDSETTING
|
||||
case DF_CMDSETTING:
|
||||
RcvSoMc33993.ByteData.StaSgL = (*(PntSta+NumMc)).CmdSetting; //<2F><>֮ǰ<D6AE><C7B0>״̬<D7B4><CCAC><EFBFBD><EFBFBD>RcvSoMc33993<39><33><EFBFBD>ֽ<EFBFBD>,Ҳ<><D2B2><EFBFBD>Dz<EFBFBD><C7B2>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>״̬
|
||||
if(Sp0ToSg13 == DF_FLGSP7)RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>λ
|
||||
else if(Sp0ToSg13 == DF_FLGSP6)RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP5)RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP4)RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP3)RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP2)RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP1)RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP0)RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdSetting = RcvSoMc33993.ByteData.StaSgL;//<2F><><EFBFBD>º<EFBFBD><C2BA><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
||||
break;
|
||||
//DF_CMDINT_SP
|
||||
case DF_CMDINT_SP:
|
||||
RcvSoMc33993.ByteData.StaSgL = (*(PntSta+NumMc)).CmdInt_Sp;
|
||||
if(Sp0ToSg13 == DF_FLGSP7)RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP6)RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP5)RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP4)RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP3)RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP2)RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP1)RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP0)RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdInt_Sp = RcvSoMc33993.ByteData.StaSgL;
|
||||
break;
|
||||
//DF_CMDMETALLIC_SP
|
||||
case DF_CMDMETALLIC_SP:
|
||||
RcvSoMc33993.ByteData.StaSgL = (*(PntSta+NumMc)).CmdMetallic_Sp;
|
||||
if(Sp0ToSg13 == DF_FLGSP7)RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP6)RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP5)RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP4)RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP3)RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP2)RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP1)RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP0)RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdMetallic_Sp = RcvSoMc33993.ByteData.StaSgL;
|
||||
break;
|
||||
//DF_CMDWETCURR_SP
|
||||
case DF_CMDWETCURR_SP:
|
||||
RcvSoMc33993.ByteData.StaSgL = (*(PntSta+NumMc)).CmdWetCurr_Sp;
|
||||
if(Sp0ToSg13 == DF_FLGSP7)RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP6)RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP5)RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP4)RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP3)RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP2)RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP1)RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP0)RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdWetCurr_Sp = RcvSoMc33993.ByteData.StaSgL;
|
||||
break;
|
||||
//DF_CMDTRISTATE_SP
|
||||
case DF_CMDTRISTATE_SP:
|
||||
RcvSoMc33993.ByteData.StaSgL = (*(PntSta+NumMc)).CmdTriState_Sp;
|
||||
if(Sp0ToSg13 == DF_FLGSP7)RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP6)RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP5)RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP4)RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP3)RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP2)RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP1)RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSP0)RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdTriState_Sp = RcvSoMc33993.ByteData.StaSgL;
|
||||
break;
|
||||
//DF_CMDINT_SG
|
||||
case DF_CMDINT_SG:
|
||||
RcvSoMc33993.StaSg = (*(PntSta+NumMc)).CmdInt_Sg;
|
||||
if(Sp0ToSg13 == DF_FLGSG13) RcvSoMc33993.BitData.FlgSg13 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG12) RcvSoMc33993.BitData.FlgSg12 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG11) RcvSoMc33993.BitData.FlgSg11 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG10) RcvSoMc33993.BitData.FlgSg10 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG9 ) RcvSoMc33993.BitData.FlgSg9 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG8 ) RcvSoMc33993.BitData.FlgSg8 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG7 ) RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG6 ) RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG5 ) RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG4 ) RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG3 ) RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG2 ) RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG1 ) RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG0 ) RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdInt_Sg = RcvSoMc33993.StaSg;
|
||||
break;
|
||||
//DF_CMDMETALLIC_SG
|
||||
case DF_CMDMETALLIC_SG:
|
||||
RcvSoMc33993.StaSg = (*(PntSta+NumMc)).CmdMetallic_Sg;
|
||||
if(Sp0ToSg13 == DF_FLGSG13) RcvSoMc33993.BitData.FlgSg13 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG12) RcvSoMc33993.BitData.FlgSg12 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG11) RcvSoMc33993.BitData.FlgSg11 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG10) RcvSoMc33993.BitData.FlgSg10 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG9 ) RcvSoMc33993.BitData.FlgSg9 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG8 ) RcvSoMc33993.BitData.FlgSg8 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG7 ) RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG6 ) RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG5 ) RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG4 ) RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG3 ) RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG2 ) RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG1 ) RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG0 ) RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdMetallic_Sg = RcvSoMc33993.StaSg;
|
||||
break;
|
||||
//DF_CMDWETCURR_SG
|
||||
case DF_CMDWETCURR_SG:
|
||||
RcvSoMc33993.StaSg = (*(PntSta+NumMc)).CmdWetCurr_Sg;
|
||||
if(Sp0ToSg13 == DF_FLGSG13) RcvSoMc33993.BitData.FlgSg13 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG12) RcvSoMc33993.BitData.FlgSg12 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG11) RcvSoMc33993.BitData.FlgSg11 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG10) RcvSoMc33993.BitData.FlgSg10 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG9 ) RcvSoMc33993.BitData.FlgSg9 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG8 ) RcvSoMc33993.BitData.FlgSg8 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG7 ) RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG6 ) RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG5 ) RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG4 ) RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG3 ) RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG2 ) RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG1 ) RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG0 ) RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdWetCurr_Sg = RcvSoMc33993.StaSg;
|
||||
break;
|
||||
//DF_CMDTRISTATE_SG
|
||||
case DF_CMDTRISTATE_SG:
|
||||
RcvSoMc33993.StaSg = (*(PntSta+NumMc)).CmdTriState_Sg;
|
||||
if(Sp0ToSg13 == DF_FLGSG13) RcvSoMc33993.BitData.FlgSg13 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG12) RcvSoMc33993.BitData.FlgSg12 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG11) RcvSoMc33993.BitData.FlgSg11 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG10) RcvSoMc33993.BitData.FlgSg10 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG9 ) RcvSoMc33993.BitData.FlgSg9 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG8 ) RcvSoMc33993.BitData.FlgSg8 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG7 ) RcvSoMc33993.BitData.FlgSg7_FlgSp7 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG6 ) RcvSoMc33993.BitData.FlgSg6_FlgSp6 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG5 ) RcvSoMc33993.BitData.FlgSg5_FlgSp5 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG4 ) RcvSoMc33993.BitData.FlgSg4_FlgSp4 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG3 ) RcvSoMc33993.BitData.FlgSg3_FlgSp3 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG2 ) RcvSoMc33993.BitData.FlgSg2_FlgSp2 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG1 ) RcvSoMc33993.BitData.FlgSg1_FlgSp1 = Status;
|
||||
else if(Sp0ToSg13 == DF_FLGSG0 ) RcvSoMc33993.BitData.FlgSg0_FlgSp0 = Status;
|
||||
else ;
|
||||
Mc33993CmdSend(NumMc,CmdBit,RcvSoMc33993.ByteData.StaSgH,RcvSoMc33993.ByteData.StaSgL);
|
||||
//(*(PntSta+NumMc)).CmdTriState_Sg = RcvSoMc33993.StaSg;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>20Ƭ<30><C6AC>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
void ChangeCsMc33993(ubyte NumMc,bit HorL)
|
||||
{
|
||||
switch(NumMc)
|
||||
{
|
||||
case Mc33993_0 : CS_SwChip_0 = HorL;break;
|
||||
case Mc33993_1 : CS_SwChip_1 = HorL;break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
//****************************************************************************
|
||||
// @Function ubyte Mc33993DataSendRcv(ubyte Data)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD>CPUƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>,<2C><>ͬCPU<50><55>Ҫ<EFBFBD>ġ<DEB8>
|
||||
// <20>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>XC2765<36><35>SSC<53><43><EFBFBD>ò<EFBFBD>ѯ<EFBFBD><D1AF>ʽ
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue <20><><EFBFBD>ؽ<EFBFBD><D8BD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2011-3-4 10:28:27
|
||||
//
|
||||
//****************************************************************************
|
||||
ubyte Mc33993DataSendRcv(ubyte Data)
|
||||
{
|
||||
uword i;
|
||||
SSC_vSendData(Data);
|
||||
for(i=0;(i<6000)&&(!(IRCON1&0x02));i++);
|
||||
IRCON1 &= 0xFD;
|
||||
for(i=0;(i<6000)&&(!(IRCON1&0x04));i++);
|
||||
IRCON1 &= 0xFB;
|
||||
return((ubyte)(SSC_vGetData()));
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// @Function union ByteBitAccess *Mc33993CmdSend(ubyte NumMc,ubyte CmdBit,ubyte SetBitH,ubyte SetBitL)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Description <20><><EFBFBD><EFBFBD>33993<39>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>״̬
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue <20><><EFBFBD>ؽ<EFBFBD><D8BD>յ<EFBFBD>3<EFBFBD><33><EFBFBD>ֽڵĿ<DAB5><C4BF><EFBFBD>״̬
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2011-3-4 10:36:27
|
||||
//
|
||||
//****************************************************************************
|
||||
union ByteBitAccess *Mc33993CmdSend(ubyte NumMc,ubyte CmdBit,ubyte SetBitH,ubyte SetBitL)
|
||||
{
|
||||
union ByteBitAccess RcvSoMc33993,*Pnt;
|
||||
union WordByteBitAccess RcvSoMc33993W;
|
||||
// uword i;
|
||||
//----------------------------------------------------------------------------
|
||||
RcvSoMc33993W.ByteData.StaSgH = SetBitH;
|
||||
RcvSoMc33993W.ByteData.StaSgL = SetBitL;
|
||||
switch(CmdBit)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
{
|
||||
case DF_CMDSETTING :(*(PntSta+NumMc)).CmdSetting = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDINT_SP :(*(PntSta+NumMc)).CmdInt_Sp = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDINT_SG :(*(PntSta+NumMc)).CmdInt_Sg = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDMETALLIC_SP:(*(PntSta+NumMc)).CmdMetallic_Sp = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDMETALLIC_SG:(*(PntSta+NumMc)).CmdMetallic_Sg = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDANALOG :(*(PntSta+NumMc)).CmdAnalog = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDWETCURR_SP :(*(PntSta+NumMc)).CmdWetCurr_Sp = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDWETCURR_SG :(*(PntSta+NumMc)).CmdWetCurr_Sg = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDTRISTATE_SP:(*(PntSta+NumMc)).CmdTriState_Sp = RcvSoMc33993W.StaSg;break;
|
||||
case DF_CMDTRISTATE_SG:(*(PntSta+NumMc)).CmdTriState_Sg = RcvSoMc33993W.StaSg;break;
|
||||
default:;
|
||||
}
|
||||
|
||||
|
||||
if(NumMc > (NumChipSw-1))NumMc = (NumChipSw-1);
|
||||
ChangeCsMc33993(NumMc,0);
|
||||
//----------------------------
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
|
||||
//-------------------------------
|
||||
|
||||
RcvSoMc33993.ByteData.SoMc33993Byte2 = Mc33993DataSendRcv(CmdBit);
|
||||
|
||||
RcvSoMc33993.ByteData.SoMc33993Byte1 = Mc33993DataSendRcv(SetBitH);
|
||||
|
||||
RcvSoMc33993.ByteData.SoMc33993Byte0 = Mc33993DataSendRcv(SetBitL);
|
||||
|
||||
ChangeCsMc33993(NumMc,1);
|
||||
//----------------------------
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
_nop_();
|
||||
//-------------------------------
|
||||
Pnt = &RcvSoMc33993;
|
||||
return (Pnt);
|
||||
}
|
||||
Reference in New Issue
Block a user