Skip to content

Commit a5da692

Browse files
committed
Revert "rebased to actual top"
This reverts commit 17dff90.
1 parent 9ab7222 commit a5da692

File tree

16 files changed

+162
-1605
lines changed

16 files changed

+162
-1605
lines changed

hardware/msp430/boards.txt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
lpmsp430g2452.name=LaunchPad w/ msp430g2452
33
lpmsp430g2452.upload.protocol=rf2500
44
lpmsp430g2452.upload.maximum_size=8192
5-
lpmsp430g2452.bootloader.lock_bits=0x0F
65
lpmsp430g2452.build.mcu=msp430g2452
76
lpmsp430g2452.build.f_cpu=16000000L
87
lpmsp430g2452.build.core=msp430
@@ -13,7 +12,6 @@ lpmsp430g2452.build.variant=launchpad
1312
lpmsp430g2231.name=LaunchPad w/ msp430g2231
1413
lpmsp430g2231.upload.protocol=rf2500
1514
lpmsp430g2231.upload.maximum_size=2048
16-
lpmsp430g2231.bootloader.lock_bits=0x0F
1715
lpmsp430g2231.build.mcu=msp430g2231
1816
lpmsp430g2231.build.f_cpu=1000000L
1917
lpmsp430g2231.build.core=msp430
@@ -24,29 +22,8 @@ lpmsp430g2231.build.variant=launchpad
2422
lpmsp430g2553.name=LaunchPad w/ msp430g2553
2523
lpmsp430g2553.upload.protocol=rf2500
2624
lpmsp430g2553.upload.maximum_size=16384
27-
lpmsp430g2553.bootloader.lock_bits=0x0F
2825
lpmsp430g2553.build.mcu=msp430g2553
2926
lpmsp430g2553.build.f_cpu=16000000L
3027
lpmsp430g2553.build.core=msp430
3128
lpmsp430g2553.build.variant=launchpad
3229
##############################################################
33-
34-
lpmsp430f2274.name=LaunchPad w/ msp430f2274
35-
lpmsp430f2274.upload.protocol=rf2500
36-
lpmsp430f2274.upload.maximum_size=16384
37-
lpmsp430f2274.bootloader.lock_bits=0x0F
38-
lpmsp430f2274.build.mcu=msp430f2274
39-
lpmsp430f2274.build.f_cpu=16000000L
40-
lpmsp430f2274.build.core=msp430
41-
lpmsp430f2274.build.variant=eZ430-RF
42-
##############################################################
43-
44-
lpmsp430fr5739.name=LaunchPad w/ msp430fr5739
45-
lpmsp430fr5739.upload.protocol=rf2500
46-
lpmsp430fr5739.upload.maximum_size=15872
47-
lpmsp430fr5739.bootloader.lock_bits=0x0F
48-
lpmsp430fr5739.build.mcu=msp430fr5739
49-
lpmsp430fr5739.build.f_cpu=8000000L
50-
lpmsp430fr5739.build.core=msp430
51-
lpmsp430fr5739.build.variant=EXP430FR57xx
52-
##############################################################

hardware/msp430/cores/msp430/Energia.h

Lines changed: 31 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,10 @@ extern "C"{
2525
#define FALLING 1
2626
#define RISING 0
2727

28-
//#define INPUT 0x0
29-
//#define OUTPUT 0x1
30-
//#define INPUT_PULLUP 0x2
31-
//#define INPUT_PULLDOWN 0x3
32-
3328
#define INPUT 0x0
3429
#define OUTPUT 0x1
3530
#define INPUT_PULLUP 0x2
36-
#define INPUT_PULLDOWN 0x4
37-
#define PORT_SELECTION0 0x10
38-
#define PORT_SELECTION1 0x20
39-
31+
#define INPUT_PULLDOWN 0x3
4032

4133
#define true 0x1
4234
#define false 0x0
@@ -54,59 +46,26 @@ extern "C"{
5446
#define EXTERNAL SREF_2
5547
#endif
5648

57-
#if defined(__MSP430_HAS_ADC10_B__)
58-
#define DEFAULT ADC10SREF_0
59-
#define INTERNAL1V5 ADC10SREF_1 + ADC10REFON
60-
#define INTERNAL2V5 ADC10SREF_1 + ADC10REFON + ADC10REF2_5V
61-
#define EXTERNAL ADC10SREF_2
62-
#endif
63-
64-
enum{
65-
P1 = 1,
66-
P2,
67-
#ifdef __MSP430_HAS_PORT3_R__
68-
P3,
69-
#endif
70-
#ifdef __MSP430_HAS_PORT4_R__
71-
P4,
72-
#endif
73-
#ifdef __MSP430_HAS_PORT5_R__
74-
P5,
75-
#endif
76-
#ifdef __MSP430_HAS_PORT6_R__
77-
P6,
78-
#endif
79-
#ifdef __MSP430_HAS_PORT7_R__
80-
P7,
81-
#endif
82-
#ifdef __MSP430_HAS_PORTJ_R__
83-
PJ,
84-
#endif
85-
};
86-
87-
enum{
88-
T0A0,
89-
T0A1,
90-
T0A2,
91-
T1A0,
92-
T1A1,
93-
T1A2,
94-
T1A3,
95-
T1A4,
96-
T1A5,
97-
T2A0,
98-
T2A1,
99-
T2A2,
100-
T0B0,
101-
T0B1,
102-
T0B2,
103-
T1B0,
104-
T1B1,
105-
T1B2,
106-
T2B0,
107-
T2B1,
108-
T2B2
109-
};
49+
#define P1 1
50+
#define P2 2
51+
#define P3 3
52+
#define P4 4
53+
#define P5 5
54+
#define P6 6
55+
#define P7 7
56+
57+
#define T0A0 0
58+
#define T0A1 1
59+
#define T0A2 2
60+
#define T1A0 3
61+
#define T1A1 4
62+
#define T1A2 5
63+
#define T1A3 6
64+
#define T1A4 7
65+
#define T1A5 8
66+
#define T2A0 9
67+
#define T2A1 10
68+
#define T2A2 11
11069

11170
typedef uint8_t boolean;
11271
typedef uint8_t byte;
@@ -165,29 +124,21 @@ void detachInterrupt(uint8_t);
165124
extern const uint8_t digital_pin_to_timer[];
166125
extern const uint8_t digital_pin_to_port[];
167126
extern const uint8_t digital_pin_to_bit_mask[];
168-
extern const uint16_t port_to_sel0[];
169-
extern const uint16_t port_to_sel1[];
127+
extern const uint16_t port_to_sel[];
170128
extern const uint16_t port_to_sel2[];
171129
extern const uint16_t port_to_input[];
172130
extern const uint16_t port_to_output[];
173131

174-
#define digitalPinToPort(P) ( digital_pin_to_port[P] )
132+
#define digitalPinToPort(P) ( digital_pin_to_port[P] )
175133
#define digitalPinToBitMask(P) ( digital_pin_to_bit_mask[P] )
176-
#define digitalPinToTimer(P) ( digital_pin_to_timer[P] )
177-
#define portDirRegister(P) ( (volatile uint8_t *)( port_to_dir[P]) )
178-
/*
179-
* We either of the compination PxSEL and PxSEL2 or PxSEL0 and PxSEL1
180-
* So we can remap PxSEL and PxSEL2 to PxSEL0 and PxSEL1
181-
*/
182-
#define portSelRegister(P) ( (volatile uint8_t *)( port_to_sel0[P]) )
183-
#define portSel2Register(P) ( (volatile uint8_t *)( port_to_sel2[P]) )
184-
185-
#define portSel0Register(P) ( (volatile uint8_t *)( port_to_sel0[P]) )
186-
#define portSel1Register(P) ( (volatile uint8_t *)( port_to_sel1[P]) )
187-
#define portRenRegister(P) ( (volatile uint8_t *)( port_to_ren[P]) )
188-
#define portOutputRegister(P) ( (volatile uint8_t *)( port_to_output[P]) )
189-
#define portInputRegister(P) ( (volatile uint8_t *)( port_to_input[P]) )
190-
#define digitalPinToTimer(P) ( digital_pin_to_timer[P] )
134+
#define digitalPinToTimer(P) ( digital_pin_to_timer[P] )
135+
#define portDirRegister(P) ( (volatile uint16_t *)( port_to_dir[P]) )
136+
#define portSelRegister(P) ( (volatile uint16_t *)( port_to_sel[P]) )
137+
#define portSel2Register(P) ( (volatile uint16_t *)( port_to_sel2[P]) )
138+
#define portRenRegister(P) ( (volatile uint16_t *)( port_to_ren[P]) )
139+
#define portOutputRegister(P) ( (volatile uint16_t *)( port_to_output[P]) )
140+
#define portInputRegister(P) ( (volatile uint16_t *)( port_to_input[P]) )
141+
#define digitalPinToTimer(P) ( digital_pin_to_timer[P] )
191142

192143
// Implemented in wiring.c
193144
void delayMicroseconds(unsigned int us);

hardware/msp430/cores/msp430/HardwareSerial.cpp

Lines changed: 31 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,21 @@
3636
#include "Energia.h"
3737
#include "wiring_private.h"
3838

39-
#if defined(__MSP430_HAS_USCI__) || defined(__MSP430_HAS_EUSCI_A0__)
39+
#if defined(__MSP430_HAS_USCI__)
4040

4141
#include "HardwareSerial.h"
4242

4343
HardwareSerial *SerialPtr;
4444

45+
/**
46+
* Receive Data (RXD) at P1.1
47+
*/
48+
#define RXD BIT1
49+
50+
/**
51+
* Receive Data (TXD) at P1.2
52+
*/
53+
#define TXD BIT2
4554

4655

4756
#define SERIAL_BUFFER_SIZE 16
@@ -83,12 +92,8 @@ HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer)
8392

8493
void HardwareSerial::begin(unsigned long baud)
8594
{
86-
unsigned int mod, divider;
87-
unsigned char oversampling;
88-
// uint8_t bit;
89-
// uint8_t port;
90-
// volatile uint8_t *sel;
91-
95+
unsigned int divider;
96+
unsigned char mod, oversampling;
9297

9398
if (SMCLK/baud>=48) { // requires SMCLK for oversampling
9499
oversampling = 1;
@@ -99,44 +104,27 @@ void HardwareSerial::begin(unsigned long baud)
99104

100105
divider=(SMCLK<<4)/baud;
101106

102-
SerialPtr = this;
103-
104-
pinMode(UARTRXD, UARTRXD_SET_MODE);
105-
pinMode(UARTTXD, UARTTXD_SET_MODE);
106-
107-
UCA0CTL1 = UCSWRST;
108-
UCA0CTL1 = UCSSEL_2; // SMCLK
109-
UCA0CTL0 = 0;
110-
UCA0ABCTL = 0;
111-
#if defined(__MSP430_HAS_EUSCI_A0__)
112-
if(!oversampling) {
113-
mod = ((divider&0xF)+1)&0xE; // UCBRSx (bit 1-3)
114-
divider >>=4;
115-
} else {
116-
mod = divider&0xFFF0; // UCBRFx = INT([(N/16) – INT(N/16)] × 16)
117-
divider>>=8;
118-
}
119-
UCA0BR0 = divider;
120-
UCA0BR1 = divider>>8;
121-
UCA0MCTLW = (oversampling ? UCOS16:0) | mod;
122-
#else
123107
if(!oversampling) {
124-
mod = ((divider&0xF)+1)&0xE; // UCBRSx (bit 1-3)
108+
mod = ((divider&0xF)+1)&0xE; // UCBRSx (bit 1-3)
125109
divider >>=4;
126110
} else {
127-
mod = ((divider&0xf8)+0x8)&0xf0; // UCBRFx (bit 4-7)
111+
mod = ((divider&0xf8)+0x8)&0xf0; // UCBRFx (bit 4-7)
128112
divider>>=8;
129113
}
114+
115+
SerialPtr = this;
116+
P1SEL = RXD + TXD;
117+
P1SEL2 = RXD + TXD;
118+
119+
UCA0CTL1 = UCSWRST;
120+
UCA0CTL1 = UCSSEL_2; //SMCLK
121+
UCA0CTL0 = 0;
122+
UCA0ABCTL = 0;
130123
UCA0BR0 = divider;
131124
UCA0BR1 = divider>>8;
132-
UCA0MCTL = (unsigned char)(oversampling ? UCOS16:0) | mod;
133-
#endif
125+
UCA0MCTL = (oversampling ? UCOS16:0) | mod;
134126
UCA0CTL1 &= ~UCSWRST;
135-
#if defined(__MSP430_HAS_EUSCI_A0__)
136-
UCA0IE = UCRXIE;
137-
#else
138127
UC0IE = UCA0RXIE;
139-
#endif
140128
}
141129

142130
void HardwareSerial::end()
@@ -190,11 +178,7 @@ size_t HardwareSerial::write(uint8_t c)
190178
_tx_buffer->buffer[_tx_buffer->head] = c;
191179
_tx_buffer->head = i;
192180

193-
#if defined(__MSP430_HAS_EUSCI_A0__)
194-
UCA0IE |= UCTXIE;
195-
#else
196-
UC0IE |= UCA0TXIE;
197-
#endif
181+
IE2 |= UCA0TXIE;
198182

199183
return 1;
200184
}
@@ -205,49 +189,30 @@ void HardwareSerial::ProcessRXInt(void)
205189
store_char(c, &rx_buffer);
206190
}
207191

192+
__attribute__((interrupt(USCIAB0RX_VECTOR)))
193+
void HardwareSerial::USCI0RX_ISR(void)
194+
{
195+
SerialPtr->ProcessRXInt();
196+
}
208197

209198
void HardwareSerial::ProcessTXInt(void)
210199
{
211200
if (tx_buffer.head == tx_buffer.tail) {
212201
// Buffer empty, so disable interrupts
213-
#if defined(__MSP430_HAS_EUSCI_A0__)
214-
UCA0IE &= ~UCTXIE;
215-
UCA0IFG |= UCTXIFG; // Set Flag again
216-
#else
217-
UC0IE &= ~UCA0TXIE;
218-
#endif
202+
IE2 &= ~UCA0TXIE;
219203
return;
220204
}
221205

222206
unsigned char c = tx_buffer.buffer[tx_buffer.tail];
223207
tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE;
224208
UCA0TXBUF = c;
225209
}
226-
#if defined(__MSP430_HAS_EUSCI_A0__)
227-
__attribute__((interrupt(USCI_A0_VECTOR)))
228-
void HardwareSerial::USCIA0_ISR(void)
229-
{
230-
switch ( UCA0IV )
231-
{
232-
case USCI_UART_UCRXIFG: SerialPtr->ProcessRXInt(); break;
233-
case USCI_UART_UCTXIFG: SerialPtr->ProcessTXInt(); break;
234-
}
235-
236-
237-
}
238-
#else
239-
__attribute__((interrupt(USCIAB0RX_VECTOR)))
240-
void HardwareSerial::USCI0RX_ISR(void)
241-
{
242-
SerialPtr->ProcessRXInt();
243-
}
244210

245211
__attribute__((interrupt(USCIAB0TX_VECTOR)))
246212
void HardwareSerial::USCI0TX_ISR(void)
247213
{
248214
SerialPtr->ProcessTXInt();
249215
}
250-
#endif
251216

252217
// Preinstantiate Objects //////////////////////////////////////////////////////
253218

hardware/msp430/cores/msp430/HardwareSerial.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,8 @@ class HardwareSerial : public Stream
4141
uint8_t lock;
4242
ring_buffer *_rx_buffer;
4343
ring_buffer *_tx_buffer;
44-
#if defined(__MSP430_HAS_EUSCI_A0__)
45-
static void USCIA0_ISR (void);
46-
#else
4744
static void USCI0RX_ISR (void);
4845
static void USCI0TX_ISR (void);
49-
#endif
5046
void ProcessTXInt(void);
5147
void ProcessRXInt(void);
5248
public:

0 commit comments

Comments
 (0)