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

📄 opp_8980.c

📁 单片机C51 源程序
💻 C
字号:
#include<reg51.h>
#include<absacc.h>
#include<intrins.h>

#define RAM_ADDR 0x0000
#define CONTROL_1 0x8000
#define CONTROL_2 0x9000
#define CONTROL_3 0xa000
#define CONTROL_4 0xb000
#define CONTROL_5 0xc000
#define CONTROL_6 0xd000

#define OFF_HOOK_07 2
#define OFF_HOOK_8F 3
#define RING_07 8
#define RING_8F 9
#define TEST_07 0xa
#define TEST_8F 0xb
#define REVERSAL_07 0xc
#define REVERSAL_8F 0xd

typedef  unsigned char BYTE;
typedef  unsigned int  WORD;

BYTE delay;
BYTE data off_hook[2];


void connect(WORD control, BYTE input_stream, BYTE input_channel, BYTE output_stream, BYTE output_channel);
void enable(WORD control, BYTE stream, BYTE channel);
void disable(WORD control, BYTE stream, BYTE channel);
void ScanStatus(WORD control,BYTE stream);
void ControlSignal(WORD control, BYTE stream, BYTE channel, BYTE message);
void Initial_8980(WORD control);
void message(WORD control, BYTE stream, BYTE channel, BYTE message);


void main(void)
{
    /* WORD i ;
     for(i=0; i<0x7fff; i++)
     {
        XBYTE[RAM_ADDR+i] = 0xff;
        _nop_();
        }           */
 // Initial_8980(CONTROL_5);

//	connect(CONTROL_1,2,5,5,17);		// Connect channel 5 stream 2 to channel 17 stream 5

//	enable(CONTROL_1,5,17);			// Enable channel 17 of stream 5
 	while(1){
//	message(CONTROL_5,5,RING_07,0xaa);		//Place channel 8 of stream 5 in message mode and set message to AAh  */
  //
        ControlSignal(CONTROL_1, 5, RING_07, 0x55);		//Enable channel 8 of stream 5
         //enable(CONTROL_5,5, RING_07);
        }


      //  ControlSignal(CONTROL_5, 5, RING_8F, 0xff); }


    //	disable(CONTROL_1,5,17);				//Disable channel 0 of stream 0  */
   //     ScanStatus(CONTROL_2,2);

}


void Initial_8980(WORD control)
{
   unsigned char k ,i;
   for(k=0;k<8;k++)
     {
      XBYTE[control] = 0xc0 + k ;
      delay = 0 ;
      for(i=0;i<32;i++)
      {
        XBYTE[control+0x20 + i] = 0x00 ;
        delay = 0 ;
      }
     }
}

/**********************************************************************************************
*
* This routine sets up a connection between an input channel and an output
* channel.
*
***********************************************************************************************/

void connect(WORD control, BYTE input_stream, BYTE input_channel, BYTE output_stream, BYTE output_channel)
{
	BYTE temp;
	BYTE connection_pointer;

	XBYTE[control] = 0x18 + output_stream;				// Select CMH of the output stream

	delay = 0;											// Software delay

	temp = XBYTE[control + 0x20 + output_channel];			// Store the contents of CMH
	temp = temp & 0xFB;										//Enable connection mode by setting bit 2 of CMH low
	XBYTE[control + 0x20 + output_channel] = temp;

	delay = 0;

	XBYTE[control] = 0x10 + output_stream;				// Select CML of output stream

	connection_pointer = input_stream;				// Assemble connection pointer
	connection_pointer = connection_pointer << 5;
	connection_pointer = connection_pointer + input_channel;

	XBYTE[control + 0x20 + output_channel] = connection_pointer;		// Set up connection

	delay = 0;
}


/****************************************
*
* This routine enables a channel.
*
****************************************/

void enable(WORD control, BYTE stream, BYTE channel)
{
	BYTE temp;

	XBYTE[control] = 0x18 + stream;				// Go to CMH of stream

	temp = XBYTE[control + 0x20 + channel];			// Store contents of CMH
	temp = temp | 1;								// Enable channel by setting bit 0 of CMH high
	XBYTE[control + 0x20 + channel] = temp;

	delay = 0;
}

/****************************************
*
* This routine disables a channel.
*
****************************************/

void disable(WORD control, BYTE stream, BYTE channel)
{
	BYTE temp;

	XBYTE[control] = 0x18 + stream;				// Go to CMH of stream

	temp = XBYTE[control + 0x20 + channel];			// Store contents of CMH
	temp = temp & 0xFE;								// Disable channel by setting bit 0 of CMH low
	XBYTE[control + 0x20 + channel] = temp;

	delay = 0;
}

/*************************************************************************************************************
*
* This routine places a channel in message mode and places a bit pattern in the channel.
*
*************************************************************************************************************/

void ControlSignal(WORD control,BYTE stream, BYTE channel, BYTE message)
{

	XBYTE[control] = 0xc0 + stream;

        /*XBYTE[control] = 0x10 + stream;*/

	delay = 0;
        _nop_();
        _nop_();
        _nop_();
	XBYTE[control + 0x20 + channel] = message;		// Write message to channel

	delay = 0;
        _nop_();
        _nop_();
        _nop_();


}


void ScanStatus(WORD control,BYTE stream)
{
	BYTE temp;

	XBYTE[control] = 0xc0 + stream;			// 设置该芯片的所有信道为消息模式

	delay = 0;

	temp = XBYTE[control + 0x20 + OFF_HOOK_07];
	delay = 0;
	off_hook[0] = temp;

	temp = XBYTE[control + 0x20 + OFF_HOOK_8F];
	delay = 0;
	off_hook[1] = temp;
}

void message(WORD control, BYTE stream, BYTE channel, BYTE message)
{
	BYTE temp;

	/* Go to CMH of stream */

	XBYTE[control] = 0x18 + stream;

	/* Software delay */

	delay = 0;

	/* Store contents of CMH */

	temp = XBYTE[control + 0x20 + channel];

	/* Place channel in message mode by setting bit 2 high */

	temp = temp | 4;

	XBYTE[control + 0x20 + channel] = temp;

	/* Software delay */

	delay = 0;

	/* Go to CML of stream */

	XBYTE[control] = 0x10 + stream;

	/* Write message to channel */

	XBYTE[control + 0x20 + channel] = message;

	/* Software delay */

	delay = 0;
}




⌨️ 快捷键说明

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