-
-
Notifications
You must be signed in to change notification settings - Fork 755
/
Copy pathPIPBOY.py
199 lines (193 loc) · 8.69 KB
/
PIPBOY.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/false
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2013 Gordon Williams <[email protected]>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# ----------------------------------------------------------------------------------------
# This file contains information for a specific board - the available pins, and where LEDs,
# Buttons, and other in-built peripherals are. It is used to build documentation as well
# as various source and header files for Espruino.
# ----------------------------------------------------------------------------------------
import pinutils;
info = {
'name' : "Fallout TV series Pip-Boy",
'link' : [ "https://www.thewandcompany.com/fallout-pip-boy" ],
'variables' : 5000, # 5000 -> 65k for vars (we have 128k main memory, but 40k is the stream buffer)
'binary_name' : 'espruino_%v_pipboy.bin',
'default_console' : "EV_SERIAL3",
'default_console_tx' : "B10",
'default_console_rx' : "B11",
'default_console_baudrate' : "115200",
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'xoff_thresh' : 3,
'xon_thresh' : 2,
'build' : {
'optimizeflags' : '-Os',
'libraries' : [
'USB_HID',
'GRAPHICS',
'LCD_FSMC',
'FILESYSTEM',
'FILESYSTEM_SDIO',
'JIT'
],
'makefile' : [
'DEFINES+=-DUSE_USB_OTG_FS=1',
'DEFINES+=-DUSE_RTC',
#'DEFINES+=-DESPR_MIN_WFI_TIME_MS=200', # delays when we enter __WFI sleep - but we don't need this after #2575
'DEFINES+=-DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DGRAPHICS_ANTIALIAS -DESPR_PBF_FONTS -DESPR_GRAPHICS_INTERNAL -DESPR_GRAPHICS_SELF_INIT -DESPR_GRAPHICS_NO_SPLASH -DGRAPHICS_FAST_PATHS',
'DEFINES+=-DESPR_SDIO_FAST_UNALIGNED', # see sdio_diskio.c - this is a nasty hack to increase unaligned read speed
'DEFINES+=-DLCD_ORIENTATION_LANDSCAPE',
'DEFINES+=-DESPR_FS_MKFS -DESPR_FS_GETFREE',
'DEFINES+=-DUSE_AUDIO_CODEC',
'DEFINES+=-DESPR_DELAY_MULTIPLIER=28672', # don't work out what to use for jshDelayMicroseconds at boot, just hard-code it
'DEFINES+=-DESPR_RTC_INITIALISE_TICKS=30', # 168Mhz so we need to wait more ticks for the RTC to init (21->2s doesn't seem to be enough - this is nearer 3s!)
'DEFINES+=-DESPR_RTC_ALWAYS_TRY_LSE', # If we boot and RTC is initialised but using LSI, try again at starting LSE
'DEFINES+=-DESPR_FS_LARGE_WRITE_BUFFER', # speeds up SD card writes ~3x
'DEFINES+=-DESPR_LCD_MANUAL_BACKLIGHT', # Pipboy handles LCD backlight on/off so we can reduce flicker
'DEFINES+=-DESPR_DISABLE_KICKWATCHDOG_PIN=BTN10_PININDEX', # If the power button is held, don't kick watchdog so we reboot
'DEFINES+=-DESPR_OFFICIAL_BOARD', # Don't display the donations nag screen
'STLIB=STM32F407xx',
'-DHSE_VALUE=9000000',
# 'DEFINES+=-DFSMC_BITBANG',
'PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f4/lib/startup_stm32f40_41xxx.o',
'TARGETSOURCES+=targetlibs/stm32f4/lib/stm32f4xx_fsmc.c',
'INCLUDE += -I$(ROOT)/libs/pipboy',
'WRAPPERSOURCES += libs/pipboy/avi.c libs/pipboy/stm32_i2s.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_pipboy.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_font_monofonto_120.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_font_monofonto_96.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_font_monofonto_36.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_font_monofonto_28.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_font_monofonto_23.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_font_monofonto_18.c',
'WRAPPERSOURCES += libs/pipboy/jswrap_font_monofonto_16.c',
'DEFINES+=-DUSBD_MANUFACTURER_STRING=\'"The Wand Company"\'',
'DEFINES+=-DUSBD_PRODUCT_STRING_FS=\'"Pip-Boy"\'',
'DEFINES+=-DUSB_PRODUCT_ID=0xA4F1', # 0xA4F1 assigned by ST for the Pip-Boy (0xA4DF = Tricorder)
# 'USE_DFU=1'
]
}
};
chip = {
'part' : "STM32F407VE",
'family' : "STM32F4",
'package' : "LQFP100",
'ram' : 192,
'flash' : 512,
# 'flash_base' : 0x08000000,
'speed' : 168,
'usart' : 6,
'spi' : 3,
'i2c' : 3,
'adc' : 3,
'dac' : 2,
'saved_code' : { # last page
'address' : 0x08060000,
'page_size' : 131072, # size of pages
'pages' : 1, # number of pages we're using
'flash_available' : 384 # Saved code is after binary
},
};
devices = {
'OSC' : { 'pin_1' : 'H0',
'pin_2' : 'H1' },
'OSC_RTC' : { 'pin_1' : 'C14',
'pin_2' : 'C15' },
'LED1' : { 'pin' : 'E4', 'pinstate' : 'OUT_OPENDRAIN' }, # Red element of RGB LED - needs to be open-drain otherwise we can't turn it off completely
'LED2' : { 'pin' : 'E5' }, # Green element of RGB LED
'LED3' : { 'pin' : 'E6' }, # Blue element of RGB LED
'LED4' : { 'pin' : 'E3' }, # Radio tuning indicator LED
'BTN1' : { 'pin' : 'A1' }, # "Play" button
'BTN2' : { 'pin' : 'E1' }, # "Up" button
'BTN3' : { 'pin' : 'E2' }, # "Down" button
'BTN4' : { 'pin' : 'A2' }, # "Flashlight" button
'BTN5' : { 'pin' : 'A10' }, # Thumbwheel encoder A - PA9 for v0.3, PA10 for v0.5 and later
'BTN6' : { 'pin' : 'A8' }, # Thumbwheel encoder B
'BTN7' : { 'pin' : 'A3' }, # Clock "select" button
'BTN8' : { 'pin' : 'B1' }, # Clock encoder A
'BTN9' : { 'pin' : 'B0' }, # Clock encoder B
'BTN10' : { 'pin' : 'A0' }, # "Power" button
'BAT' : {
'pin_sense_en' : 'C4',
'pin_voltage' : 'A6',
'pin_charging' : 'C5',
},
'SD' : { 'pin_cmd' : 'D2',
'pin_d0' : 'C8',
'pin_d1' : 'C9',
'pin_d2' : 'C10',
'pin_d3' : 'C11',
'pin_clk' : 'C12',
'pin_cd' : 'A15', # SD card detect switch - doesn't work on hardware v0.3
'pin_pwr' : 'D3'}, # SD card power supply enable (also switches power to the ES8388 audio codec)
'LCD' : {
'width' : 480, 'height' : 320, 'bpp' : 16, 'controller' : 'fsmc',
'pin_d0' : 'D14',
'pin_d1' : 'D15',
'pin_d2' : 'D0',
'pin_d3' : 'D1',
'pin_d4' : 'E7',
'pin_d5' : 'E8',
'pin_d6' : 'E9',
'pin_d7' : 'E10',
'pin_d8' : 'E11',
'pin_d9' : 'E12',
'pin_d10' : 'E13',
'pin_d11' : 'E14',
'pin_d12' : 'E15',
'pin_d13' : 'D8',
'pin_d14' : 'D9',
'pin_d15' : 'D10',
'pin_rs' : 'D11',
'pin_rd' : 'D4',
'pin_wr' : 'D5',
'pin_cs' : 'D7', # CS / NE1
'pin_bl' : 'B15', # backlight
'pin_tearing' : 'D12' # tearing effect output from LCD controller - planned for PCB v0.7
},
'SPIFLASH' : {
'pin_cs' : 'B14',
'pin_sck' : 'B3',
'pin_mosi' : 'B5',
'pin_miso' : 'B4',
'size' : 4096*64,
# Don't enable the memory mapping - STM32 doesn't do this, but it does cause extra stuff to be added to jsvariterator which can slow it down
# 'memmap_base' : 0x60000000 # map into the address space (in software) - FIXME: what should this address be?
},
'USB' : { 'pin_vsense' : 'A9', # PA5 for v0.3, PA9 for v0.5 and later
'pin_dm' : 'A11',
'pin_dp' : 'A12' },
'JTAG' : {
'pin_MS' : 'A13',
'pin_CK' : 'A14',
},
};
# left-right, or top-bottom order
board = {
};
board["_css"] = """
""";
def get_pins():
pins = pinutils.scan_pin_file([], 'stm32f40x.csv', 6, 9, 10)
pins = pinutils.scan_pin_af_file(pins, 'stm32f405_af.csv', 0, 1) # F405 is close enough to the F407
pins = pinutils.only_from_package(pinutils.fill_gaps_in_pin_list(pins), chip["package"])
pinutils.findpin(pins, "PE4", True)["functions"]["NEGATED"]=0; # LED1
pinutils.findpin(pins, "PE5", True)["functions"]["NEGATED"]=0; # LED2
pinutils.findpin(pins, "PE6", True)["functions"]["NEGATED"]=0; # LED3
pinutils.findpin(pins, "PE3", True)["functions"]["NEGATED"]=0; # LED4
pinutils.findpin(pins, "PA1", True)["functions"]["NEGATED"]=0; # BTN1
pinutils.findpin(pins, "PE1", True)["functions"]["NEGATED"]=0; # BTN2
pinutils.findpin(pins, "PE2", True)["functions"]["NEGATED"]=0; # BTN3
pinutils.findpin(pins, "PA2", True)["functions"]["NEGATED"]=0; # BTN4
pinutils.findpin(pins, "PA10", True)["functions"]["NEGATED"]=0; # BTN5 - PA9 for v0.3, PA10 for v0.5 and later
pinutils.findpin(pins, "PA8", True)["functions"]["NEGATED"]=0; # BTN6
pinutils.findpin(pins, "PA3", True)["functions"]["NEGATED"]=0; # BTN7
pinutils.findpin(pins, "PB1", True)["functions"]["NEGATED"]=0; # BTN8
pinutils.findpin(pins, "PB0", True)["functions"]["NEGATED"]=0; # BTN9
pinutils.findpin(pins, "PA0", True)["functions"]["NEGATED"]=0; # BTN10
return pins