You are reading a single comment by @yngv126399 and its replies. Click here to read the full conversation.
  • I have Espruino running on a DT28 smartwatch (NRF52832) with its display removed. I've soldered wires to the main board to run an e-ink display, which works fine. The watch has an 8MB SPI flash chip which I've compiled in and it works, but with power issues. My first pass I was getting nothing back with every first call (call .list() get nothing, call it again, get file list). This sounded like it needed to be woken up, so I added the flag 'DEFINES += -DSPIFLASH_SLEEP_CMD', # SPI flash needs to be explicitly slept and woken up and it that stopped the errors, but now my battery dies in about 2 days (as opposed to 10 days without flash at all). I don't have an easy way to measure the power draw other than battery life (a 200mAh which I charger for 2 hours).

    BTW: SPI flash shares NO GPIOs with the display. It DOES share CLK/DATA with the accelerometer, but I do not initialize or use that at all (yet).

    All thoughts appreciated. Board file is

    import pinutils;
    
    info = {
     'name' : "DT28 smartwatch",
     'boardname' : 'DT28', # visible in process.env.BOARD
     'default_console' : "EV_BLUETOOTH",
     'variables' : 2565, 
     'bootloader' : 1,
     'binary_name' : 'e_%v_dt28.hex',
     'build' : {
       'optimizeflags' : '-Os',
       'libraries' : [
         'BLUETOOTH',
         'GRAPHICS',
         'JIT',
       ],
       'makefile' : [
     'DEFINES+=-DCONFIG_GPIO_AS_PINRESET', # Allow the display MOSI pin to work
         'DEFINES += -DCONFIG_NFCT_PINS_AS_GPIOS',
         'DEFINES+=-DNRF_BLE_GATT_MAX_MTU_SIZE=53­ -DNRF_BLE_MAX_MTU_SIZE=53', # increase MTU from default of 23
         'DEFINES+=-DUSE_FONT_6X8',
         'DEFINES += -DSPIFLASH_SLEEP_CMD', # SPI flash needs to be explicitly slept and woken up
         'DEFINES+=-DBLE_HIDS_ENABLED=1 -DBLUETOOTH_NAME_PREFIX=\'"DT28"\'',
         'DFU_PRIVATE_KEY=targets/nrf5x_dfu/dfu_p­rivate_key.pem',
         'NRF_BL_DFU_INSECURE=1',
         'DFU_SETTINGS=--application-version 0xff --hw-version 52 --sd-req 0x8C,0x91',
         'INCLUDE += -I$(ROOT)/libs/misc',c'
       ]
     }
    };
    
    
    save_code_pages = 20;
    chip = {
      'part' : "NRF52832",
      'family' : "NRF52",
      'package' : "QFN48",
      'ram' : 64,
     'flash' : 512,
      'speed' : 64,
      'usart' : 1,
      'spi' : 1,
      'i2c' : 1,
      'adc' : 1,
      'dac' : 0,
      'saved_code' : {
              'page_size' : 4096,
              #'address' : ((118 - save_code_pages) * 4096), # Bootloader at 0xF8000
              #'pages' : save_code_pages,
              'flash_available' : 512 - ((35 + 8 + 2)*4), # Softdevice 5.0  uses 35 pages of flash, bootloader 8, FS 2. Each page is 4 kb.
              'address' : 0x60000000, # put this in external spiflash (see below)
              'pages' : 2048, # 8MB of the 16MB external flash
       },
    };
    
    
    devices = {
     'BTN1' : { 'pin' : 'D29',  'pinstate' : 'IN_PULLDOWN'},
     'BTN2' : { 'pin' : 'D30',  'pinstate' : 'IN_PULLDOWN'},
     'BTN3' : { 'pin' : 'D31'},  # Fake button: bootloader wants THREE 
    
      #'VIBRATE' : { 'pin' : 'D22' }, # Pin negated in software
    
      #'LCD' : {  # unused for bootloader
    
     'SPIFLASH' : {
                'pin_sck' : 'D9',
                'pin_mosi' : 'D8',
                'pin_miso' : 'D7',
                'pin_cs' : 'D6',
                'size' : 8192*1024, # 16MB
                'memmap_base' : 0x60000000 # map into the address space (in software)
      }
    };
    
    # left-right, or top-bottom order
    board = {
      'left' : [ 'VDD', 'VDD', 'RESET', 'VDD','5V','GND','GND','','','D3','D4','­D28','D29','D30','D31'],
      'right' : [
         'D27', 'D26', 'D2', 'GND', 'D25','D24','D23', 'D22','D20','D19','',
         'D18','D17','D16','D15','D14','D13','D12­','D11','',
         'D10','D9','D8','D7','D6','D5','D21','D1­','D0'],
      '_notes' : {
        'D6' : "Serial console RX",
        'D8' : "Serial console TX"
      }
    };
    board["_css"] = """
    [#board](https://forum.espruino.com/sear­ch/?q=%23board) {
      width: 528px;
      height: 800px;
      top: 0px;
     left : 200px;
      background-image: url(img/NRF52832DK.jpg);
    }
    [#boardcontainer](https://forum.espruino­.com/search/?q=%23boardcontainer) {
      height: 900px;
    }
    [#left](https://forum.espruino.com/searc­h/?q=%23left) {
        top: 219px;
        right: 466px;
    }
    [#right](https://forum.espruino.com/sear­ch/?q=%23right) {
        top: 150px;
        left: 466px;
    }
    .leftpin { height: 17px; }
    .rightpin { height: 17px; }
    """;
    
    def get_pins():
      pins = pinutils.generate_pins(0,31) # 32 General Purpose I/O Pins.
      pinutils.findpin(pins, "PD2", True)["functions"]["ADC1_IN0"]=0;
      pinutils.findpin(pins, "PD3", True)["functions"]["ADC1_IN1"]=0;
      pinutils.findpin(pins, "PD4", True)["functions"]["ADC1_IN2"]=0;
      pinutils.findpin(pins, "PD5", True)["functions"]["ADC1_IN3"]=0;
      pinutils.findpin(pins, "PD28", True)["functions"]["ADC1_IN4"]=0;
      pinutils.findpin(pins, "PD29", True)["functions"]["ADC1_IN5"]=0;
    pinutils.findpin(pins, "PD30", True)["functions"]["ADC1_IN6"]=0;
      pinutils.findpin(pins, "PD31", True)["functions"]["ADC1_IN7"]=0;
      # Make buttons and LEDs negated
      pinutils.findpin(pins, "PD29", True)["functions"]["NEGATED"]=0;
      pinutils.findpin(pins, "PD30", True)["functions"]["NEGATED"]=0;
    
      # everything is non-5v tolerant
      for pin in pins:
        pin["functions"]["3.3"]=0;
      return pins
    
About

Avatar for yngv126399 @yngv126399 started