forked from espruino/Espruino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MICROBIT1.py
158 lines (148 loc) · 6.57 KB
/
MICROBIT1.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
#!/bin/false
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2015 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;
# placeholder
info = {
'name' : "BBC micro:bit 1",
'link' : [ "https://en.wikipedia.org/wiki/Micro_Bit" ],
'espruino_page_link' : 'MicroBit',
'default_console' : "EV_SERIAL1",
'default_console_tx' : "H0", # pin 24
'default_console_rx' : "H1", # pin 25
'default_console_baudrate' : "9600",
'variables' : 350,
'binary_name' : 'espruino_%v_microbit1.hex',
'build' : {
'optimizeflags' : '-Os',
'libraries' : [
'BLUETOOTH',
'GRAPHICS',
],
'makefile' : [
'SAVE_ON_FLASH=1',
'DEFINES+=-DSAVE_ON_FLASH_EXTREME',
'DEFINES+=-DESPR_PACKED_SYMPTR', # Pack builtin symbols' offset into pointer to save 2 bytes/symbol
'DEFINES+=-DESPR_NO_DAYLIGHT_SAVING',
'DEFINES+=-DJSVAR_FORCE_NO_INLINE=1',
'CFLAGS += -ffreestanding', # needed for SAVE_ON_FLASH_EXTREME (jswrap_math, __aeabi_dsub)
'ASFLAGS += -D__STARTUP_CLEAR_BSS -D__START=main',
'LDFLAGS += -nostartfiles',
'BLACKLIST=boards/MICROBIT1.blocklist', # force some stuff to be removed to save space
'DEFINES+=-DCONFIG_GPIO_AS_PINRESET', # Allow the reset pin to work
'DEFINES += -DMICROBIT', # enable microbit-specific stuff
'DEFINES+=-DNO_DUMP_HARDWARE_INITIALISATION', # don't dump hardware init - not used and saves a bunch of flash
'DEFINES+=-DUSE_TAB_COMPLETE',
'USE_DEBUGGER=0', # Removed due to firmware size issues
'INCLUDE += -I$(ROOT)/libs/microbit',
'WRAPPERSOURCES += libs/microbit/jswrap_microbit.c',
]
}
};
saved_code_pages = 4;
chip = {
'part' : "NRF51822",
'family' : "NRF51",
'package' : "QFN48",
'ram' : 16,
'flash' : 256,
'speed' : 16,
'usart' : 1,
'spi' : 0,
'i2c' : 1,
'adc' : 0,
'dac' : 0,
# If using DFU bootloader, it sits at 0x3C000 - 0x40000 (0x40000 is end of flash)
# Might want to change 256 -> 240 in the code below
'saved_code' : {
'address' : ((256 - saved_code_pages) * 1024),
'page_size' : 1024,
'pages' : saved_code_pages,
'flash_available' : (256 - 108 - saved_code_pages) # total flash pages - softdevice - saved code
}
};
devices = {
'BTN1' : { 'pin' : 'D5', 'pinstate' : 'IN_PULLDOWN' }, # 'P0_17' - Pin negated in software
'BTN2' : { 'pin' : 'D11', 'pinstate' : 'IN_PULLDOWN' }, # 'P0_26' - Pin negated in software
# 'V' pins are virtual
'LED1' : { 'pin' : 'V0' },
};
# left-right, or top-bottom order
board = {
'bottom' : [ 'D3', '','D0','','D4','D5','D6','D7','','D1','','D8','D9','D10','D11','D12','','D2','',
'D13','D14','D15','D16','3.3','','3.3','','3.3','D19','D20','GND','','GND','','GND' ],
'_hide_not_on_connectors' : True,
'_notes' : {
'D3' : "LED Col 1",
'D4' : "LED Col 2",
'D6' : "LED Col 9",
'D7' : "LED Col 8",
'D9' : "LED Col 7",
'D10' : "LED Col 3"
}
};
board["_css"] = """
#board {
width: 659px;
height: 562px;
top: 0px;
left : 0px;
background-image: url(img/MICROBIT1.jpg);
}
#boardcontainer {
height: 700px;
}
#bottom {
top: 490px;
left: 52px;
}
.bottompin { width: 10px; }
""";
# Display is on:
# real NRF pins 4,5,6,7,8,9,10,11,12 (column pull down)
# real NRF pins 13,14,15 (row pull up)
def get_pins():
pins = [
{ "name":"PD0", "sortingname":"D00", "port":"D", "num":"1", "functions":{ "ADC1_IN2":0 }, "csv":{} },
{ "name":"PD1", "sortingname":"D01", "port":"D", "num":"2", "functions":{ "ADC1_IN3":0 }, "csv":{} },
{ "name":"PD2", "sortingname":"D02", "port":"D", "num":"3", "functions":{ "ADC1_IN4":0 }, "csv":{} },
{ "name":"PD3", "sortingname":"D03", "port":"D", "num":"4", "functions":{ "ADC1_IN5":0 }, "csv":{} }, # LED col 1
{ "name":"PD4", "sortingname":"D04", "port":"D", "num":"5", "functions":{ "ADC1_IN6":0 }, "csv":{} }, # BTNA
{ "name":"PD5", "sortingname":"D05", "port":"D", "num":"17", "functions":{}, "csv":{} }, # LED col 2
{ "name":"PD6", "sortingname":"D06", "port":"D", "num":"12", "functions":{}, "csv":{} }, # LED row 2
{ "name":"PD7", "sortingname":"D07", "port":"D", "num":"11", "functions":{}, "csv":{} }, # LED row 1
{ "name":"PD8", "sortingname":"D08", "port":"D", "num":"18", "functions":{}, "csv":{} },
{ "name":"PD9", "sortingname":"D09", "port":"D", "num":"10", "functions":{}, "csv":{} }, # LED row 3
{ "name":"PD10", "sortingname":"D10", "port":"D", "num":"6", "functions":{ "ADC1_IN7":0 }, "csv":{} }, # LED col 3
{ "name":"PD11", "sortingname":"D11", "port":"D", "num":"26", "functions":{ "ADC1_IN0":0 }, "csv":{} }, # BTNB
{ "name":"PD12", "sortingname":"D12", "port":"D", "num":"20", "functions":{}, "csv":{} },
{ "name":"PD13", "sortingname":"D13", "port":"D", "num":"23", "functions":{ "SPI1_SCK":0 }, "csv":{} },
{ "name":"PD14", "sortingname":"D14", "port":"D", "num":"22", "functions":{ "SPI1_MISO":0 }, "csv":{} },
{ "name":"PD15", "sortingname":"D15", "port":"D", "num":"21", "functions":{ "SPI1_MOSI":0 }, "csv":{} },
{ "name":"PD16", "sortingname":"D16", "port":"D", "num":"16", "functions":{}, "csv":{} },
{ "name":"PD17", "sortingname":"D17", "port":"D", "num":"31", "functions":{}, "csv":{} }, # FIXME 3.3v
{ "name":"PD18", "sortingname":"D18", "port":"D", "num":"31", "functions":{}, "csv":{} }, # FIXME 3.3v
{ "name":"PD19", "sortingname":"D19", "port":"D", "num":"0", "functions":{ "I2C1_SCL":0, "ADC1_IN0":0 }, "csv":{} },
{ "name":"PD20", "sortingname":"D20", "port":"D", "num":"30", "functions":{ "I2C1_SDA":0 }, "csv":{} },
{ "name":"PH0", "sortingname":"H0", "port":"D", "num":"24", "functions":{}, "csv":{} },
{ "name":"PH1", "sortingname":"H1", "port":"D", "num":"25", "functions":{}, "csv":{} },
{ "name":"PV0", "sortingname":"V0", "port":"V", "num":"0", "functions":{}, "csv":{} }
];
# Make buttons negated
pinutils.findpin(pins, "PD5", True)["functions"]["NEGATED"]=0;
pinutils.findpin(pins, "PD11", True)["functions"]["NEGATED"]=0;
# everything is non-5v tolerant
for pin in pins:
pin["functions"]["3.3"]=0;
return pins