示例#1
0
t_uint8 _Device_Uart_Module_1_Send_Bytes(unsigned char *sendByte, unsigned int length){
	unsigned int i;

//    if(Usart_Peripheral_Enable_Flag == DeviceOff){
//        return Func_Fail;
//    }

	for(i = 0; i < length; i++){
		SendingWhileTimeOutCount = 0;
        //confirm TX buffer is ready first, USCI_A1 TX buffer ready?
        while (!USCI_A_UART_getInterruptStatus(UART_Module_1_USCI_A_BASEADDRESS, USCI_A_UART_TRANSMIT_INTERRUPT_FLAG)){
            __no_operation();
			if(SendingWhileTimeOutCount >= Uart_Module_1_SendingTimeOutCycle){
				break;
			}
			SendingWhileTimeOutCount++;
        }

        //Transmit data
        USCI_A_UART_transmitData(UART_Module_1_USCI_A_BASEADDRESS, (*(sendByte + i)));
    }
    __no_operation();

    return Func_Success;
}
void PC_USCI_A0_UART_string_transmitData(uint8_t *str){
	do{
        while(!USCI_A_UART_getInterruptStatus(USCI_A0_BASE,
                                              USCI_A_UART_TRANSMIT_INTERRUPT_FLAG))
        {
            ;
        }
		USCI_A_UART_transmitData(USCI_A0_BASE,*str);
	}while(*str++);
}
void PC_USCI_A0_UART_alldata_transmitData(uint8_t *str, int size){

	do{
        while(!USCI_A_UART_getInterruptStatus(USCI_A0_BASE,
                                              USCI_A_UART_TRANSMIT_INTERRUPT_FLAG))
        {
            ;
        }
		USCI_A_UART_transmitData(USCI_A0_BASE,*str);
		str++;
	}while(--size);
}
/*普通船体基础上上加有结束符*/
void USCI_A1_UART_screen_string_transmitData(uint8_t *str){
	int8_t i = 3;

	do{
		while(!USCI_A_UART_getInterruptStatus(USCI_A1_BASE,
				                                              USCI_A_UART_TRANSMIT_INTERRUPT_FLAG))
		{
			;
		}
		USCI_A_UART_transmitData(USCI_A1_BASE,*str);
	}while(*(++str));

	while(i--){
		while(!USCI_A_UART_getInterruptStatus(USCI_A1_BASE,
		                                              USCI_A_UART_TRANSMIT_INTERRUPT_FLAG))
		{
			;
		}
		USCI_A_UART_transmitData(USCI_A1_BASE,0xff);
	};
}