Mercurial > ~darius > hgwebdir.cgi > stm32temp
annotate main.c @ 88:5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Fri, 13 Mar 2015 11:36:41 +1030 |
parents | f1c9a51e368a |
children |
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" |
76
f1c9a51e368a
Add EEPROM emulation from AN2594.
Daniel O'Connor <darius@dons.net.au>
parents:
57
diff
changeset
|
17 #include "eeprom.h" |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
18 #include "flash.h" |
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
19 #include "hw.h" |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
20 #include "lcd.h" |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
21 #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
|
22 #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
|
23 #include "sd.h" |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
24 #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
|
25 #include "tempctrl.h" |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
26 #include "touch.h" |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
27 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
28 #define MAXARGS 10 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
29 #define LINEBUF 40 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
30 typedef struct { |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
31 char *buf; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
32 volatile uint8_t state; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
33 uint8_t len; |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
34 } consbuf_t; |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
35 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
36 void NVIC_Configuration(void); |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
37 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
38 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
39 /* Called every 1 / TICK_FREQ */ |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
40 #define TICK_FREQ 10000 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 RAMFUNC void |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
42 SysTick_Handler(void) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
43 static uint32_t tick = 0; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
44 static int led = 0; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
45 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
46 tick++; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
47 if (tick % 10000 == 0) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
48 led = !led; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
49 if (led) |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
50 GPIO_SetBits(GPIOB, GPIO_Pin_5); |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
51 else |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
52 GPIO_ResetBits(GPIOB, GPIO_Pin_5); |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
53 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
54 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
56 |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
57 consbuf_t cmd; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
58 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
59 RAMFUNC void |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
60 USART1_IRQHandler(void) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
61 char c; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
62 int i; |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
63 |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
64 /* Recieved data */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
65 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
|
66 c = USART_ReceiveData(USART1); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
67 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
68 /* End of line? */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
69 if (c == '\n' || c == '\r') { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
70 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
|
71 fputs("\n", stdout); |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
72 cmd.len = cmd.state; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
73 cmd.state = 255; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
74 continue; |
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 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
77 /* Ctrl-w / Ctrl-u */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
78 if (c == 0x17 || c == 0x15) { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
79 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
|
80 fputs("\010\040\010", stdout); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
81 cmd.state = 0; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
82 continue; |
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 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
85 /* Backspace/delete */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
86 if (c == 0x08 || c == 0x7f) { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
87 if (cmd.state > 0) { |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
88 cmd.state--; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
89 fputs("\010\040\010", stdout); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
90 } |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
91 continue; |
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 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
94 /* Anything unprintable just ignore it */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
95 if (!isprint(c)) |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
96 continue; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
97 |
57
adc9b1555f9d
Add the ability to log temperatures to SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
55
diff
changeset
|
98 cmd.buf[cmd.state] = c; |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
99 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
100 /* Echo back to the user */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
101 comm_put(cmd.buf[cmd.state]); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
102 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
103 cmd.state++; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
104 /* Over flow? */ |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
105 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
|
106 fputs("\nLine too long", stdout); |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
107 cmd.state = 0; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
108 continue; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
109 } |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
110 } |
0
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 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
113 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
114 main(void) { |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
115 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
|
116 int argc; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
117 struct tm nowtm; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
118 time_t now; |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
119 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
|
120 float t, t2; |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
121 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
122 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
|
123 cmd.buf = malloc(LINEBUF); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
124 |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
125 /* 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
|
126 hw_init(); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
127 |
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 NVIC_Configuration(); |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
130 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
131 /* 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
|
132 if (SysTick_Config(SystemCoreClock / TICK_FREQ)) { |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
133 /* 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
|
134 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
|
135 while (1) |
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 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
138 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
139 /* Set stdout to unbuffered */ |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
140 setvbuf(stdout, NULL, _IONBF, 0); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
141 /* Say hello */ |
88
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
142 fputs("\n\n\n" |
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
143 "===============\n" |
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
144 "==== Reset ====\n" |
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
145 "===============\n", |
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
146 stdout); |
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
147 |
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
148 #if 0 |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
149 lcd_stripes(); |
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_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
|
152 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
|
153 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
|
154 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
|
155 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
156 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
|
157 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
|
158 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
|
159 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
|
160 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
161 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
|
162 lcd_ellipse(160, 120, 30, 50, 1, LCD_WHITE); |
88
5fc6a25f40ef
Disable LCD init code since this board doesn't have it.
Daniel O'Connor <darius@dons.net.au>
parents:
76
diff
changeset
|
163 #endif |
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 /* 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
|
165 tempctrl_init(); |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
166 |
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
167 /* Setup sprinkler stuff */ |
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
168 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
|
169 |
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
|
170 /* 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
|
171 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
|
172 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
173 while (1) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
174 fputs("> ", stdout); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
175 |
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
|
176 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
|
177 tempctrl_update(); |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
178 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
|
179 } |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
180 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
181 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
|
182 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
183 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
184 /* 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
|
185 argc = 0; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
186 tmp = cmd.buf; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
187 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
|
188 if (**ap != '\0') { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
189 argc++; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
190 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
|
191 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
192 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
193 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
194 /* 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
|
195 cmd.buf = tmp; |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
196 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
197 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
|
198 now = time(NULL); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 } 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
|
203 struct timeval tv; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
204 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
|
205 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
|
206 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
207 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
208 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
209 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
|
210 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
|
211 settimeofday(&tv, NULL); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
212 } 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
|
213 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
|
214 } 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
|
215 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
|
216 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
|
217 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
|
218 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
219 } 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
|
220 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
|
221 } 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
|
222 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
|
223 } 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
|
224 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
|
225 } 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
|
226 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
|
227 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
|
228 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
229 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 } 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
|
236 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
|
237 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
|
238 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
239 } |
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
|
240 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
241 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
|
242 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
|
243 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
|
244 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
|
245 c = lcd_parsecol(argv[5][0]); |
13 | 246 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
247 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
|
248 } 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
|
249 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
|
250 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
|
251 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
252 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
253 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
254 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
260 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
|
261 } 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
|
262 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
|
263 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
|
264 delay(30); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
265 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
|
266 delay(60); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
267 } |
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
|
268 } 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
|
269 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
|
270 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
|
271 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
|
272 } |
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
|
273 |
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
|
274 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
|
275 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
|
276 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
|
277 |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
278 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
|
279 } 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
|
280 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
|
281 } 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
|
282 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
|
283 int8_t i; |
13 | 284 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
285 memset(ROM, 0, 8); |
13 | 286 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
287 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
|
288 do { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
289 switch (i) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
290 case OW_NOMODULES: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
291 case OW_FOUND: |
13 | 292 break; |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
293 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
294 case OW_BADWIRE: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
295 case OW_NOPRESENCE: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
296 case OW_BADCRC: |
13 | 297 default: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
298 printf("Err %d\n", i); |
13 | 299 break; |
300 } | |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
301 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
302 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
|
303 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
304 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
305 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
|
306 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
|
307 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
308 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
|
309 } while (1); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
310 } 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
|
311 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
|
312 } 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
|
313 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
|
314 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
|
315 goto out; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
316 } |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
317 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
318 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
|
319 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
|
320 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
|
321 } 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
|
322 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
|
323 int16_t res; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
324 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
325 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
|
326 &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
|
327 &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
|
328 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
|
329 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
330 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
331 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
332 res = OWGetTemp(ROM); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
333 switch (res) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
334 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
|
335 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
|
336 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
337 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
338 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
|
339 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
|
340 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
341 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
342 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
|
343 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
|
344 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
345 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
346 default: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
347 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
|
348 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
349 } |
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
|
350 } 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
|
351 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
|
352 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
|
353 |
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
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 //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
|
360 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
|
361 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
|
362 } |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
363 printf("Max err = %.3f\n", maxerr); |
22 | 364 } else if (!strcmp("assert", argv[0])) { |
365 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
|
366 } 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
|
367 sd_cmd(argc - 1, argv + 1); |
76
f1c9a51e368a
Add EEPROM emulation from AN2594.
Daniel O'Connor <darius@dons.net.au>
parents:
57
diff
changeset
|
368 } else if (!strcmp("ee", argv[0])) { |
f1c9a51e368a
Add EEPROM emulation from AN2594.
Daniel O'Connor <darius@dons.net.au>
parents:
57
diff
changeset
|
369 EE_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
|
370 } 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
|
371 NVIC_SystemReset(); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
372 } else { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
373 printf("Unknown command\n"); |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
374 } |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
375 out: |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
376 cmd.state = 0; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
377 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
378 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
379 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
380 /* Configure interrupt controller */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
381 #ifdef VECT_TAB_RAM |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
382 /* 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
|
383 extern uint32_t _isr_vectorsram_offs; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
384 #else |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
385 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
|
386 #endif |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
387 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
388 void |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
389 NVIC_Configuration(void) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
390 NVIC_InitTypeDef NVIC_InitStructure; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
391 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
392 #ifdef VECT_TAB_RAM |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
393 /* 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
|
394 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
|
395 #else |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
396 /* 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
|
397 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
|
398 #endif |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
399 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
400 /* Enable the USART1 Interrupt */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
401 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
402 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
403 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
404 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
|
405 |
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
406 /* 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
|
407 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
|
408 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
|
409 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
|
410 NVIC_Init(&NVIC_InitStructure); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
411 } |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
412 |