Skip to content

Commit a767ff4

Browse files
tofergreggCS107E Bot
authored and
CS107E Bot
committed
added screencast link to lecture 7
commit 20f9168a5422fc13785dc0543a5adf1d5fceb959 Author: Chris Gregg <[email protected]> Date: Mon Oct 15 20:57:45 2018 -0700 added screencast link to lecture 7
1 parent ba324b0 commit a767ff4

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

_includes/schedule.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
</tr>
147147
<tr>
148148
<td>Lecture 7 (Mon): Communication and the Serial Protocol
149-
(<a href="lectures/07-Serial/serial.pdf">slides</a>--><!--, <a href="https://www.youtube.com/watch?v=NSX4izsY55I">screencast</a>-->, <a href="https://github.com/cs107e/cs107e.github.io/tree/master/lectures/Serial/code">code</a>)
149+
(<a href="lectures/07-Serial/serial.pdf">slides</a>, <a href="https://youtu.be/LErUamayHQk">screencast</a>, <a href="https://github.com/cs107e/cs107e.github.io/tree/master/lectures/Serial/code">code</a>)
150150
</td>
151151
<td>Read about characters and strings, basic IO (getc, putc, puts, printf), and structures (Section 1.5, 1.6, 1.9, 5.5, 6, 7 in K&amp;R; Section 3 in EssentialC).
152152
Read about <a href="https://learn.sparkfun.com/tutorials/serial-communication/all">Serial Communication</a>.

lectures/07_Serial/code/sos/sos.c

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include "gpio.h"
2+
#include "timer.h"
3+
4+
#define PIN 20
5+
#define ONE_SECOND 1000
6+
#define DELAY_MORSE (ONE_SECOND/4)
7+
8+
void morse_s();
9+
void morse_o();
10+
void dot();
11+
void dash();
12+
void morse_letter(char *code); // "--..-."
13+
14+
void dot() {
15+
gpio_write(PIN,1);
16+
timer_delay_ms(DELAY_MORSE);
17+
gpio_write(PIN,0);
18+
timer_delay_ms(DELAY_MORSE);
19+
}
20+
21+
void dash() {
22+
gpio_write(PIN,1);
23+
timer_delay_ms(DELAY_MORSE * 3);
24+
gpio_write(PIN,0);
25+
timer_delay_ms(DELAY_MORSE);
26+
}
27+
28+
void morse_s() {
29+
morse_letter("...");
30+
}
31+
32+
void morse_o() {
33+
morse_letter("---");
34+
}
35+
36+
void morse_letter(char *code) {
37+
while (*code) {
38+
*code++ == '.' ? dot() : dash();
39+
}
40+
}
41+
42+
void main(void) {
43+
timer_init();
44+
gpio_init();
45+
gpio_set_output(PIN);
46+
47+
while (1) {
48+
// flash SOS
49+
morse_s();
50+
morse_o();
51+
morse_s();
52+
timer_delay_ms(DELAY_MORSE * 4);
53+
}
54+
}

0 commit comments

Comments
 (0)