Mercurial > ~darius > hgwebdir.cgi > stm32temp
annotate main.c @ 80:1a4573062b37
Reshuffle in preparation for being able to have a common API for SPI flash and (emulated) EEPROM.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Sun, 07 Jul 2013 22:49:02 +0930 |
parents | f1c9a51e368a |
children | 5fc6a25f40ef |
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); |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
141 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
142 /* 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
|
143 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
|
144 |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
145 lcd_stripes(); |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
146 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 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
|
151 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 |
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
157 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
|
158 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
|
159 |
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
|
160 /* 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
|
161 tempctrl_init(); |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
162 |
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
163 /* Setup sprinkler stuff */ |
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
164 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
|
165 |
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
|
166 /* 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
|
167 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
|
168 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
169 while (1) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
170 fputs("> ", stdout); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
171 |
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
|
172 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
|
173 tempctrl_update(); |
45
6466e8720e04
Add sprinkler control stubs for testing
Daniel O'Connor <darius@dons.net.au>
parents:
44
diff
changeset
|
174 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
|
175 } |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
176 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
177 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
|
178 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
179 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
180 /* 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
|
181 argc = 0; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
182 tmp = cmd.buf; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
183 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
|
184 if (**ap != '\0') { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
185 argc++; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
186 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
|
187 break; |
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 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
190 /* 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
|
191 cmd.buf = tmp; |
12
093bc0c3b1cc
Add delay, ellipse and line demos.
Daniel O'Connor <darius@dons.net.au>
parents:
8
diff
changeset
|
192 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
193 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
|
194 now = time(NULL); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 } 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
|
199 struct timeval tv; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
200 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
|
201 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
|
202 goto out; |
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 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
205 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
|
206 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
|
207 settimeofday(&tv, NULL); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
208 } 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
|
209 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
|
210 } 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
|
211 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
|
212 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
|
213 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
|
214 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
215 } 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
|
216 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
|
217 } 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
|
218 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
|
219 } 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
|
220 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
|
221 } 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
|
222 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
|
223 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
|
224 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
225 } |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 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
|
230 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
|
231 } 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
|
232 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
|
233 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
|
234 goto out; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
235 } |
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
|
236 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 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
|
241 c = lcd_parsecol(argv[5][0]); |
13 | 242 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
243 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
|
244 } 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
|
245 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
|
246 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
|
247 goto out; |
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 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
256 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
|
257 } 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
|
258 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
|
259 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
|
260 delay(30); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
261 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
|
262 delay(60); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
263 } |
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
|
264 } 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
|
265 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
|
266 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
|
267 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
|
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 |
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 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
|
271 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
|
272 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
|
273 |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
274 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
|
275 } 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
|
276 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
|
277 } 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
|
278 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
|
279 int8_t i; |
13 | 280 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
281 memset(ROM, 0, 8); |
13 | 282 |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
283 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
|
284 do { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
285 switch (i) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
286 case OW_NOMODULES: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
287 case OW_FOUND: |
13 | 288 break; |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
289 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
290 case OW_BADWIRE: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
291 case OW_NOPRESENCE: |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
292 case OW_BADCRC: |
13 | 293 default: |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
294 printf("Err %d\n", i); |
13 | 295 break; |
296 } | |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
297 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
298 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
|
299 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
300 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
301 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
|
302 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
|
303 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
304 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
|
305 } while (1); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
306 } 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
|
307 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
|
308 } 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
|
309 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
|
310 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
|
311 goto out; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
312 } |
21
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
313 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
314 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
|
315 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
|
316 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
|
317 } 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
|
318 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
|
319 int16_t res; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
320 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
321 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
|
322 &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
|
323 &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
|
324 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
|
325 goto out; |
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 |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
328 res = OWGetTemp(ROM); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
329 switch (res) { |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
330 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
|
331 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
|
332 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
333 |
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_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
|
335 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
|
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_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
|
339 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
|
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 default: |
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("%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
|
344 break; |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
345 } |
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
|
346 } 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
|
347 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
|
348 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
|
349 |
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 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
|
351 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
|
352 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
|
353 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
|
354 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
|
355 //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
|
356 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
|
357 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
|
358 } |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
359 printf("Max err = %.3f\n", maxerr); |
22 | 360 } else if (!strcmp("assert", argv[0])) { |
361 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
|
362 } 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
|
363 sd_cmd(argc - 1, argv + 1); |
76
f1c9a51e368a
Add EEPROM emulation from AN2594.
Daniel O'Connor <darius@dons.net.au>
parents:
57
diff
changeset
|
364 } else if (!strcmp("ee", argv[0])) { |
f1c9a51e368a
Add EEPROM emulation from AN2594.
Daniel O'Connor <darius@dons.net.au>
parents:
57
diff
changeset
|
365 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
|
366 } 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
|
367 NVIC_SystemReset(); |
bd8e2cf04034
- Add flash erase, write & read commands (needs more work).
Daniel O'Connor <darius@dons.net.au>
parents:
19
diff
changeset
|
368 } else { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
45
diff
changeset
|
369 printf("Unknown command\n"); |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
2
diff
changeset
|
370 } |
8
58d76cf522ff
Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents:
7
diff
changeset
|
371 out: |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
372 cmd.state = 0; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
373 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
374 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
375 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
376 /* Configure interrupt controller */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
377 #ifdef VECT_TAB_RAM |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
378 /* 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
|
379 extern uint32_t _isr_vectorsram_offs; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
380 #else |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
381 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
|
382 #endif |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
383 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
384 void |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
385 NVIC_Configuration(void) { |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
386 NVIC_InitTypeDef NVIC_InitStructure; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
387 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
388 #ifdef VECT_TAB_RAM |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
389 /* 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
|
390 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
|
391 #else |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
392 /* 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
|
393 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
|
394 #endif |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
395 |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
396 /* Enable the USART1 Interrupt */ |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
397 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
398 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
399 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
400 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
|
401 |
b21db2b47a27
Enable DMA mode by initing DMA channel and enabling IRQ handler.
Daniel O'Connor <darius@dons.net.au>
parents:
49
diff
changeset
|
402 /* 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
|
403 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
|
404 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
|
405 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
|
406 NVIC_Init(&NVIC_InitStructure); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
407 } |
2
274e01fa5a4c
- Do console IO with RX IRQs.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
408 |