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

📄 int32.c

📁 RTX是当前非常流行的RTX实时操作系统
💻 C
字号:
/***********************************************************************

FILE
    int32.c -  functions for INT32 board

ROUTINES

REMARKS
    Clock rate into Zilog 8536 chip is 2.5 MHz


LAST UPDATE
    Dan Block  2/5/98


***********************************************************************/

/***********************************************************************
			  I M P O R T S

    This section contains ALL the declarations from other modules
    required in this program.  Such "imports" are gathered here
    instead of scattered all over this file to make them easier
    to find and reduces the chance of introducing bugs through
    inconsistent multiple declarations of the same item.

***********************************************************************/
#include "windows.h"
#include "rtapi.h"
#include "stdio.h"

#include "int32.h"      /* address and other declarations */


/***********************************************************************
	     F O R W A R D    D E C L A R A T I O N S

    This section only declares functions that are local to this
    module; functions visible outside this module are already
    declared in the header file timerbd.h #include'd above.

***********************************************************************/


/***********************************************************************
	   P R I V A T E    D A T A    V A R I A B L E S

    These variables and declarations are visible to all routines in
    this file.  Variables declared as "static" are not visible
    outside of this file.  In computer jargon, their "name space" is
    restricted to this file.  This enhances data security by preventing
    routines outside this file from inadvertently modidifying these
    values though accidental use of an external variable with the
    same name.

***********************************************************************/


/***********************************************************************
		  E N T R Y    R O U T I N E S

    Entry routines are those that can be called directly by functions
    outside this module or file.

***********************************************************************/

/*----------------------------------------------------------------------
PROCEDURE
    Int32_Initialize

SYNOPSIS
    

PARAMETERS
      
RETURNS
     
REMARKS

LAST UPDATE
    Dan Block 11/19/98
----------------------------------------------------------------------*/
void Int32_Initialize(void) {

	RtEnablePortIo(INT32_BASE,0x8);

}
/*----------------------------------------------------------------------
PROCEDURE
    INT32_READ_REGISTER

SYNOPSIS
    int Int32_Read_Register(int chip, int reg)

PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
      reg - register address value.  Address values are given in the 8536 documentation
RETURNS
      Normal operation: The value in the given register
      On error:  -1
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
int Int32_Read_Register(int chip, int reg) {

    int tmp;

    if (chip == 1) {
      RtWritePortUchar(INT_STA_CNTR_1, (UCHAR) reg);
      tmp = RtReadPortUchar(INT_STA_CNTR_1);
    } else if (chip == 2) {
      RtWritePortUchar(INT_STA_CNTR_2, (UCHAR) reg);
      tmp = RtReadPortUchar(INT_STA_CNTR_2);
    } else {
      tmp = -1;
    } /* endif */

    return(tmp);
}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_WRITE_REGISTER

SYNOPSIS
    void Int32_Write_Register(int chip, int reg,int value)

PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
      reg - register address value.  Address values are given in the 8536 documentation
      value  -  value to write to the register
RETURNS
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
void Int32_Write_Register(int chip, int reg, int value) {

    if (chip == 1) {
      RtWritePortUchar(INT_STA_CNTR_1, (UCHAR) reg);
      RtWritePortUchar(INT_STA_CNTR_1, (UCHAR) value);
    } else if (chip == 2) {
      RtWritePortUchar(INT_STA_CNTR_2, (UCHAR) reg);
      RtWritePortUchar(INT_STA_CNTR_2, (UCHAR) value);
    } /* endif */

}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_RESET

SYNOPSIS
    void Int32_Reset(int chip)

PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
RETURNS
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
void Int32_Reset(int chip) {

    int ii;

    if (chip == 1) {
      ii = RtReadPortUchar(INT_STA_CNTR_1);                 // In RESET or state 0
      RtWritePortUchar(INT_STA_CNTR_1,CLR_INT_RESET);
      ii = RtReadPortUchar(INT_STA_CNTR_1);                 // In state 0
      RtWritePortUchar(INT_STA_CNTR_1,MASTER_INT_CNTR);
      RtWritePortUchar(INT_STA_CNTR_1,INT_RESET);           // Trigger RESET
      RtWritePortUchar(INT_STA_CNTR_1,CLR_INT_RESET);       // Clear RESET -> state 0

      /* Now perform the rest of the setup for chip 1 */
      /* this sets up chip 1 for vectored interrupts */
      RtWritePortUchar(INT_STA_CNTR_1,MASTER_INT_CNTR);
      RtWritePortUchar(INT_STA_CNTR_1,INT_CONTROL_SETUP);

      RtWritePortUchar(INT_STA_CNTR_1,PORT_A_INT_VECT);
      RtWritePortUchar(INT_STA_CNTR_1,PORTA_VECTOR);

      RtWritePortUchar(INT_STA_CNTR_1,PORT_B_INT_VECT);
      RtWritePortUchar(INT_STA_CNTR_1,PORTB_VECTOR);

      RtWritePortUchar(INT_STA_CNTR_1,CNT_INT_VECT);
      RtWritePortUchar(INT_STA_CNTR_1,CNT_VECTOR);

    } else if (chip == 2) {
      ii = RtReadPortUchar(INT_STA_CNTR_2);                 // In RESET or state 0
      RtWritePortUchar(INT_STA_CNTR_2,CLR_INT_RESET);
      ii = RtReadPortUchar(INT_STA_CNTR_2);                 // In state 0
      RtWritePortUchar(INT_STA_CNTR_2,MASTER_INT_CNTR);
      RtWritePortUchar(INT_STA_CNTR_2,INT_RESET);           // Trigger RESET
      RtWritePortUchar(INT_STA_CNTR_2,CLR_INT_RESET);       // Clear RESET -> state 0
    } /* endif */

//    /* Now perform the rest of the setup for the chip */
//    RtWritePortUchar(INT_STA_CNTR_1,MASTER_INT_CNTR);
//    RtWritePortUchar(INT_STA_CNTR_1,INT_CONTROL_SETUP);

//    RtWritePortUchar(INT_STA_CNTR_1,PORT_A_INT_VECT);
//    RtWritePortUchar(INT_STA_CNTR_1,PORTA_VECTOR);

//    RtWritePortUchar(INT_STA_CNTR_1,PORT_B_INT_VECT);
//    RtWritePortUchar(INT_STA_CNTR_1,PORTB_VECTOR);

//    RtWritePortUchar(INT_STA_CNTR_1,CNT_INT_VECT);
//    RtWritePortUchar(INT_STA_CNTR_1,CNT_VECTOR);

}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_READ_PORTA


SYNOPSIS
    int Int32_Read_PortA(int chip)


PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
RETURNS
      normal: value read on Port A
      error: -1
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
int Int32_Read_PortA(int chip) {

    int tmp;

    if (chip == 1) {
      tmp = RtReadPortUchar(INT_PORTA_1);
    } else if (chip == 2) {
      tmp = RtReadPortUchar(INT_PORTA_2);
    } else {
      return(-1);
    } /* endif */

}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_READ_PORTB


SYNOPSIS
    int Int32_Read_PortB(int chip)


PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
RETURNS
      normal: value read on Port B
      error: -1
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
int Int32_Read_PortB(int chip) {

    int tmp;

    if (chip == 1) {
      tmp = RtReadPortUchar(INT_PORTB_1);
    } else if (chip == 2) {
      tmp = RtReadPortUchar(INT_PORTB_2);
    } else {
      return(-1);
    } /* endif */

}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_READ_PORTC


SYNOPSIS
    int Int32_Read_PortC(int chip)


PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
RETURNS
      normal: value read on Port C
      error: -1
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
int Int32_Read_PortC(int chip) {

    int tmp;

    if (chip == 1) {
      tmp = RtReadPortUchar(INT_PORTC_1);
    } else if (chip == 2) {
      tmp = RtReadPortUchar(INT_PORTC_2);
    } else {
      return(-1);
    } /* endif */

}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_WRITE_PORTA


SYNOPSIS
    void Int32_Write_PortA(int chip,int value)


PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
      value - value to write to the Port
RETURNS
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
void Int32_Write_PortA(int chip,int value) {

    if (chip == 1) {
      RtWritePortUchar(INT_PORTA_1,(UCHAR) value);
    } else if (chip == 2) {
      RtWritePortUchar(INT_PORTA_2,(UCHAR) value);
    } /* endif */

}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_WRITE_PORTB


SYNOPSIS
    void Int32_Write_PortB(int chip,int value)


PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
      value - value to write to the Port
RETURNS
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
void Int32_Write_PortB(int chip,int value) {

    if (chip == 1) {
      RtWritePortUchar(INT_PORTB_1,(UCHAR) value);
    } else if (chip == 2) {
      RtWritePortUchar(INT_PORTB_2,(UCHAR) value);
    } /* endif */

}

/*----------------------------------------------------------------------
PROCEDURE
    INT32_WRITE_PORTC


SYNOPSIS
    void Int32_Write_PortC(int chip,int value)


PARAMETERS
      chip - either 1 or 2 ... there are two Zilog 8536 chips on the INT32 board
      value - value to write to the Port
RETURNS
REMARKS

LAST UPDATE
    Dan Block 2/5/98
----------------------------------------------------------------------*/
void Int32_Write_PortC(int chip,int value) {

    if (chip == 1) {
      RtWritePortUchar(INT_PORTC_1,(UCHAR) value);
    } else if (chip == 2) {
      RtWritePortUchar(INT_PORTC_2,(UCHAR) value);
    } /* endif */

}

⌨️ 快捷键说明

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