CC2640R2f模拟uart

想要使用2640模拟串口,发送信息,程序如下:

//定义句柄
static PIN_Handle Uart_PinsHandle = NULL;
static PIN_State My_state;

//引脚的配置数组
PIN_Config MyBoardPinsCfg[] ={
    CC2640R2_LAUNCHXL_UART_TX  | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE};
void My_Uart_Send(char uContent)
{
    int i;
    //起始信号,拉低引脚
    PIN_setOutputValue( Uart_PinsHandle, CC2640R2_LAUNCHXL_UART_TX, false );
    usleep(104);
    //数据发送
    for(i=0;i<8;i++)
    {
        PIN_setOutputValue( Uart_PinsHandle, CC2640R2_LAUNCHXL_UART_TX, (uContent & 0x01));
        uContent = uContent >> 1;
        usleep(104);
    }
    //结束信号,拉高引脚
    PIN_setOutputValue( Uart_PinsHandle, CC2640R2_LAUNCHXL_UART_TX, true );

    //多写几个sleep,测试发现sleep少的情况下,很容易出现乱码
    usleep(104);usleep(104);usleep(104);usleep(104);usleep(104);
}

//发送字符串

void Send_Word_Func(char *s){
    while(*s)
        My_Uart_Send(*s++);
}

void main ()
{
    char buf[200] = "|8_8|--------------------------*1_1*";
    Uart_PinsHandle = PIN_open(&My_state, MyBoardPinsCfg);
    PIN_setOutputValue( Uart_PinsHandle, CC2640R2_LAUNCHXL_UART_TX, true );
    while(1){
        sleep(1);
        Send_Word_Func(buf);


    }

}

CC2640R2f模拟uart