Exemplo n.º 1
0
/** 
 * @UART uart wfi deepsleep wakeup demo 
 * @param none
 * @return none
 */
void UartWFIDeepSleepWuDemo(void)
{
    UINT8 i,recbuf[3];
	Memset(recbuf,0x0,3);

	IomUARTRXWuEn();	
    IomUARTRXWuLevHi(); 	 
	ModuleIrqRegister(Uart_Exception, UartIrqService);  
	
	printf("Uart WFI deep sleep enter!!!\r\n");
	SCB->SCR |= 0x04;
	__WFI();
	UartReceive(recbuf, 1);
	printf("\r\n");
	
	if(SCU->WKSR0 &0x40)
    {
		ScuWkSrcUartClr();
		printf("Uart WFI Deep sleep Wakeup!\r\n");
    }
    for(i = 0; i < 1; i++)
    {
         printf("recbuf[%d]=0x%x\r\n",i,recbuf[i]);	  
    }
}
Exemplo n.º 2
0
/** 
 * @UART uart loopback transfer demo 
 * @param none
 * @return none
 */
void UartLBModeDemo(void) 
{
    UINT8 recbuf[0x10];
    UINT8 Writebuf[0x10];
    UINT8 i;

    for(i = 0; i < 0x10; i++)
    {
        recbuf[i] = i;
        Writebuf[i] = 0;
    }
    UartInit();  
    UartLBEn();

    UartSend(recbuf, 10);
    UartReceive(Writebuf, 10);

	UartInit();  
	UartLBDis(); 
    for(i = 0; i < 10; i++)
    {
        if(Writebuf[i] != i)
        {
            printf("UartLoopBack Error!\r\n");
        }
	    else
	    {
		    printf("UartLoopBack Ok!\r\n");
	    }
    }
}
Exemplo n.º 3
0
/** 
 * @UART uart wfe deepsleep wakeup demo 
 * @param none
 * @return none
 */
void UartWFEDeepSleepWuDemo(void)
{
    UINT8 i, recbuf[3];
	Memset(recbuf,0x0,3);

	IomUARTRXWuEn();	   
    IomUARTRXWuLevHi();  
	printf("Uart WFE deep sleep enter!!!\r\n");
	ScuWakeCoreEvent(); 
	__SEV();
    SCB->SCR |= 0x04;        
    __WFE();
    __WFE();
	UartReceive(recbuf, 1);
	printf("\r\n");
	if(SCU->WKSR0 &0x40)
    {
		ScuWkSrcUartClr();
		printf("Uart WFE  Deep sleep Wakeup!\r\n");
    }
    for(i = 0; i < 1; i++)
    {
         printf("recbuf[%d]=0x%x\r\n",i,recbuf[i]);	  
    }
} 
Exemplo n.º 4
0
/** 
 * @UART uart transfer whith pc demo 
 * @param none
 * @return none
 */
void UartSendReviceDemo(void)
{
     UINT8 buf[0x10];
     UartInit();      
	 printf("Uart test start\r\nRreceive data:\r\n");
     UartReceive(buf, 10);
	 printf("\r\nSend data:\r\n");
     UartSend(buf, 10);
	 printf("\r\n");

}
Exemplo n.º 5
0
/** 
 * @UART uart sleep wakeup demo 
 * @param none
 * @return none
 */ 
void UartSleepWuDemo(void)
{
	UINT8 recbuf[3];
	Memset(recbuf,0x0,3);
	ModuleIrqRegister(Uart_Exception, UartIrqService);
	printf("Uart WFI sleep enetr!\r\n");
	//sleep
	SCB->SCR &= ~0x04;
	//sleep mode enter
	__WFI();	                               
	UartReceive(recbuf, 1);
	printf("\r\n");
	printf("Uart WFI  sleep Wakeup!\r\n");
}
Exemplo n.º 6
0
/*----------------------------------------------------------------------*/
void UartStore(void) {
    received = UartReceive();
    if(received == '<') {
        received = UartReceive();
        if(received == '<') {
            receiving_ok = 1;
            c_path = 0;
        }
    }else if(received == 0x04) {  /* EOT received; transmission ended by
                                   * host, reset counter for storing */
        c_path = 0;
        path_name = 0;
        receiving_ok = 0;
    }else if(received == 0x17){ // ETB received, further characters are name
        NAME:
        c_name = 0;
        path_name = 1;
    }else if(received == '>') { /* entered if first ending of cc '>'
                                 * transmission is received */
        unsigned char signreceivecounter = 0;
        while(RC1IF == 0 && signreceivecounter < 20) {
            signreceivecounter ++;
            __delay_us(10);
        }
        received = UartReceive();   // reading next byte
        if(received == '>'){    /* entered if second ending of cc '>'
                                 * transmission is received */
            numb_cc = c_path;
            receiving_ok = 0;
        }else {     // ending was not complete, send error
            UartSendError();
        }
    }else if(received == 0x1D) {    // Tableindicator received
        numb_cc_table = c_path;
    }else if(receiving_ok == 1){    // receiving cc/path or name
        if(path_name == 0) {    // entered for storing path
            a_path[c_path].lower_cc = received;
            unsigned char pathreceivecounter = 0;
            while(RC1IF == 0 && pathreceivecounter < 20) {
                pathreceivecounter ++;
                __delay_us(10);
            }
            received = UartReceive();
            a_path[c_path].higher_cc = received;
            c_path++;
            if(c_path > 20) {
                UartSendOverflow();
                c_path = 0;
            }
        }else if(path_name == 1) {  // entered for storing name
            a_name[c_name] = received;
            c_name++;
            if(c_name > 32) {
                UartSendOverflow();
                c_name = 0;
            }
        }
    }else {     // entered if receiving is not allowed -> no startkondition
        UartDump();
    }
}
Exemplo n.º 7
0
void UartDump(void) {
    unsigned char dumpdata;
    dumpdata = UartReceive();
}