示例#1
0
int	fputc(int ch, FILE* f)
{ 
	if (f == stdout)
	{
		return UartPutchar(ch, f);
	}
	return 0;
}
示例#2
0
void WiFiSendTest(void) {
	// Uart Write Test
	while (TRUE) {
		// Wait until FIFO empty
		while (!UartTxFifoEmpty());
		// FIFO empty, load 16 characters
		int i;
		for (i = 0; i < 16; i++) UartPutchar(TEST_CHR[i]);
	}
}
示例#3
0
__interrupt void Timer_A(void){

	dht11();

	ch[1]=((int)t)/10+'0';
	ch[2]=((int)t)%10+'0';
	ch[6]=((int)h)/10+'0';
	ch[7]=((int)h)%10+'0';

	for(i=0;i<9;i++){
			 UartPutchar(ch[i]);
		 }
}
示例#4
0
/************************************************************************//**
 * \brief Sends an array of characters using polling method.
 *
 * \param[in] data Data buffer to send.
 * \param[in] dataLen Number of bytes to send.
 *
 * \return The number of bytes sent.
 * \warning This function blocks, eating all the CPU until buffer is sent.
 ****************************************************************************/
uint16_t WiFiPollSend(uint8_t data[], uint16_t dataLen) {
	uint16_t i;
	uint8_t j;

	for (i = 0; i < dataLen;) {
		// Wait until FIFO empty, and send in bursts of up to 16 characters.
		while (!UartTxFifoEmpty());
		for (j = 0; j < 16 && i < dataLen; i++, j++) {
			UartPutchar(data[i]);
		}
	}

	return i;
}
示例#5
0
/*************************************************************************
Function Name :	UartPutchar
Arguments 	  : ch: character be send out
				stream: device file descriptor
Return		  : It returns the character, or EOF in case an error occurred. 
Description	  : Send input char out by UART, wait until TX complete.
				Mainly used for debug print.
**************************************************************************/
int UartPutchar(char ch, FILE* stream)
{
	UartLoopUntilTxIdle();
	UartSwitchToTx();
	if (ch == '\n')
	{
    	UartPutchar('\r', stream);
		UartSwitchToTx();//!
	}

    loop_until_bit_is_set(UCSR0A, UDRE);
	UDR0 = ch;

	UartSwitchToRxAfterTxc();
	return ch;
}
示例#6
0
void WiFiEchoTest(void) {
	uint8_t c = 0;

	while (TRUE) {
		// Wait until FIFO empty and write char
		while (!UartTxFifoEmpty());
		UartPutchar(c);
		// Waitn until char is echoed and compare with sent
		while (!UartRxFifoData());
		if (c != UartGetchar()) {
			// Received character does not match!
			LEDs_TurnOffLEDs(LEDS_LED2);
			LEDs_ToggleLEDs(LEDS_LED1);
		}
		c++;
	}
}
示例#7
0
/*
 * main.c
 */
int main(void) {
    //WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	Clock_Init();
    WDT_Init();
    WX315_Init();
	led_init();
	Init_HC05();
	TimerA_Init();
	Key_Init();
	MQ2_Init();
	Ir_Init();
	Sound_Init();

//	//__bis_SR_register(LPM0_bits + GIE);
	_EINT();

	led0_off();//默认开蓝牙使能
	delay_ms(1000);

	while(1){
		if(temp_tx_flag==1){
			for(i=0;i<8;i++){
				UartPutchar(ch[i]);
			}
			temp_tx_flag=0;
		}
		if(flag_mq2==1){
			flag_mq2=0;
			UartPutchar('V');//Vapour 烟雾传感器 有漏气 向APP发送指令'V'
		}
		if(flag_ir==1){
			flag_ir=0;
			UartPutchar('I');//Ir 红外传感器 有漏气 向APP发送指令'I'
		}
		if(flag_sound==1){
			flag_sound=0;
			UartPutchar('S');//Sound 声音传感器 有大风 向APP发送指令'S'
		}
		switch(uart_temp){

			 		//color
			 		case 'r':
			 			RGB_r();
			 			uart_temp=' ';
			 			break;
			 		case 'o':
			 			RGB_o();
			 			uart_temp=' ';
			 			break;
			 		case 'y':
			 			RGB_y();
			 			uart_temp=' ';
			 			break;
			 		case 'g':
			 			RGB_g();
			 			uart_temp=' ';
			 			break;
			 		case 'b':
			 			RGB_b();
			 			uart_temp=' ';
			 			break;
			 		case 'p':
			 			RGB_p();
			 			uart_temp=' ';
			 			break;
			 		case 'w':
			 			RGB_w();
			 			uart_temp=' ';
			 			break;
			 		case 'd'://关灯 dieout
			 			RGB_d();
			 			uart_temp=' ';
			 			break;
			 			//***********************************************************
			 		case 'm'://开窗 m motor
			 			Window_m();
			 			uart_temp=' ';
			 			break;
			 		case 'n'://关窗
			 			Window_n();
			 			uart_temp=' ';
			 			break;
			 			//***********************************************************
			 		case 'u'://加热 u up
			 			TempNew_u();
			 			uart_temp=' ';
			 			break;
			 		case 'v'://制冷
			 			TempNew_v();
			 			uart_temp=' ';
			 			break;
			 		case 'x'://停止加热
			 			TempNew_x();
			 			uart_temp=' ';
			 			break;
			 		case 'z'://停止制冷
			 			TempNew_z();
			 			uart_temp=' ';
			 			break;
			 			//************************************************************
			 		case 'c'://回家模式
			 			Home_Mode_Backhome();
			 			break;
			 		case 'e'://浪漫模式
			 			Home_Mode_Romatic();
			 			break;
			 		case 'f'://离家模式
			 			Home_Mode_Awayhome();
			 			break;


			 		default:break;
			 		}
	}

	
	//return 0;
}
示例#8
0
void WiFiEchoServerTest(void) {
	while (TRUE) {
		while (!UartRxFifoData());
		UartPutchar(UartGetchar());
	}
}