Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MSP430FR5994 BOOSTXL-CC1120-90 Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Energy-Driven Computing
MSP430FR5994 BOOSTXL-CC1120-90 Library
Commits
ce2e7149
Commit
ce2e7149
authored
5 years ago
by
Edward Longman
Browse files
Options
Downloads
Patches
Plain Diff
Copy F5_UART_INTF_USCIA1 section for conversion to FR5
parent
aa2eb431
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/lib/uart_drv/uart_drv.c
+139
-4
139 additions, 4 deletions
source/lib/uart_drv/uart_drv.c
source/lib/uart_drv/uart_drv.h
+7
-1
7 additions, 1 deletion
source/lib/uart_drv/uart_drv.h
with
146 additions
and
5 deletions
source/lib/uart_drv/uart_drv.c
+
139
−
4
View file @
ce2e7149
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
source/lib/uart_drv/uart_drv.h
+
7
−
1
View file @
ce2e7149
...
...
@@ -43,7 +43,7 @@
*
* F2_UART_INTF_USCIA0 LaunchPAD_G2553
* F5_UART_INTF_USCIA0 MSP430_TRXEB development kit
* FR5_UART_INTF_USCIA0 LaunchPAD_FR59
6
9
* FR5_UART_INTF_USCIA0 LaunchPAD_FR599
4
*
*******************************************************************************/
#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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment