YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
src
MCU
msp432p401r
uart_msp432.h
1
#ifndef _UART_MSP432_H_
2
#define _UART_MSP432_H_
3
4
#include <stdint.h>
5
#include "uart_interface.h"
6
#include "msp.h"
7
8
extern
"C"
{
9
void
EUSCIA0_UART_IRQHandler(
void
);
10
void
EUSCIA1_UART_IRQHandler(
void
);
11
void
EUSCIA2_UART_IRQHandler(
void
);
12
void
EUSCIA3_UART_IRQHandler(
void
);
13
}
14
15
class
uart_msp432
:
public
uart_interface
{
16
public
:
17
uart_msp432
(
EUSCI_A_Type
* mod = EUSCI_A0,
// default: backport UART
18
uint32_t baud = 115200,
19
uart_mode_t mode = UART::BITS_8 |
20
UART::NO_PARITY |
21
UART::STOPBITS_1);
22
virtual
~uart_msp432
();
23
24
// Basic read/write operations on a UART
25
bool
available()
override
;
26
char
getc()
override
;
27
void
putc(
char
c)
override
;
28
size_t
puts(
const
char
*s);
29
30
void
uartMode(uart_mode_t mode)
override
;
31
void
setBaudrate(uint32_t)
override
;
32
void
sendBreak(uint16_t ms)
override
;
33
void
setDTR(
bool
dtr)
override
;
34
void
setRTS(
bool
rts)
override
;
35
36
// Interrupt handling
37
void
uartAttachIrq (function<
void
(
char
)> f)
override
;
38
void
uartDetachIrq ()
override
;
39
void
uartEnableIrq ()
override
;
40
void
uartDisableIrq()
override
;
41
42
// FIFO control
43
void
enableFIFO(
bool
)
override
;
44
45
// The IRQ handlers are our friends :)
46
friend
void
EUSCIA0_UART_IRQHandler(
void
);
47
friend
void
EUSCIA1_UART_IRQHandler(
void
);
48
friend
void
EUSCIA2_UART_IRQHandler(
void
);
49
friend
void
EUSCIA3_UART_IRQHandler(
void
);
50
51
private
:
52
bool
_init;
53
void
init();
54
55
static
void
handleIrq(
EUSCI_A_Type
*);
56
static
function<void(
char
)> _intHandler[4];
57
58
EUSCI_A_Type
* _EUSCI;
59
uint32_t _baud;
60
uart_mode_t _mode;
61
uint8_t _port;
62
uint8_t _rx_pin;
63
uint8_t _tx_pin;
64
};
65
66
#endif
// _UART_MSP432_H_
uart_interface
Definition
uart_interface.h:26
uart_msp432
Definition
uart_msp432.h:15
EUSCI_A_Type
Definition
msp432p401r.h:753
Generated by
1.12.0