예제 #1
0
/*******************************************************************************
* 设置节点的上报数据的周期
********************************************************************************/
void setPeriod(uint16 periodSet)
{
    LCD_Char_1_PrintNumber(periodSet);
    if(periodSet < 5)
    switch(periodSet)
    {
        case 0 ://设置0节点上报数据周期
        {
            setGate(&period);
            LCD_Char_1_PrintNumber(period);
            break;
        }
        case 1 :
        {
            setUartSend(11);
            break;
        }
        case 2 :
        {
            setUartSend(12);
            break;
        }
        case 3 ://设置所有节点上报数据周期
        {
            setGate(&period);
            setUartSend(11);
            setUartSend(12);
            break;
        }
        default :
        {
            break;
        }
    }
}
예제 #2
0
/*******************************************************************************
* 获取温度
********************************************************************************/
void getTempture()
{
    uint16 voltageRawCount;//电平值得统计
    ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT); /* 等待温度转换完成 */        
    voltageRawCount = ADC_DelSig_1_GetResult32(); /* 得到转换后的值 GetResult16 最大值是32767  */
    tempture = 1.024*voltageRawCount/65536*1000; /* 根据公式进行转换 */ 
	if (voltageRawCount <= 0)
	{
		errorDisplay();/* 处理错误数据或是零下的温度 */
        UART_PutString("sl0e");
	}
    else if(tempture > highTempture )
    {
        char tem[6]; 
        tem[0] = 's';
        tem[1] = 'h';
        tem[2] = '0';
        tem[3] = 'e';
        tem[4] = '\0';
        UART_PutString(tem);
        LCD_Char_1_PrintNumber(highTempture);
    }
    else if(tempture < lowTempture)//防止温度值溢出
    {
        char tem[6]; 
        tem[0] = 's';
        tem[1] = 'l';
        tem[2] = '0';
        tem[3] = 'e';
        tem[4] = '\0';
        UART_PutString(tem);
        LCD_Char_1_PrintNumber(lowTempture);
    }
	else 
	{	
        char tem[9]; 
        tem[0] = 's';
        tem[1] = 't';
        tem[2] = '0';
        tem[3] = tempture/100 + 48;
        tem[4] = (tempture%100)/10 + 48;
        tem[5] = tempture%10 + 48;
        tem[6] = 'e';
        tem[7] = '\0';
        UART_PutString(tem);
    }
        
        
        //LCD_Char_1_PrintString(" tempture ");
        //LCD_Char_1_PrintNumber(tempture/10); /* 打印小数点前面的数据 */
        //LCD_Char_1_PrintNumber(tempture%10); /* 打印小数点后面的数据 */
        
        //LCD_Char_1_PrintNumber(tempture);
        //updateDisplay(tempture); /* 打印数据到LCD */
}
예제 #3
0
void main(){

    UART_1_Start();
	
	/* choose when we receive interrupts from tx and rx */
	UART_1_SetTxInterruptMode(UART_1_TX_STS_COMPLETE);
	UART_1_SetRxInterruptMode(UART_1_RX_STS_FIFO_NOTEMPTY);
	
	CyGlobalIntEnable;
    
	UART_1_ClearTxBuffer();
	UART_1_ClearRxBuffer();
	
	LCD_Char_1_Start();
	LCD_Char_1_Position(0,0);
	
	/* initialize our source data to index */
	int j;
	for(j = 0; j < DATA_SIZE; ++j){
		sourceData[j] = j;
	}
	
	/* enable our interrupt routines */
	isr_1_StartEx(tx_int);
	isr_2_StartEx(rx_int);	
		
	/* idle loop until we finish our transmission */	
 	while(!rx_done){}

 	int k;
	int errors = 0;
	/* data validation */
	for(k = 0; k < DATA_SIZE; ++k)
		if(sourceData[k] != receiveData[k]) ++errors;
	
	/* print errors to lcd */
	LCD_Char_1_PrintString("errors: ");
	LCD_Char_1_PrintNumber(errors);
	
	LCD_Char_1_Position(1,0);
	LCD_Char_1_PrintString("tx:");

	LCD_Char_1_PrintNumber(tx_cnt);
	LCD_Char_1_PrintString(" rx:");

	LCD_Char_1_PrintNumber(rx_cnt);

	for(;;){
	
    }
}
예제 #4
0
/*******************************************************************************
* 显示数据到显示屏
********************************************************************************/
void updateDisplay (uint16 tempture)
{
    //LCD_Char_1_ClearDisplay();//清除显示    
    LCD_Char_1_PrintString("Tempture:");/* 打印提示信息 */
    
	LCD_Char_1_Position(0,9); /* 把光标移动到1行,10列 */
	LCD_Char_1_PrintNumber(tempture/10); /* 打印小数点前面的数据 */
    LCD_Char_1_PutChar('.');
    LCD_Char_1_PrintNumber(tempture%10); /* 打印小数点后面的数据 */
    
    LCD_Char_1_PrintString(" ");
    //LCD_Char_1_PutChar(LCD_Char_1_CUSTOM_7);
    LCD_Char_1_PrintString("C");
    
}
예제 #5
0
파일: main.c 프로젝트: wuweijia1994/PSOC
/*******************************************************************************
* Function Name: UpdateDisplay
********************************************************************************
*
* Summary:
* Print voltage raw count result to the LCD. Clears some characters if
* necessary.
*
* Parameters:
* voltageRawCount: The voltage raw counts being received from the ADC
*
* Return:
* void
*
*******************************************************************************/
void UpdateDisplay (uint16 voltageRawCount, int row)
{
	/* Move the cursor to Row 0 Column 0 */
	LCD_Char_1_Position(ROW_0,COLUMN_0); 
	/* Print Label for the pot voltage raw count */
	LCD_Char_1_PrintString("TEMP NOW:");
	
	LCD_Char_1_Position(ROW_0,COLUMN_13); 
	LCD_Char_1_PrintString("C");
	
	LCD_Char_1_Position(ROW_1,COLUMN_0);
	LCD_Char_1_PrintString("TEMP SET:    C");

	/* Move the cursor to Row 0, Column 10 */
	LCD_Char_1_Position(row,COLUMN_10);
	/* Print the result */
	LCD_Char_1_PrintNumber(voltageRawCount); 
	
	if (voltageRawCount < 10)
	{
		/* Move the cursor to Row 0, Column 11 */
		LCD_Char_1_Position(row,COLUMN_11);
		LCD_Char_1_PrintString(CLEAR_TENS_HUNDREDS); /* Clear last characters */
	}
	else if (voltageRawCount < 100)
	{
		/* Move the cursor to Row 0, Column 12 */
		LCD_Char_1_Position(row,COLUMN_12);
		LCD_Char_1_PrintString(CLEAR_HUNDREDS); /* Clear last characters */
	}
	else
	{
		/* Continue on */
	}
}
예제 #6
0
/*******************************************************************************
* 设置节点温度上下限
********************************************************************************/
void setNode(uint8 config)
{
    //LCD_Char_1_PrintNumber(config);
    if(config < 19)
    switch(config)
    {
        case 0 ://设置0节点上限
        {
            setGate(&highTempture);
            LCD_Char_1_PrintNumber(highTempture);
            break;
        }
        case 1 :
        {
            setUartSend(1);
            break;
        }
        case 2 :
        {
            setUartSend(2);
            break;
        }
        case 3 ://设置所有节点上限
        {
            setGate(&highTempture);
            setUartSend(1);
            setUartSend(2);
            break;
        }
        case 10 ://设置0节点下限
        {
            setGate(&lowTempture);
            //LCD_Char_1_PrintNumber(lowTempture);
            break;
        }
        case 11 :
        {
            setUartSend(1);
            break;
        }
        case 12 :
        {
            setUartSend(2);
            break;
        }
        case 13 ://设置所有节点下限
        {
            setGate(&lowTempture);
            setUartSend(1);
            setUartSend(2);
            break;
        }
        default :
        {
            break;
        }
    }
}
예제 #7
0
void main(){
	/* initialize UART */
    UART_1_Start();
	
	/* disable interrupts */
	UART_1_DisableRxInt();
	UART_1_DisableTxInt();
	
	UART_1_ClearTxBuffer();
	UART_1_ClearRxBuffer();
	
	LCD_Char_1_Start();
	LCD_Char_1_Position(0,0);
	
	/* initialize or source array */
	int j;
	for(j = 0; j < DATA_SIZE; ++j){
		sourceData[j] = j;
	}
	
	/* loop to transmit all 4096 bytes of our source array */
	int i;
	for(i = 0; i < DATA_SIZE; ++i){
		UART_1_WriteTxData(sourceData[i]);
		
		/* we check the receiver FIFO to see when we get the data */
		while(UART_1_ReadRxStatus() != UART_1_RX_STS_FIFO_NOTEMPTY){}
		
		/* if FIFO is not empty, save the data */
		receiveData[i] = UART_1_ReadRxData();
	}
 
 	int k;
	int errors = 0;
	/* loop through received data to verify it */
	for(k = 0; k < DATA_SIZE; ++k)
		if(sourceData[k] != receiveData[k]) ++errors;
	
	/* print errors */
	LCD_Char_1_PrintString("errors: ");
	LCD_Char_1_PrintNumber(errors);
	for(;;){
	
    }
}
예제 #8
0
/*******************************************************************************
* Function Name: main
********************************************************************************
*
* Summary:
*  Main function performs following functions:
*   1: Initializes the LCD
*   2: Get the temperature of the Die
*   3: Print the Die Temperature value in LCD
*   4: Print the Status value in the LCD
*
* Parameters:
*  None.
*
* Return:
*  None.
*
*******************************************************************************/
int main()
{
    cystatus Status;
    int16 temperature;

    /* Initializing the LCD */
    LCD_Char_1_Start();

    while(1)
    {
        /* Providing some delay */
        CyDelay(50);

        /* Reading the Die Temperature value */
        Status = DieTemp_1_GetTemp(&temperature);
       

        /* Displaying the Die Temperature value on the LCD */
        LCD_Char_1_Position(0u, 0u);
        LCD_Char_1_PrintString("Temp = ");

        if (temperature >= 0)
        {
            LCD_Char_1_PrintString("+");
        }
        else
        {
            /* If the temperature value is negative, display "-" sign and make value positive */
            LCD_Char_1_PrintString("-");
            temperature = (uint16)(~temperature + 1u);
        }
        
        LCD_Char_1_PrintNumber((uint16) (temperature));
        LCD_Char_1_PrintString(" ");
        
        LCD_Char_1_PutChar(LCD_Char_1_CUSTOM_7);
        LCD_Char_1_PrintString("C");

        /* Displaying the status value on the LCD */
        LCD_Char_1_Position(1u, 0u);
        LCD_Char_1_PrintString("Status = ");
        LCD_Char_1_PrintInt8((uint8) Status);
    }
}