Mercurial > ~darius > hgwebdir.cgi > stm32temp
annotate main.c @ 59:488085e0c7e1
Don't print extra newlines when cat'ing a file.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 08 Apr 2013 23:10:47 +0930 |
parents | adc9b1555f9d |
children | f1c9a51e368a |
rev | line source |
---|---|
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
1 #include <ctype.h> |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
2 #include <malloc.h> |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
3 #include <math.h> |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
4 #include <stdio.h> |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
5 #include <stdint.h> |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
6 #include <time.h> |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
7 #include <string.h> |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
8 #include <sys/time.h> |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
9 #include <stdlib.h> |
22 | 10 #include <assert.h> |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
11 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
12 #include "stm32f10x.h" |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
13 |
13 | 14 #include "1wire.h" |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
15 #include "comm.h" |
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
16 #include "delay.h" |
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
17 #include "flash.h" |
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
18 #include "hw.h" |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
19 #include "lcd.h" |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
20 #include "main.h" |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
21 #include "rtc.h" |
49
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
22 #include "sd.h" |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
23 #include "sprink.h" |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
24 #include "tempctrl.h" |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
25 #include "touch.h" |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
26 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
27 #define MAXARGS 10 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
28 #define LINEBUF 40 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
29 typedef struct { |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
30 char *buf; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
31 volatile uint8_t state; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
32 uint8_t len; |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
33 } consbuf_t; |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
34 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
35 void NVIC_Configuration(void); |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
36 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
37 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
38 /* Called every 1 / TICK_FREQ */ |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
39 #define TICK_FREQ 10000 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
40 RAMFUNC void |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 SysTick_Handler(void) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
42 static uint32_t tick = 0; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
43 static int led = 0; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
44 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
45 tick++; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
46 if (tick % 10000 == 0) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
47 led = !led; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
48 if (led) |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
49 GPIO_SetBits(GPIOB, GPIO_Pin_5); |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
50 else |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
51 GPIO_ResetBits(GPIOB, GPIO_Pin_5); |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
52 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
53 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
54 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
56 consbuf_t cmd; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
57 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
58 RAMFUNC void |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
59 USART1_IRQHandler(void) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
60 char c; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
61 int i; |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
62 |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
63 /* Recieved data */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
64 while (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
65 c = USART_ReceiveData(USART1); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
66 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
67 /* End of line? */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
68 if (c == '\n' || c == '\r') { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
69 cmd.buf[cmd.state] = '\0'; |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
70 fputs("\n", stdout); |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
71 cmd.len = cmd.state; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
72 cmd.state = 255; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
73 continue; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
74 } |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
75 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
76 /* Ctrl-w / Ctrl-u */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
77 if (c == 0x17 || c == 0x15) { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
78 for (i = 0; i < cmd.state; i++) |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
79 fputs("\010\040\010", stdout); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
80 cmd.state = 0; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
81 continue; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
82 } |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
83 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
84 /* Backspace/delete */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
85 if (c == 0x08 || c == 0x7f) { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
86 if (cmd.state > 0) { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
87 cmd.state--; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
88 fputs("\010\040\010", stdout); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
89 } |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
90 continue; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
91 } |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
92 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
93 /* Anything unprintable just ignore it */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
94 if (!isprint(c)) |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
95 continue; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
96 |
57
adc9b1555f9d
Add the ability to log temperatures to SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
55
diff
changeset
|
97 cmd.buf[cmd.state] = c; |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
98 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
99 /* Echo back to the user */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
100 comm_put(cmd.buf[cmd.state]); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
101 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
102 cmd.state++; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
103 /* Over flow? */ |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
104 if (cmd.state == LINEBUF - 1) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
105 fputs("\nLine too long", stdout); |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
106 cmd.state = 0; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
107 continue; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
108 } |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
109 } |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
110 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
111 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
112 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
113 main(void) { |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
114 char buf[40], *argv[MAXARGS], **ap, *tmp; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
115 int argc; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
116 struct tm nowtm; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
117 time_t now; |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
118 uint16_t x, y, x1, y1, z1, z2, r, c, rx, ry; |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
119 float t, t2; |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
120 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
121 cmd.state = cmd.len = 0; |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
122 cmd.buf = malloc(LINEBUF); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
123 |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
124 /* Init hardware - configure IO ports and external peripherals */ |
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
125 hw_init(); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
126 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
127 /* NVIC configuration */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
128 NVIC_Configuration(); |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
129 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
130 /* Setup SysTick Timer rate, also enables Systick and Systick-Interrupt */ |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
131 if (SysTick_Config(SystemCoreClock / TICK_FREQ)) { |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
132 /* Capture error */ |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
133 comm_puts("Can't setup SysTick\n"); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
134 while (1) |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
135 ; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
136 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
137 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
138 /* Set stdout to unbuffered */ |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
139 setvbuf(stdout, NULL, _IONBF, 0); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
140 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
141 /* Say hello */ |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
142 fputs("\n\n\nHello world\n", stdout); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
143 |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
144 lcd_stripes(); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
145 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
146 lcd_circle(20, 20, 20, 1, LCD_RED); /* Bottom left */ |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
147 lcd_circle(300, 220, 20, 1, LCD_WHITE); /* Top right */ |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
148 lcd_circle(20, 220, 20, 1, LCD_BLUE); /* Top left */ |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
149 lcd_circle(300, 20, 20, 1, LCD_GREEN); /* Bottom right */ |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
150 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
151 lcd_line(20, 20, 20, 220, LCD_BLACK); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
152 lcd_line(20, 220, 300, 220, LCD_BLACK); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
153 lcd_line(300, 220, 300, 20, LCD_BLACK); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
154 lcd_line(300, 20, 20, 20, LCD_BLACK); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
155 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
156 lcd_ellipse(160, 120, 50, 30, 1, LCD_WHITE); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
157 lcd_ellipse(160, 120, 30, 50, 1, LCD_WHITE); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
158 |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
159 /* Setup temperature control stuff */ |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
160 tempctrl_init(); |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
161 |
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
162 /* Setup sprinkler stuff */ |
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
163 sprink_init(); |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
164 |
49
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
165 /* Setup SD card */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
166 sd_init(); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
167 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
168 while (1) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
169 fputs("> ", stdout); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
170 |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
171 while (cmd.state != 255) { |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
172 tempctrl_update(); |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
173 sprink_update(); |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
174 } |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
175 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
176 if (cmd.len < 1) |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
177 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
178 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
179 /* Split command string on space/tab boundaries into argv/argc */ |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
180 argc = 0; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
181 tmp = cmd.buf; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
182 for (ap = argv; (*ap = strsep(&cmd.buf, " \t")) != NULL;) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
183 if (**ap != '\0') { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
184 argc++; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
185 if (++ap >= &argv[MAXARGS]) |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
186 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
187 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
188 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
189 /* Reset the buffer pointer after strsep() has mangled it */ |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
190 cmd.buf = tmp; |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
191 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
192 if (!strcmp("gc", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
193 now = time(NULL); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
194 gmtime_r(&now, &nowtm); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
195 strftime(buf, sizeof(buf) - 1, "%Y/%m/%d %H:%M:%S UTC", &nowtm); |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
196 printf("Time is %s (%d)\n", buf, (int)now); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
197 } else if (!strcmp("sc", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
198 struct timeval tv; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
199 if (argc != 2) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
200 fputs("Incorrect number of arguments\n", stdout); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
201 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
202 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
203 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
204 tv.tv_sec = atoi(argv[1]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
205 tv.tv_usec = 0; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
206 settimeofday(&tv, NULL); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
207 } else if (!strcmp("read", argv[0])) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
208 printf("PB5 = %d\n", GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_15)); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
209 } else if (!strcmp("touch", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
210 for (int i = 0; i < 10; i++) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
211 tp_getcoords(&x, &y, &z1, &z2, &t, &t2); |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
212 printf("X = %5d Y = %5d Z1 = %5d Z2 = %5d T = %7.2f T2 = %7.2f\n", x, y, z1, z2, t, t2); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
213 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
214 } else if (!strcmp("fl", argv[0])) { |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
215 flashcmd(argc - 1, argv + 1); |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
216 } else if (!strcmp("tc", argv[0])) { |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
217 tempctrl_cmd(argc - 1, argv + 1); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
218 } else if (!strcmp("pwm", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
219 lcd_setpwm(atoi(argv[1])); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
220 } else if (!strcmp("circ", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
221 if (argc != 5) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
222 fputs("Unable to parse circ args\n", stdout); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
223 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
224 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
225 x = atoi(argv[1]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
226 y = atoi(argv[2]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
227 r = atoi(argv[3]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
228 c = lcd_parsecol(argv[4][0]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
229 lcd_circle(x, y, r, 0, c); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
230 } else if (!strncmp("ellip", cmd.buf, 6)) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
231 if (argc != 5) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
232 fputs("Unable to parse ellip args\n", stdout); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
233 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
234 } |
16
db6011aa94d6
Use new delay routine on pin 2 so it doesn't interfere with 1 wire.
Daniel O'Connor <darius@dons.net.au>
parents:
13
diff
changeset
|
235 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
236 x = atoi(argv[1]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
237 y = atoi(argv[2]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
238 rx = atoi(argv[3]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
239 ry = atoi(argv[4]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
240 c = lcd_parsecol(argv[5][0]); |
13 | 241 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
242 lcd_ellipse(x, y, rx, ry, 0, c); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
243 } else if (!strncmp("line", cmd.buf, 5)) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
244 if (argc != 5) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
245 fputs("Unable to parse line args\n", stdout); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
246 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
247 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
248 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
249 x = atoi(argv[1]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
250 y = atoi(argv[2]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
251 x1 = atoi(argv[3]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
252 y1 = atoi(argv[4]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
253 c = lcd_parsecol(argv[5][0]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
254 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
255 lcd_line(x, y, x1, y1, c); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
256 } else if (!strcmp("delay", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
257 for (x = 0; x < 100; x++) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
258 GPIO_SetBits(GPIOE, GPIO_Pin_2); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
259 delay(30); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
260 GPIO_ResetBits(GPIOE, GPIO_Pin_2); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
261 delay(60); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
262 } |
44
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
263 } else if (!strcmp("cyc", argv[0])) { |
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
264 if (argc != 2) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
265 fputs("Incorrect number of arguments\n", stdout); |
44
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
266 goto out; |
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
267 } |
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
268 |
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
269 GPIO_SetBits(GPIOE, GPIO_Pin_2); |
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
270 delay(atoi(argv[1])); |
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
271 GPIO_ResetBits(GPIOE, GPIO_Pin_2); |
f1cc171b06b5
Remove useless delay test. Add GPIO PE2 changes to make testing arbitary delays possible.
Daniel O'Connor <darius@dons.net.au>
parents:
40
diff
changeset
|
272 |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
273 fputs("Done\n", stdout); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
274 } else if (!strcmp("rs", argv[0])) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
275 printf("Reset got %d\n", OWTouchReset()); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
276 } else if (!strcmp("sr", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
277 uint8_t ROM[8]; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
278 int8_t i; |
13 | 279 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
280 memset(ROM, 0, 8); |
13 | 281 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
282 i = OWFirst(ROM, 1, 0); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
283 do { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
284 switch (i) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
285 case OW_NOMODULES: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
286 case OW_FOUND: |
13 | 287 break; |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
288 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
289 case OW_BADWIRE: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
290 case OW_NOPRESENCE: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
291 case OW_BADCRC: |
13 | 292 default: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
293 printf("Err %d\n", i); |
13 | 294 break; |
295 } | |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
296 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
297 if (i != OW_FOUND) |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
298 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
299 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
300 for (i = 0; i < 8; i++) |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
301 printf("%02x%s", ROM[i], i == 7 ? "\n" : ":"); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
302 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
303 i = OWNext(ROM, 1, 0); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
304 } while (1); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
305 } else if (!strcmp("rb", argv[0])) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
306 printf("Read bit returned %d\n", OWReadBit()); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
307 } else if (!strcmp("wb", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
308 if (argc != 2) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
309 fputs("Incorrect number of arguments\n", stdout); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
310 goto out; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
311 } |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
312 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
313 x = atoi(argv[1]); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
314 OWWriteBit(x); |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
315 printf("Wrote %d\n", x); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
316 } else if (!strcmp("te", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
317 uint8_t ROM[8]; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
318 int16_t res; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
319 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
320 if (sscanf(argv[1], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
321 &ROM[0], &ROM[1], &ROM[2], &ROM[3], |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
322 &ROM[4], &ROM[5], &ROM[6], &ROM[7]) != 8) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
323 fputs("Unable to parse ROM ID\n", stdout); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
324 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
325 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
326 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
327 res = OWGetTemp(ROM); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
328 switch (res) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
329 case OW_TEMP_WRONG_FAM: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
330 printf("ROM specified isn't a temperature sensor\n"); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
331 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
332 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
333 case OW_TEMP_CRC_ERR: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
334 printf("CRC mismatch\n"); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
335 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
336 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
337 case OW_TEMP_NO_ROM: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
338 printf("No ROM found\n"); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
339 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
340 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
341 default: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
342 printf("%hd.%02hd\n", GETWHOLE(res), GETFRAC(res)); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
343 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
344 } |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
345 } else if (!strcmp("rtc", argv[0])) { |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
346 float f, err, maxerr; |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
347 uint32_t d, i; |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
348 |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
349 maxerr = 0; |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
350 for (i = 0; i < 32768; i++) { |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
351 d = RTC_PS2USEC(32768 - i); |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
352 f = ((float)i * 1e6) / (float)RTC_PRESCALE; |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
353 err = fabs(d - f); |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
354 //rtcprintf("i = %d, d = %d, f = %.3f, err = %.3f\n", i, d, f, err); |
31
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
355 if (err > maxerr) |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
356 maxerr = err; |
03592ca4d37e
Port tempctrl.c from AVR. I removed the beep code as I don't have a
Daniel O'Connor <darius@dons.net.au>
parents:
22
diff
changeset
|
357 } |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
358 printf("Max err = %.3f\n", maxerr); |
22 | 359 } else if (!strcmp("assert", argv[0])) { |
360 assert(0 == 1); | |
49
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
361 } else if (!strcmp("sd", argv[0])) { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
362 sd_cmd(argc - 1, argv + 1); |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
363 } else if (!strcmp("zz", argv[0])) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
364 NVIC_SystemReset(); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
365 } else { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
366 printf("Unknown command\n"); |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
367 } |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
368 out: |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
369 cmd.state = 0; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
370 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
371 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
372 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
373 /* Configure interrupt controller */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
374 #ifdef VECT_TAB_RAM |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
375 /* vector-offset (TBLOFF) from bottom of SRAM. defined in linker script */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
376 extern uint32_t _isr_vectorsram_offs; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
377 #else |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
378 extern uint32_t _isr_vectorsflash_offs; |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
379 #endif |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
380 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
381 void |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
382 NVIC_Configuration(void) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
383 NVIC_InitTypeDef NVIC_InitStructure; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
384 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
385 #ifdef VECT_TAB_RAM |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
386 /* Set the Vector Table base location at 0x20000000+_isr_vectorsram_offs */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
387 NVIC_SetVectorTable(NVIC_VectTab_RAM, (uint32_t)&_isr_vectorsram_offs); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
388 #else |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
389 /* Set the Vector Table base location at 0x08000000+_isr_vectorsflash_offs */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
390 NVIC_SetVectorTable(NVIC_VectTab_FLASH, (uint32_t)&_isr_vectorsflash_offs); |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
391 #endif |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
392 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
393 /* Enable the USART1 Interrupt */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
394 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
395 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
396 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
397 NVIC_Init(&NVIC_InitStructure); |
55
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
398 |
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
399 /* Enable the SDIO Interrupt */ |
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
400 NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn; |
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
401 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
402 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
403 NVIC_Init(&NVIC_InitStructure); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
404 } |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
405 |