示例#1
0
文件: test.c 项目: hexanome/setre2013
int main(void)
{
	//WDTCTL = WDTPW + WDTHOLD;  	//Stop watchdog
	InitPorts();
	
	while (1)
	{		
		Delayx100us(10);
		if ((B1)==0)
		{
			STATUS_LED_OFF;
		}
		if ((B2)==0)
		{
			Bargraph_Rise();
			STATUS_LED_ON;
		}
		if ((B3)==0)
		{
			Bargraph_Fall();
			STATUS_LED_ON;
		}
		if ((B4)==0)
		{
			Bargraph_Print(7,1);
		}
	}
	return 0;
}
示例#2
0
void Bargraph_Rise_On(void)
{
	unsigned char i=0;
	
	for (i=0; i<8 ;i++)
	{
		Bargraph_Print(i,LED_ON);
		Delayx100us(10);
	}
}
示例#3
0
void Bargraph_Fall(void)
{
	unsigned char i=0;

	for (i=7; i>0 ;i--)
	{
		Bargraph_Print(i,LED_ON);
		Delayx100us(10);
		Bargraph_Print(i,LED_OFF);
	}
}
示例#4
0
void SEND_CMD (unsigned char e)
{
	Delayx100us(10);                //10ms
	temp = e & 0xf0;		//get upper nibble	
	LCD_Data &= 0x0f;
	LCD_Data |= temp;               //send CMD to LCD
	bitclr(P2OUT,RS);     	        //set LCD to CMD mode
	_E();                           //toggle E for LCD
	temp = e & 0x0f;
	temp = temp << 4;               //get down nibble
	LCD_Data &= 0x0f;
	LCD_Data |= temp;
	bitclr(P2OUT,RS);   	        //set LCD to CMD mode
	_E();                           //toggle E for LCD
}
示例#5
0
void SEND_CHAR (unsigned char d)
{
	Delayx100us(5);                 //.5ms	
	temp = d & 0xf0;		//get upper nibble	
	LCD_Data &= 0x0f;
	LCD_Data |= temp;               
	bitset(P2OUT,RS);     	        //set LCD to data mode
	_E();                           //toggle E for LCD
	temp = d & 0x0f;
	temp = temp << 4;               //get down nibble
	LCD_Data &= 0x0f;
	LCD_Data |= temp;
	bitset(P2OUT,RS);   	        //set LCD to data mode
	_E();                           //toggle E for LCD
}
示例#6
0
文件: lcd.c 项目: hexanome/setre2013
static void Send_Char (unsigned char d)
{
        int temp;
	Delayx100us(5);    //.5ms	
	temp = d & 0xf0;   // Get upper nibble	
	LCD_Data &= 0x0f;
	LCD_Data |= temp;
	bitset(P2OUT,RS);  // Set LCD to data mode
	_E();              // Toggle E for LCD
	temp = d & 0x0f;
	temp = temp << 4;  // Get down nibble
	LCD_Data &= 0x0f;
	LCD_Data |= temp;
	bitset(P2OUT,RS);  // Set LCD to data mode
	_E();              // Toggle E for LCD
}
示例#7
0
文件: lcd.c 项目: hexanome/setre2013
static void Send_Cmd (unsigned char e)
{
        int temp;
	Delayx100us(10);   // 10ms
	temp = e & 0xf0;   // Get upper nibble	
	LCD_Data &= 0x0f;
	LCD_Data |= temp;  // Send CMD to LCD
	bitclr(P2OUT,RS);  // Set LCD to CMD mode
	_E();              // Toggle E for LCD
	temp = e & 0x0f;
	temp = temp << 4;  // Get down nibble
	LCD_Data &= 0x0f;
	LCD_Data |= temp;
	bitclr(P2OUT,RS);  // Set LCD to CMD mode
	_E();              // Toggle E for LCD
}
示例#8
0
void InitLCD(void)
{
    bitclr(P2OUT,RS);
    Delayx100us(250);                   //Delay 100ms
    Delayx100us(250);
    Delayx100us(250);
    Delayx100us(250);
    LCD_Data |= BIT4 | BIT5;            //D7-D4 = 0011
    LCD_Data &= ~BIT6 & ~BIT7;
    _E();                               //toggle E for LCD
    Delayx100us(100);                   //10ms
    _E();                               //toggle E for LCD
    Delayx100us(100);                   //10ms
    _E();                               //toggle E for LCD
    Delayx100us(100);                   //10ms
    LCD_Data &= ~BIT4;
    _E();                               //toggle E for LCD
    
    SEND_CMD(DISP_ON);
    SEND_CMD(CLR_DISP);   
}
示例#9
0
文件: display.c 项目: ESS-Group/WSim
void clearDisplay() {
    SEND_CMD(CLR_DISP);
    Delayx100us(10);
}
示例#10
0
文件: lcd.c 项目: hexanome/setre2013
void LCD_Clear(void)
{
    Send_Cmd(CLR_DISP);
    Delayx100us(10);
}
示例#11
0
文件: lcd.c 项目: hexanome/setre2013
void LCD_Init(void)
{
    bitclr(P2OUT,RS);
    Delayx100us(250);             // Delay 100ms
    Delayx100us(250);
    Delayx100us(250);
    Delayx100us(250);
    LCD_Data |= BIT4 | BIT5;      // D7-D4 = 0011
    LCD_Data &= ~BIT6 & ~BIT7;
    _E();                         // Toggle E for LCD
    Delayx100us(100);             // 10ms
    _E();                         // Toggle E for LCD
    Delayx100us(100);             // 10ms
    _E();                         // Toggle E for LCD
    Delayx100us(100);             // 10ms
    LCD_Data &= ~BIT4;
    _E();                         // Toggle E for LCD

    Send_Cmd(DISP_ON);
    Send_Cmd(CLR_DISP);
    Delayx100us(250);
    Delayx100us(250);
    Delayx100us(250);
    Delayx100us(250);
}
示例#12
0
int main(void)
{

	InitOsc();  
	InitPorts();           
	InitUART0();
	InitLCD();

	TCPLowLevelInit();                            //after TCPLowLevelInit() UCLK = ACLK = MCLK/4 = 2 000 000 Hz   

	UART_transmit (CR);
	UART_transmit (LF);  
	for (i=0; i!=26; i++)  UART_transmit (UART_Message[i]); 
	UART_transmit (CR);
	UART_transmit (LF);  

	for (i=0; i!=32; i++)  
	{
		SEND_CHAR(LCD_Message[i]);
		if (i==15) SEND_CMD (DD_RAM_ADDR2);
	}  

	SEND_CMD(DD_RAM_ADDR);    
	RX_flag=0; 
	cntr = 0;   

	HTTPStatus = 0;                                // clear HTTP-server's flag register
	TCPLocalPort = TCP_PORT_HTTP;                  // set port we want to listen to

	while (1)                                      // repeat forever
	{

		//--------------buttons scan---------------------------------------------------------

		if ((B1) == 0)                                 //B1 is pressed
		{
			STATUS_LED_ON;                             //switch on status_led
			SEND_CMD(CLR_DISP);
			SEND_CMD(DD_RAM_ADDR);
			cntr=0;
		}
		else  STATUS_LED_OFF;                           //B1 is released 

		if ((B2) == 0)
		{      
			//        time_out = BUTTON_TIME;
			//        while (time_out != 0) 
			//        if ((B2) == 0) time_out--;
			//        else time_out = BUTTON_TIME;  

			Delayx100us(50);
			RELAY1_ON;                                        
		}
		else
		{      
			//        time_out = BUTTON_TIME;
			//        while (time_out != 0) 
			//        if ((B2) != 0) time_out--;
			//        else time_out = BUTTON_TIME;  

			Delayx100us(50);
			RELAY1_OFF;                                        
		}                   

		if ((B3) == 0)   
		{
			Delayx100us(50);
			RELAY2_ON;                     //B3 is pressed
		}
		else  
		{
			Delayx100us(50);
			RELAY2_OFF;                               //B3 is released
		}  

		while ((B4) == 0)                               //B4 is pressed
		{
			BUZ1_OFF;                                 
			BUZ2_ON;
			Delay(_100us);
			Delay(_100us);                            //buzzer with 5 000 Hz
			BUZ2_OFF;
			BUZ1_ON;
			Delay(_100us);          
		}    
		BUZ1_OFF;                                      //B4 is released
		BUZ2_OFF;      

		//--------UART0 receiv scan------------------------------------------------------------------     

		if (RX_flag == 1)                              //new receiv byte
		{                    
			STATUS_LED_ON;
			if (cntr == 0) 
			{
				SEND_CMD(CLR_DISP);
				SEND_CMD(DD_RAM_ADDR);                //set address for first row
			}
			SEND_CHAR(RXData);          
			if(cntr == 15) SEND_CMD(DD_RAM_ADDR2);    //set address for second row
			if(cntr++ == 31) cntr = 0;           
			RX_flag = 0;            
			STATUS_LED_OFF;
		}
		//---------Digital Inputs scan--------------------------------------------------------------

		if ((DI1) == 0)  for (i=0 ; i != 5; i++)UART_transmit(DI1_Message[i]);  
		if ((DI2) == 0)  for (i=0 ; i != 5; i++)UART_transmit(DI2_Message[i]);  
		if ((DI3) == 0)  for (i=0 ; i != 5; i++)UART_transmit(DI3_Message[i]);  
		if ((DI4) == 0)  for (i=0 ; i != 5; i++)UART_transmit(DI4_Message[i]);  

		//---------DALLAS scan ---------------------------------------------------------------------

		if ((DALLAS) == 0)                      
		{
			cntr=0;
			SEND_CMD(CLR_DISP);
			SEND_CMD(DD_RAM_ADDR);
			for (i=0 ; i!= 14; i++) SEND_CHAR(DALLAS_Message[i]);
		}   

		//---------FREQ scan ----------------------------------------------------------------------      

		if ((FREQ) != 0) 
		{
			cntr=0;
			SEND_CMD(CLR_DISP);
			SEND_CMD(DD_RAM_ADDR);
			for (i=0 ; i!= 16; i++) SEND_CHAR(FREQ_Message[i]);
		}   

		//***********************************************************************************    
		//this is the end of my programm
		//***********************************************************************************

		if (!(SocketStatus & SOCK_ACTIVE)) {
			TCPPassiveOpen();   // listen for incoming TCP-connection
		}
		DoNetworkStuff();                                      // handle network and easyWEB-stack
		// events
		HTTPServer();
	}                               
	return 0;
}