Browse code

Use strutils instead of snprintf (to save some bytes), set default year to 2014, partial revamp of the stopwatch

Dario Rodriguez authored on 14/01/2014 22:59:59
Showing 1 changed files
... ...
@@ -3,6 +3,7 @@
3 3
 #include <stdio.h>
4 4
 #include <ctype.h>
5 5
 
6
+#include "strutils.h"
6 7
 #include "mw_main.h"
7 8
 
8 9
 #include "mw_uart.h"
... ...
@@ -90,8 +91,10 @@ void debug_dump_hex(const uint16_t len, const void *buf)
90 91
 	char tstr[8];
91 92
 
92 93
 	for (i=0; i<len; i++) {
93
-		snprintf(tstr, 8, "0x%02x ", *(uint8_t *)(buf+i));
94
+		debug_uart_tx("0x");
95
+		hexnum2str(*(uint8_t *)(buf+i),tstr,2);
94 96
 		debug_uart_tx(tstr);
97
+		debug_uart_tx(" ");
95 98
 	}
96 99
 	debug_uart_tx("\n");
97 100
 }
Browse code

Add option for debug UART on digital watch

Nils Faerber authored on 06/07/2013 21:18:33
Showing 1 changed files
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 static char UART_RX_CHAR = 0;
11 11
 
12
-#if defined MW_DEVBOARD_V2
12
+#if defined MW_DEVBOARD_V2 || MW_DEBUG_UART
13 13
 
14 14
 void debug_uart_tx_char(char c);
15 15
 
... ...
@@ -23,7 +23,8 @@ __interrupt void UCA_ISR (void)
23 23
 			UART_RX_CHAR = UCA3RXBUF;
24 24
 			_event_src |= DBG_UART_RCV_EVENT;
25 25
 			/* wake up to handle the received char */
26
-			LPM3_EXIT;
26
+			// LPM3_EXIT;
27
+			LPM3_EXIT_ISR();
27 28
 			break;
28 29
 		case 4: // TXIFG
29 30
 			break;
Browse code

Power saving changes, add new fonts, bitmaps and screens

Nils Faerber authored on 19/05/2013 00:07:04
Showing 1 changed files
... ...
@@ -16,12 +16,20 @@ void debug_uart_tx_char(char c);
16 16
 #pragma vector=USCI_A3_VECTOR
17 17
 __interrupt void UCA_ISR (void)
18 18
 {
19
-	/* clear IRQ flag */
20
-	UCA3IFG  &= ~UCRXIFG;
21
-	UART_RX_CHAR = UCA3RXBUF;
22
-	_event_src |= DBG_UART_RCV_EVENT;
23
-	/* wake up to handle the received char */
24
-	LPM3_EXIT;
19
+	switch (UCA3IV) {
20
+		case 2: // RXIFG
21
+			/* clear IRQ flag */
22
+			UCA3IFG  &= ~UCRXIFG;
23
+			UART_RX_CHAR = UCA3RXBUF;
24
+			_event_src |= DBG_UART_RCV_EVENT;
25
+			/* wake up to handle the received char */
26
+			LPM3_EXIT;
27
+			break;
28
+		case 4: // TXIFG
29
+			break;
30
+		default:
31
+			break;
32
+	}
25 33
 }
26 34
 
27 35
 void init_debug_uart(void)
... ...
@@ -36,7 +44,7 @@ void init_debug_uart(void)
36 44
 	/* 16,000,000 115200 138  7     0 */
37 45
 
38 46
 	UCA3BR0 = 138;
39
-	UCA3MCTL = UCBRS_7 + UCBRF_0;
47
+	UCA3MCTL = UCBRS_7 | UCBRF_0;
40 48
 
41 49
 	/* set P10.4 & P10.5 to UCA function */
42 50
 	P10SEL |= BIT4;
... ...
@@ -55,6 +63,8 @@ void init_debug_uart(void)
55 63
 
56 64
 void debug_uart_tx_char(const char c)
57 65
 {
66
+	while (UCA3STAT & UCBUSY)
67
+		nop();
58 68
 	UCA3TXBUF = c;
59 69
 	while ((UCA3IFG & UCTXIFG) == 0 )
60 70
 		nop();
Browse code

Here we are! MetaWatch support in Oswald!

Nils Faerber authored on 27/04/2013 20:22:32
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,110 @@
1
+#include <msp430.h>
2
+#include <stdint.h>
3
+#include <stdio.h>
4
+#include <ctype.h>
5
+
6
+#include "mw_main.h"
7
+
8
+#include "mw_uart.h"
9
+
10
+static char UART_RX_CHAR = 0;
11
+
12
+#if defined MW_DEVBOARD_V2
13
+
14
+void debug_uart_tx_char(char c);
15
+
16
+#pragma vector=USCI_A3_VECTOR
17
+__interrupt void UCA_ISR (void)
18
+{
19
+	/* clear IRQ flag */
20
+	UCA3IFG  &= ~UCRXIFG;
21
+	UART_RX_CHAR = UCA3RXBUF;
22
+	_event_src |= DBG_UART_RCV_EVENT;
23
+	/* wake up to handle the received char */
24
+	LPM3_EXIT;
25
+}
26
+
27
+void init_debug_uart(void)
28
+{
29
+	/* assert reset */
30
+	UCA3CTL1 = UCSWRST;
31
+
32
+	/* reset default SMCLK = 1.048MHz */
33
+	UCA3CTL1 |= UCSSEL__SMCLK;
34
+	/* CLK        baud   BRx  BRSx  BRFx */
35
+	/* 1,048,576  115200 9    1     0 */
36
+	/* 16,000,000 115200 138  7     0 */
37
+
38
+	UCA3BR0 = 138;
39
+	UCA3MCTL = UCBRS_7 + UCBRF_0;
40
+
41
+	/* set P10.4 & P10.5 to UCA function */
42
+	P10SEL |= BIT4;
43
+	P10SEL |= BIT5;
44
+
45
+	UCA3STAT = 0;
46
+
47
+	/* deassert reset */
48
+	UCA3CTL1 &= ~UCSWRST;
49
+
50
+	/* enable receive interrupt */
51
+	UCA3IE = UCRXIE;
52
+	/* clear interrup flags */
53
+	UCA3IFG = 0;
54
+}
55
+
56
+void debug_uart_tx_char(const char c)
57
+{
58
+	UCA3TXBUF = c;
59
+	while ((UCA3IFG & UCTXIFG) == 0 )
60
+		nop();
61
+}
62
+
63
+void debug_uart_tx(const char *buf)
64
+{
65
+	unsigned char i = 0;
66
+
67
+	while (buf[i] != 0) {
68
+		debug_uart_tx_char(buf[i]);
69
+		if (buf[i++] == '\n')
70
+			debug_uart_tx_char('\r');
71
+	}
72
+	while (UCA3STAT & UCBUSY)
73
+		nop();
74
+}
75
+
76
+void debug_dump_hex(const uint16_t len, const void *buf)
77
+{
78
+	int i;
79
+	char tstr[8];
80
+
81
+	for (i=0; i<len; i++) {
82
+		snprintf(tstr, 8, "0x%02x ", *(uint8_t *)(buf+i));
83
+		debug_uart_tx(tstr);
84
+	}
85
+	debug_uart_tx("\n");
86
+}
87
+
88
+void debug_dump_ascii(const uint16_t len, const void *buf)
89
+{
90
+	int i;
91
+
92
+	for (i=0; i<len; i++) {
93
+		debug_uart_tx_char(isprint(*(uint8_t *)(buf+i)) ? *(uint8_t *)(buf+i) : '.');
94
+	}
95
+	debug_uart_tx("\n");
96
+}
97
+
98
+char debug_uart_rx_char(char *c)
99
+{
100
+	if (UART_RX_CHAR != 0) {
101
+		*c = UART_RX_CHAR;
102
+		UART_RX_CHAR = 0;
103
+		return 1;
104
+	} else {
105
+		*c = 0;
106
+		return 0;
107
+	}
108
+}
109
+#endif
110
+