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

📄 ios.c

📁 ST7540 Demo 下位机C程序
💻 C
字号:
/**********************************************************************************
*                 ST 7538 DEMOBOARD SOFTWARE 	  IOs.c                             *
*                                                                                 *
*                 Input/Output  V1.1                                              *
***********************************************************************************/
#include "global.h"

// In this code there are the functions to initialize Microcontroller Ports, 
// it manage the LED, the PC interface interrupt, the WD funstion of ST7538 
// and the "power_good" function of the ST7538.


// Function to set the port configuration.

#pragma CODE_SEG APPLI_CODE

void	IOsInit(void)
{
//LED_TX
  LED_TX_DIR|=LED_TX_MASK;		//LED_TX in output push pull. 
	LED_TX_PORT|=LED_TX_MASK;		//Default is LED off
//	LED_TX_OP_R|=LED_TX_MASK;
//LED_RX
  LED_RX_DIR|=LED_RX_MASK;		//LED_RX in output push pull. 
	LED_RX_PORT|=LED_RX_MASK;		//Default is LED off
//LED_CDPD
  LED_CDPD_DIR|=LED_CDPD_MASK;	//LED_CDPD in output push pull. 
	LED_CDPD_PORT|=LED_CDPD_MASK;	//Default is LED off
//LED_TOUT
 	LED_TOUT_DIR|=LED_TOUT_MASK;	//LED_TOUT in output push pull. 
	LED_TOUT_PORT|=LED_TOUT_MASK;	//Default is LED off
// ST7538 Watchdog reset signal output push pul
 	WDOG_DIR|=WDOG_MASK;			//output push pull. 
	WDOG_PORT|=WDOG_MASK;			//Default is High
// Power Good signal
	POWERGOOD_DIR   &= ~POWERGOOD_MASK;	// in input floating
// Dual channel control Init
	CH2_DIR |= (CH2_MASK|NCH2_MASK);
	CH2_OPT |= (CH2_MASK|NCH2_MASK);
	CH2_DESELECT();
	SET_PLM_ID_PORT();
}
       

//Function which updates LEDs status
void	LedsUpdate(void)
{

if(Modem_Id==ST7540) {
		if(SPI_OnTx()&&(BANDUSED_PORT&BANDUSED_MASK))
			 SET_LED_TOUT(1);
		else
		   SET_LED_TOUT(0);
	  } 
	else 
	if(!ST7538_TIMEOUT)	// Updating of the TIMEOUT LED
		SET_LED_TOUT(0);
	else								
		SET_LED_TOUT(1);
	
	if(!ST7538_CD)		// Updating of the CARRIER LED
		SET_LED_CDPD(0);
	else                                
		SET_LED_CDPD(1);

	if( (SPI_OnRx()==0)  )		// Updating of the RX LED
		SET_LED_RX(0);
	else                         
		SET_LED_RX(1);

	if( (SPI_OnTx()==0)  )		// Updating of the TX LED
		SET_LED_TX(0);
	else                                    
		SET_LED_TX(1);
}

//Function which refresh the watchdog signal using a square wave signal
// with a period of about 2 time XmS
void	WatchDogRefresh()
{
	if (_5mS_Delay_Elapsed()) {
		WDGCR = 0xFF;
		(WDOG_PORT^=WDOG_MASK);
		refresh_5mS_Delay();
	}
}

⌨️ 快捷键说明

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