1、BRR--- bit RESET(置0) register //高16位无,低16位置1为0,不能写1
2 、BSRR--- bit SET(设置1或0) register //低16位设置1为0
BSRR:用于低16位的作用是让指定的IO口置1;而高16位的作用是让指定的IO口置0。



static void IoUartTxd(IO_UART_STRUCT *uart) { if(uart->TxdByteCp < uart->TxdByte) { if(uart->TxdBit == 0)//起始位 { uart->TxdCheck = 0; uart->TxdPort->BRR = uart->TxdPin; //置低 } else if(uart->TxdBit <= 8)//数据位 { if(uart->TxdBuff[uart->TxdByteCp]&(1<<(uart->TxdBit-1))) { uart->TxdCheck++; //记录高电平个数 uart->TxdPort->BSRR = uart->TxdPin; //置高 } else { uart->TxdPort->BRR = uart->TxdPin; //置低 } } else if(uart->Parity && uart->TxdBit <= 9) //校验位 { if(uart->Parity == 1){if(uart->TxdCheck%2){uart->TxdPort->BRR = uart->TxdPin;}else{uart->TxdPort->BSRR = uart->TxdPin;}}//奇校验 if(uart->Parity == 2){if(uart->TxdCheck%2){uart->TxdPort->BSRR = uart->TxdPin;}else{uart->TxdPort->BRR = uart->TxdPin;}}//偶校验 } else //停止位 { uart->TxdPort->BSRR = uart->TxdPin; } if((++uart->TxdBit >= 10 && !uart->Parity) || uart->TxdBit >= 11){uart->TxdBit = 0; uart->TxdByteCp++;} } else if(uart->TxdByteCp > 0) { uart->TxdByte = 0; uart->TxdByteCp = 0; uart->Time->CR1 &= 0xfffe; // 失能 EXTI->IMR |= uart->ExitLine; // 开外部中断 } }
讯享网
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/118170.html