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

Fix the backchannel EUSCI number

parent 1bdcd9fd
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@
#include "uart_drv.h"
#include "msp430.h"
#include "circ_buf.h"
#include "../radio_drv/hal_types.h"
/* defines the size of the circular buffers */
#define TX_UART_BUFFER_SIZE 80
......@@ -460,40 +461,40 @@ void hal_uart_init(void)
rx_end_of_str = NO_END_OF_LINE_DETECTED;
rx_str_length = 0;
//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);
//Due to 3 peripherals per port there are more select bits.
UART_PORT_SEL1 |= UART_PIN_RXD + UART_PIN_TXD;
UART_PORT_SEL0 &= ~(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
UCA0CTL1 |= UCSWRST; // Reset State
UCA0CTL1 |= UCSSEL_1; // ACLK
UCA0CTL0 = UCMODE_0;
UCA0CTL0 &= ~UC7BIT; // 8bit char
UCA1BR0 = 3; // 9600 bits per second
UCA1BR1 = 0;
UCA0BR0 = 3; // 9600 bits per second
UCA0BR1 = 0;
UCA1MCTL = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3
UCA1CTL1 &= ~UCSWRST;
UCA0MCTL = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3
UCA0CTL1 &= ~UCSWRST;
*/
/* 115200 bits per second on 16MHz SMCLK */
UCA1CTL1 |= UCSWRST; // Reset State
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1CTL0 = UCMODE_0;
UCA1CTL0 &= ~UC7BIT; // 8bit char
UCA0CTL1 |= UCSWRST; // Reset State
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0CTL0 = UCMODE_0;
UCA0CTL0 &= ~UC7BIT; // 8bit char
UCA1BR0 = 138; // 115200 bits per second
UCA1BR1 = 0;
UCA0BR0 = 138; // 115200 bits per second
UCA0BR1 = 0;
//Slight different modulation options in FR5994
UCA0MCTLW = UCBRS2 + UCBRS1 + UCBRS0;
UCA1CTL1 &= ~UCSWRST;
UCA0CTL1 &= ~UCSWRST;
UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(GIE); // Enable Interrupts
}
......@@ -508,9 +509,9 @@ void hal_uart_init(void)
**************************************************************************/
void hal_uart_deinit(void)
{
UCA1IE &= ~UCRXIE;
UCA1IE &= ~UCTXIE;
UCA1CTL1 = UCSWRST; //Reset State
UCA0IE &= ~UCRXIE;
UCA0IE &= ~UCTXIE;
UCA0CTL1 = UCSWRST; //Reset State
//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);
......@@ -532,29 +533,23 @@ 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);
UCA0IE |= UCTXIE;
UCA0TXBUF = 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
HAL_ISR_FUNC_DECLARATION(eUSCI_isr, EUSCI_A0)
{
char tmp_uart_data;
switch(__even_in_range(UCA1IV,4))
P1OUT ^= BIT0;
switch(__even_in_range(UCA0IV,4))
{
case UCIV__NONE:
break; // Vector 0 - no interrupt
case UCIV__UCRXIFG: // Vector 2 - RXIFG
tmp_uart_data = UCA1RXBUF;
tmp_uart_data = UCA0RXBUF;
circ_buf_put_data(&uart_rx_buf, tmp_uart_data);
......@@ -571,11 +566,12 @@ void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
case UCIV__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);
UCA0TXBUF = circ_buf_get_data(&uart_tx_buf);
} else {
isr_state = TX_ISR_OFF;
UCA1IE &= ~UCTXIE; // Disable USCI_A0 TX interrupt
UCA0IE &= ~UCTXIE; // Disable USCI_A0 TX interrupt
}
P1OUT ^= BIT0;
break; // Vector 4 - TXIFG
default:
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment