Skip to content
Snippets Groups Projects
Commit ce2e7149 authored by Edward Longman's avatar Edward Longman
Browse files

Copy F5_UART_INTF_USCIA1 section for conversion to FR5

parent aa2eb431
No related branches found
No related tags found
No related merge requests found
......@@ -442,14 +442,149 @@ void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
}
}
#elif UART_SER_INTF == F2_UART_INTF_USCIA0 // Interface to UART
#elif (UART_SER_INTF == FR5x_UART_INTF_USCIA0) // Interface to UART
/**************************************************************************
* @brief Initializes the serial communications peripheral and GPIO ports
*
* @param none
*
* @return none
**************************************************************************/
void hal_uart_init(void)
{
circ_buf_init(&uart_rx_buf, rx_buf, RX_UART_BUFFER_SIZE);
circ_buf_init(&uart_tx_buf, tx_buf, TX_UART_BUFFER_SIZE);
rx_end_of_str = NO_END_OF_LINE_DETECTED;
rx_str_length = 0;
UART_PORT_SEL |= UART_PIN_RXD + UART_PIN_TXD;
UART_PORT_DIR |= UART_PIN_TXD;
UART_PORT_DIR &= ~UART_PIN_RXD;
/* 9600 bits per second on 32768 ACLK */
/*
UCA1CTL1 |= UCSWRST; // Reset State
UCA1CTL1 |= UCSSEL_1; // ACLK
UCA1CTL0 = UCMODE_0;
UCA1CTL0 &= ~UC7BIT; // 8bit char
UCA1BR0 = 3; // 9600 bits per second
UCA1BR1 = 0;
UCA1MCTL = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3
UCA1CTL1 &= ~UCSWRST;
*/
/* 115200 bits per second on 16MHz SMCLK */
UCA1CTL1 |= UCSWRST; // Reset State
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1CTL0 = UCMODE_0;
UCA1CTL0 &= ~UC7BIT; // 8bit char
UCA1BR0 = 138; // 115200 bits per second
UCA1BR1 = 0;
UCA1MCTL = UCBRS2 + UCBRS1 + UCBRS0; // Modulation UCBRSx = 7
UCA1CTL1 &= ~UCSWRST;
UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(GIE); // Enable Interrupts
}
/***************************************************************************
* @brief Disables the serial communications peripheral and clears the GPIO
* settings, reset the interupts.
*
* @param none
*
* @return none
**************************************************************************/
void hal_uart_deinit(void)
{
UCA1IE &= ~UCRXIE;
UCA1IE &= ~UCTXIE;
UCA1CTL1 = UCSWRST; //Reset State
UART_PORT_SEL &= ~( UART_PIN_RXD + UART_PIN_TXD );
UART_PORT_DIR |= UART_PIN_TXD;
UART_PORT_DIR |= UART_PIN_RXD;
UART_PORT_OUT &= ~(UART_PIN_TXD + UART_PIN_RXD);
}
/**************************************************************************
* @brief Initializes the serial communications peripheral and GPIO ports
* @brief void hal_uart_start_tx(void)
*
* @param Start the TX ISR, it will automatically stop when FIFO is empty
*
* @return none
**************************************************************************/
void hal_uart_start_tx(void)
{
if(isr_state == TX_ISR_OFF) {
ENTER_CRITICAL_SECTION(isr_flag);
isr_state = TX_ISR_ON;
UCA1IE |= UCTXIE;
UCA1TXBUF = circ_buf_get_data(&uart_tx_buf);
LEAVE_CRITICAL_SECTION(isr_flag);
}
}
// Echo back RXed character, confirm TX buffer is ready first
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{
char tmp_uart_data;
switch(__even_in_range(UCA1IV,4))
{
case USCI_NONE:
break; // Vector 0 - no interrupt
case USCI_UCRXIFG: // Vector 2 - RXIFG
tmp_uart_data = UCA1RXBUF;
circ_buf_put_data(&uart_rx_buf, tmp_uart_data);
if(uart_state == UART_ECHO_ON) {
uart_put_char(tmp_uart_data);
}
// if its a "return" then activate main-loop
if(tmp_uart_data == 13) {
rx_end_of_str = END_OF_LINE_DETECTED;
rx_str_length = uart_rx_buf.size_of_buffer - circ_buf_remainder(&uart_rx_buf);
__bic_SR_register_on_exit(LPM3_bits);
}
break;
case USCI_UCTXIFG:
// check if there is more data to send
if(circ_buf_remainder(&uart_tx_buf) < uart_tx_buf.size_of_buffer) {
UCA1TXBUF = circ_buf_get_data(&uart_tx_buf);
} else {
isr_state = TX_ISR_OFF;
UCA1IE &= ~UCTXIE; // Disable USCI_A0 TX interrupt
}
break; // Vector 4 - TXIFG
default:
break;
}
}
#elif UART_SER_INTF == F2_UART_INTF_USCIA0 // Interface to UART
/**************************************************************************
* @brief Initializes the serial communications peripheral and GPIO ports
* to communicate with the TUSB3410.
*
*
* @param none
*
*
* @return none
**************************************************************************/
void hal_uart_init(void)
......
......@@ -43,7 +43,7 @@
*
* F2_UART_INTF_USCIA0 LaunchPAD_G2553
* F5_UART_INTF_USCIA0 MSP430_TRXEB development kit
* FR5_UART_INTF_USCIA0 LaunchPAD_FR5969
* FR5_UART_INTF_USCIA0 LaunchPAD_FR5994
*
*******************************************************************************/
#if defined (__MSP430G2553__)
......@@ -58,6 +58,10 @@
#define UART_SER_INTF F5_UART_INTF_USCIA1
#endif
#if defined (__MSP430FR5994__)
#define UART_SER_INTF FR5x_UART_INTF_USCIA0
#endif
#if UART_SER_INTF == F2_UART_INTF_USCIA0 // Interface to UART
#define UART_PORT_OUT P1OUT
......@@ -90,6 +94,8 @@
#define UART_PIN_RXD BIT5
#elif UART_SER_INTF == FR5x_UART_INTF_USCIA0
#define UART_PORT_OUT P2OUT
// The 430FR5xxx series is different as it has multiple function per pin
// 4 Way multiplexing takes place
#define UART_PORT_SEL0 P2SEL0
#define UART_PORT_SEL1 P2SEL1
#define UART_PORT_DIR P2DIR
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment