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

Modify F5 to port it to FR5x

parent 7bf44ad8
No related branches found
No related tags found
No related merge requests found
......@@ -181,10 +181,10 @@ void uart_drv_toggle_echo(void) {
#if (UART_SER_INTF == F5_UART_INTF_USCIA0)
/**************************************************************************
* @brief Initializes the serial communications peripheral and GPIO ports
*
* @brief Initializes the serial communications peripheral and GPIO ports
*
* @param none
*
*
* @return none
**************************************************************************/
void hal_uart_init(void)
......@@ -235,9 +235,9 @@ void hal_uart_init(void)
/***************************************************************************
* @brief Disables the serial communications peripheral and clears the GPIO
* settings, reset the interupts.
*
*
* @param none
*
*
* @return none
**************************************************************************/
void hal_uart_deinit(void)
......@@ -253,9 +253,9 @@ void hal_uart_deinit(void)
/**************************************************************************
* @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)
......@@ -460,7 +460,13 @@ void hal_uart_init(void)
rx_end_of_str = NO_END_OF_LINE_DETECTED;
rx_str_length = 0;
<<<<<<< Updated upstream
UART_PORT_SEL |= UART_PIN_RXD + UART_PIN_TXD;
=======
//Due to 3 peripherals per port there are more select bits.
UART_PORT_SEL0 |= UART_PIN_RXD + UART_PIN_TXD;
UART_PORT_SEL1 &= ~(UART_PIN_RXD + UART_PIN_TXD);
>>>>>>> Stashed changes
UART_PORT_DIR |= UART_PIN_TXD;
UART_PORT_DIR &= ~UART_PIN_RXD;
......@@ -487,7 +493,12 @@ void hal_uart_init(void)
UCA1BR0 = 138; // 115200 bits per second
UCA1BR1 = 0;
<<<<<<< Updated upstream
UCA1MCTL = UCBRS2 + UCBRS1 + UCBRS0; // Modulation UCBRSx = 7
=======
//Slight different modulation options in FR5994
UCA0MCTLW = UCBRS2 + UCBRS1 + UCBRS0;
>>>>>>> Stashed changes
UCA1CTL1 &= ~UCSWRST;
UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
......@@ -508,11 +519,18 @@ void hal_uart_deinit(void)
UCA1IE &= ~UCRXIE;
UCA1IE &= ~UCTXIE;
UCA1CTL1 = UCSWRST; //Reset State
<<<<<<< Updated upstream
UART_PORT_SEL &= ~( UART_PIN_RXD + UART_PIN_TXD );
=======
//Due to 3 peripherals per port there are more select bits.
UART_PORT_SEL0 &= ~( UART_PIN_RXD + UART_PIN_TXD);
UART_PORT_SEL1 &= ~( UART_PIN_RXD + UART_PIN_TXD);
>>>>>>> Stashed changes
UART_PORT_DIR |= UART_PIN_TXD;
UART_PORT_DIR |= UART_PIN_RXD;
UART_PORT_OUT &= ~(UART_PIN_TXD + UART_PIN_RXD);
}
<<<<<<< Updated upstream
/**************************************************************************
* @brief void hal_uart_start_tx(void)
......@@ -580,6 +598,75 @@ void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
#elif UART_SER_INTF == F2_UART_INTF_USCIA0 // Interface to UART
/**************************************************************************
=======
/**************************************************************************
* @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 UCIV__NONE:
break; // Vector 0 - no interrupt
case UCIV__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 UCIV__UCTXCFG:
// 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
/**************************************************************************
>>>>>>> Stashed changes
* @brief Initializes the serial communications peripheral and GPIO ports
* to communicate with the TUSB3410.
*
......@@ -618,9 +705,9 @@ void hal_uart_init(void)
/***************************************************************************
* @brief Disables the serial communications peripheral and clears the GPIO
* settings, reset the interupts.
*
*
* @param none
*
*
* @return none
**************************************************************************/
void hal_uart_deinit(void)
......@@ -636,9 +723,9 @@ void hal_uart_deinit(void)
/**************************************************************************
* @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)
......
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