Skip to content

Commit e6b6af5

Browse files
committed
Merge pull request adafruit#111 from dhylands/teensy
Updated teensy to use common code from stm directory.
2 parents 6d6bc9e + 9b7b947 commit e6b6af5

20 files changed

Lines changed: 105 additions & 836 deletions

stm/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ SRC_C = \
3030
string0.c \
3131
malloc0.c \
3232
systick.c \
33-
lexerstm.c \
33+
lexerstr.c \
34+
lexerfatfs.c \
3435
led.c \
3536
lcd.c \
3637
servo.c \

stm/lexerstm.c renamed to stm/lexerfatfs.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,7 @@
55

66
#include "misc.h"
77
#include "lexer.h"
8-
#include "lexerstm.h"
9-
10-
unichar str_buf_next_char(mp_lexer_str_buf_t *sb) {
11-
if (sb->src_cur < sb->src_end) {
12-
return *sb->src_cur++;
13-
} else {
14-
return MP_LEXER_CHAR_EOF;
15-
}
16-
}
17-
18-
void str_buf_free(mp_lexer_str_buf_t *sb) {
19-
if (sb->free) {
20-
m_del(char, (char*)sb->src_beg, 0 /* don't know allocated size of src */);
21-
}
22-
}
23-
24-
mp_lexer_t *mp_lexer_new_from_str_len(const char *src_name, const char *str, uint len, bool free_str, mp_lexer_str_buf_t *sb) {
25-
sb->free = free_str;
26-
sb->src_beg = str;
27-
sb->src_cur = str;
28-
sb->src_end = str + len;
29-
return mp_lexer_new(src_name, sb, (mp_lexer_stream_next_char_t)str_buf_next_char, (mp_lexer_stream_close_t)str_buf_free);
30-
}
8+
#include "lexerfatfs.h"
319

3210
unichar file_buf_next_char(mp_lexer_file_buf_t *fb) {
3311
if (fb->pos >= fb->len) {

stm/lexerfatfs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
typedef struct _py_lexer_file_buf_t {
2+
FIL fp;
3+
char buf[20];
4+
uint16_t len;
5+
uint16_t pos;
6+
} mp_lexer_file_buf_t;
7+
8+
mp_lexer_t *mp_lexer_new_from_file(const char *filename, mp_lexer_file_buf_t *fb);

stm/lexerstm.h

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "misc.h"
55
#include "lexer.h"
6-
#include "lexerteensy.h"
6+
#include "lexerstr.h"
77

88
unichar str_buf_next_char(mp_lexer_str_buf_t *sb) {
99
if (sb->src_cur < sb->src_end) {
@@ -26,8 +26,3 @@ mp_lexer_t *mp_lexer_new_from_str_len(const char *src_name, const char *str, uin
2626
sb->src_end = str + len;
2727
return mp_lexer_new(src_name, sb, (mp_lexer_stream_next_char_t)str_buf_next_char, (mp_lexer_stream_close_t)str_buf_free);
2828
}
29-
30-
mp_lexer_t *mp_import_open_file(qstr mod_name) {
31-
printf("import not implemented\n");
32-
return NULL;
33-
}
File renamed without changes.

stm/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#include "nlr.h"
2020
#include "misc.h"
2121
#include "lexer.h"
22-
#include "lexerstm.h"
22+
#include "lexerstr.h"
23+
#include "lexerfatfs.h"
2324
#include "parse.h"
2425
#include "obj.h"
2526
#include "compile.h"

teensy/Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ LIBS = -L $(COMPILER_PATH)/../lib/gcc/arm-none-eabi/4.7.2/thumb2 -lgcc
2222

2323
SRC_C = \
2424
main.c \
25-
lexerteensy.c \
25+
lcd.c \
2626
led.c \
27+
lexerfatfs.c \
28+
usart.c \
29+
usb.c \
30+
31+
STM_SRC_C = \
32+
lexerstr.c \
2733
malloc0.c \
2834
printf.c \
2935
string0.c \
30-
usb.c \
3136

32-
SRC_S = \
37+
STM_SRC_S = \
3338
gchelper.s \
3439

3540
PY_O = \
@@ -90,7 +95,10 @@ SRC_TEENSY = \
9095
usb_serial.c \
9196
yield.c \
9297

93-
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(PY_O) $(SRC_TEENSY:.c=.o))
98+
STM_SRC_C_OBJ = $(STM_SRC_C:.c=.o)
99+
STM_SRC_S_OBJ = $(STM_SRC_S:.s=.o)
100+
101+
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C_OBJ) $(STM_SRC_S_OBJ) $(PY_O) $(SRC_TEENSY:.c=.o))
94102
#LIB = -lreadline
95103
# the following is needed for BSD
96104
#LIB += -ltermcap
@@ -117,10 +125,13 @@ $(PROG).elf: $(BUILD) $(OBJ)
117125
$(BUILD):
118126
mkdir -p $@
119127

120-
$(BUILD)/%.o: %.s
128+
$(BUILD)/%.o: %.c
129+
$(CC) $(CFLAGS) -c -o $@ $<
130+
131+
$(BUILD)/%.o: ../stm/%.s
121132
$(AS) -o $@ $<
122133

123-
$(BUILD)/%.o: %.c
134+
$(BUILD)/%.o: ../stm/%.c
124135
$(CC) $(CFLAGS) -c -o $@ $<
125136

126137
$(BUILD)/%.o: $(PYSRC)/%.S

teensy/README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ cd teensy
88
ARDUINO=~/arduino-1.0.5 make
99
```
1010

11-
To build the loader
12-
13-
```
14-
cd teensy/loader
15-
make
16-
```
17-
1811
To upload micropython to the Teensy 3.1.
1912

2013
Press the Program button on the Teensy 3.1
@@ -23,9 +16,3 @@ make upload
2316
```
2417

2518
Currently, the python prompt is through the USB serial interface.
26-
27-
The LED will blink (100 msec on/100 msec off) while waiting for the USB Serial
28-
device to be configured, and will blink (200 msec on/200 msec off) while
29-
sitting at the readline prompt.
30-
31-
Currently, there is no I/O support configured (no GPIO, ADC, etc).

teensy/gchelper.s

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)