📄 hal_uart.c
字号:
#include "include.h"
//----------------------------------------------------------------------------
// Functions for sending debug strings to a UART. Although the same interfaces
// defined for SPI (USARTn, USCIxn, USI, and bit-bang) could be used for UART,
// only USART0/1 are defined.
//----------------------------------------------------------------------------
void halUARTSetup(void)
{
P2SEL |= 0x010; // P2.4 = USCI_A0 TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x6D; // 1MHz 9600
UCA0BR1 = 0x00; // 1MHz 9600
UCA0MCTL = 4; // Modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
}
void blastString(char string[], unsigned int len)
{
volatile unsigned int i;
for(i=0;i<len;i++)
{
while (!(IFG2 & UCA0TXIFG)); // USART1 TX buffer ready?
UCA0TXBUF = string[i]; // Output character
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -