Advertisement
Guest User

Untitled

a guest
Mar 1st, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.39 KB | None | 0 0
  1. #!/bin/false
  2. # This file is part of Espruino, a JavaScript interpreter for Microcontrollers
  3. #
  4. # Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
  5. #
  6. # This Source Code Form is subject to the terms of the Mozilla Public
  7. # License, v. 2.0. If a copy of the MPL was not distributed with this
  8. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. #
  10. # ----------------------------------------------------------------------------------------
  11. # This file contains information for a specific board - the available pins, and where LEDs,
  12. # Buttons, and other in-built peripherals are. It is used to build documentation as well
  13. # as various source and header files for Espruino.
  14. # ----------------------------------------------------------------------------------------
  15.  
  16. import pinutils;
  17.  
  18. info = {
  19.  'name' : "MDBT42Q Module",
  20.  'link' :  [ "http://www.espruino.com/MDBT42Q" ],
  21.  'espruino_page_link' : 'MDBT42Q',
  22.  'default_console' : "EV_SERIAL1",
  23.  'default_console_tx' : "D11",
  24.  'default_console_rx' : "D12",
  25.  'default_console_baudrate' : "9600",
  26.  'variables' : 2500, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
  27.  #'bootloader' : 1,
  28.  'binary_name' : 'espruino_%v_mdbt42q.hex',
  29.  'build' : {
  30.    'optimizeflags' : '-Os',
  31.    'libraries' : [
  32.      'BLUETOOTH',
  33.      'NET',
  34.      #'GRAPHICS',
  35.      #'CRYPTO','SHA256','SHA512',
  36.      #'AES',
  37.      #'NFC',
  38.      #'NEOPIXEL',
  39.      'FILESYSTEM'
  40.      #'TLS'
  41.    ],
  42.    'makefile' : [
  43.      'DEFINES+=-DHAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND=1', # Looks like proper production nRF52s had this issue
  44.      #'DEFINES+=-DCONFIG_GPIO_AS_PINRESET', # Allow the reset pin to work
  45.      'DEFINES+=-DBLUETOOTH_NAME_PREFIX=\'"MDBT42Q"\'',
  46.      #'DEFINES+=-DNEOPIXEL_SCK_PIN=23',
  47.      #'DFU_PRIVATE_KEY=targets/nrf5x_dfu/dfu_private_key.pem',
  48.      #'DFU_SETTINGS=--application-version 0xff --hw-version 52 --sd-req 0x8C'
  49.    ]
  50.  }
  51. };
  52.  
  53. chip = {
  54.   'part' : "NRF52832",
  55.   'family' : "NRF52",
  56.   'package' : "QFN48",
  57.   'ram' : 64,
  58.   'flash' : 512,
  59.   'speed' : 64,
  60.   'usart' : 1,
  61.   'spi' : 1,
  62.   'i2c' : 1,
  63.   'adc' : 1,
  64.   'dac' : 0,
  65.   'saved_code' : {
  66.     'address' : ((118 - 10) * 4096), # Bootloader takes pages 120-127, FS takes 118-119
  67.     'page_size' : 4096,
  68.     'pages' : 10,
  69.     'flash_available' : 512 - ((31 + 8 + 2 + 10)*4) # Softdevice uses 31 pages of flash, bootloader 8, FS 2, code 10. Each page is 4 kb.
  70.   },
  71. };
  72.  
  73. devices = {
  74.   'LED1' : { 'pin' : 'D1' },
  75.   'LED2' : { 'pin' : 'D2', 'no_bootloader':True }, # don't use LED2 in the bootloader since we may be using a bare module
  76.   'BTN1' : { 'pin' : 'D0', 'pinstate' : 'IN_PULLDOWN' },
  77.   'NFC': { 'pin_a':'D9', 'pin_b':'D10' },
  78.   # Pin D23 is used for clock when driving neopixels - as not specifying a pin seems to break things
  79. };
  80.  
  81. # left-right, or top-bottom order
  82. board_module = {
  83.   'left' : [ 'GND','','','','D25','D26','D27','D28','D29','D30','D31','DEC4','DCC','VDD'],
  84.   'right2' : [ 'D24', '', 'D23'],
  85.   'right' : [ 'GND','D22','SWDIO','SWDCLK','D21','D20','D19','D18','D17','D16','D15','D14','D13','D12','D11' ],
  86.   'bottom' : [ 'GND','D0','D1','D2','D3','D4','D5','D6','D7','D8','D9','D10','GND' ],
  87.   '_notes' : {
  88.     'D21' : "Also NRST if configured",
  89.     'D23' : "This is used as SCK when driving Neopixels with 'require('neopixel').write'. This pin is not accessible.",
  90.   }
  91. };
  92.  
  93. board_module["_css"] = """
  94. #board {
  95.  width: 359px;
  96.  height: 484px;
  97.  top: 0px;
  98.  left : 200px;
  99.  background-image: url(img/MDBT42Q.jpg);
  100. }
  101. #boardcontainer {
  102.  height: 650px;
  103. }
  104. #board #bottom {
  105.    top: 440px;
  106.    left: 56px;
  107. }
  108. #board #left {
  109.    top: 115px;
  110.    right: 316px;
  111. }
  112. #board #right2 {
  113.    top: 115px;
  114.    right: 110px;
  115. }
  116. #board #right {
  117.    top: 115px;
  118.    left: 316px;
  119. }
  120.  
  121. #board .leftpin { height: 17px; }
  122. #board .left2pin { height: 17px; }
  123. #board .rightpin { height: 17px; }
  124. #board .bottompin { width: 15px; padding:0px; }
  125. """;
  126.  
  127. board_breakout = {
  128.   'left' : [ 'D25','D26','D27','D28','D29','D30','D31','D3','D4','D5','D11' ],
  129.   'right' : [ 'D22','D20','D19','D18','D17','D16','D15','D14','3.3','Vin','GND'],
  130.   'bottom' : [ 'D6','D8','D7','Vin','GND' ],
  131.   'top' : [ 'D9','D10' ],
  132.   '_hide_not_on_connectors' : True,
  133.   '_class' : "board_breakout",
  134.   '_notes' : {
  135.     'D12' : "Serial Console RX when Bluetooth disconnected",
  136.     'D11' : "Serial Console TX when Bluetooth disconnected",    
  137.   }
  138. };
  139.  
  140. board_breakout["_css"] = """
  141. #board {
  142.  width: 255px;
  143.  height: 400px;
  144.  top: 0px;
  145.  left : 200px;
  146.  background-image: url(img/MDBT42Q_BREAKOUT.png);
  147. }
  148. #boardcontainer {
  149.  height: 600px;
  150. }
  151. #board #bottom {
  152.    top: 410px;
  153.    left: 40px;
  154. }
  155. #board #top {
  156.    bottom: 75px;
  157.    left: 167px;
  158. }
  159. #board #left {
  160.    top: 17px;
  161.    right: 256px;
  162. }
  163. #board #right {
  164.    top: 17px;
  165.    left: 256px;
  166. }
  167.  
  168. #board .leftpin { height: 33px; }
  169. #board .rightpin { height: 33px; }
  170. #board .toppin { width: 15px; padding:0px; }
  171. #board .bottompin { width: 31px; padding:0px; }
  172. """;
  173.  
  174. boards = [board_module, board_breakout];
  175.  
  176.  
  177. def get_pins():
  178.   pins = pinutils.generate_pins(0,31) # 32 General Purpose I/O Pins.
  179.   pinutils.findpin(pins, "PD0", True)["functions"]["XL1"]=0;
  180.   pinutils.findpin(pins, "PD1", True)["functions"]["XL2"]=0;
  181.   pinutils.findpin(pins, "PD9", True)["functions"]["NFC1"]=0;
  182.   pinutils.findpin(pins, "PD10", True)["functions"]["NFC2"]=0;
  183.   pinutils.findpin(pins, "PD2", True)["functions"]["ADC1_IN0"]=0;
  184.   pinutils.findpin(pins, "PD3", True)["functions"]["ADC1_IN1"]=0;
  185.   pinutils.findpin(pins, "PD4", True)["functions"]["ADC1_IN2"]=0;
  186.   pinutils.findpin(pins, "PD5", True)["functions"]["ADC1_IN3"]=0;
  187.   pinutils.findpin(pins, "PD28", True)["functions"]["ADC1_IN4"]=0;
  188.   pinutils.findpin(pins, "PD6", True)["functions"]["ADC1_IN8"]=0;
  189.   pinutils.findpin(pins, "PD8", True)["functions"]["ADC1_IN9"]=0;
  190.   pinutils.findpin(pins, "PD11", True)["functions"]["USART1_TX"]=0;
  191.   pinutils.findpin(pins, "PD12", True)["functions"]["USART1_RX"]=0;
  192.   pinutils.findpin(pins, "PD29", True)["functions"]["ADC1_IN5"]=0;
  193.   pinutils.findpin(pins, "PD30", True)["functions"]["ADC1_IN6"]=0;
  194.   pinutils.findpin(pins, "PD31", True)["functions"]["ADC1_IN7"]=0;
  195.   # everything is non-5v tolerant
  196.   for pin in pins:
  197.     pin["functions"]["3.3"]=0;
  198.  
  199.   #The boot/reset button will function as a reset button in normal operation. Pin reset on PD21 needs to be enabled on the nRF52832 device for this to work.
  200.   return pins
  201.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement