Skip to content

Instantly share code, notes, and snippets.

Avatar

fanoush fanoush

View GitHub Profile
@fanoush
fanoush / E104_BT5032A.py
Last active Nov 1, 2020
E104-BT5032A board file
View E104_BT5032A.py
#!/bin/false
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
#
# 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/.
#
# ----------------------------------------------------------------------------------------
View WeActF411.diff
diff --git a/targetlibs/stm32f4/lib/stm32f4xx_conf.h b/targetlibs/stm32f4/lib/stm32f4xx_conf.h
index 2f33cd4f..885f551f 100755
--- a/targetlibs/stm32f4/lib/stm32f4xx_conf.h
+++ b/targetlibs/stm32f4/lib/stm32f4xx_conf.h
@@ -26,7 +26,7 @@
#if defined (HSE_VALUE)
/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
#undef HSE_VALUE
- #define HSE_VALUE ((uint32_t)8000000)
+ #define HSE_VALUE ((uint32_t)25000000)
@fanoush
fanoush / WeActF411.py
Last active Nov 13, 2020
WeAct F411 Espruino board file
View WeActF411.py
#!/bin/false
# -*- coding: utf8 -*-
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
#
# 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/.
#
@fanoush
fanoush / B5-demo.js
Last active Oct 16, 2020
Espruino demo code for SMA B5 smart band with GPS
View B5-demo.js
E.kickWatchdog();
function KickWd(){
if( (typeof(BTN1)=='undefined')||(!BTN1.read()) ) E.kickWatchdog();
}
var wdint=setInterval(KickWd,2000);
E.enableWatchdog(15, false);
// MIT License (c) 2020 fanoush https://github.com/fanoush
// see full license text at https://choosealicense.com/licenses/mit/
// SPI display driver below compiled with options LCD_BPP=12
View espruino-bootloader.diff
diff --git a/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c b/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c
index 6da88aa9..5ba66f3d 100644
--- a/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c
+++ b/targetlibs/nrf5x_12/components/libraries/bootloader/dfu/nrf_dfu_utils.c
@@ -461,10 +461,11 @@ uint32_t nrf_dfu_continue(uint32_t * p_enter_dfu_mode)
bool nrf_dfu_app_is_valid(void)
{
NRF_LOG_INFO("Enter nrf_dfu_app_is_valid\r\n");
- if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP &&
+ if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP ^M
@fanoush
fanoush / DK08.js
Last active Nov 4, 2020
DK08 demo
View DK08.js
function KickWd(){
if(!BTN1.read())E.kickWatchdog();
}
var wdint=setInterval(KickWd,5000); // 5 secs
E.enableWatchdog(20, false); // 20 secs
E.kickWatchdog();
/*
// MIT License (c) 2020 fanoush https://github.com/fanoush
// see full license text at https://choosealicense.com/licenses/mit/
var SPI2 = E.compiledC(`
View F07-espruino-demo.js
E.kickWatchdog();
function KickWd(){
if( (typeof(BTN1)=='undefined')||(!BTN1.read()) ) E.kickWatchdog();
}
var wdint=setInterval(KickWd,1000);
E.enableWatchdog(10, false);
var SPI2 = (function(){
var bin=atob("AAAAAAAAAAAAAAAA/////////////////////wAAAAAAAAAAELUDTHxEIoBggKGA44AQvdT///8HS3tEm2hDsQRKE2gAK/zQACMTYANKekSTYHBHGDECQML///+u////LenwR5BGGUwZTv/35f8ZSt/4ZMAAIwElE2BP8P8OU2CpRiNgEDIfRv8pAOsDCsL4AKCLv/8zMWDG+ADgACGIv/85zPgAkLjxAA8G0Cm5C0t7RJ1gACC96PCH1PgAoLrxAA/60CdgACne0fPnGDECQEg1AkA0NQJAEDACQEz///8t6fBPm7DN6QASBJNDS3tEBkaT+ACQACh90AApe9AJ8f8yByp32AEiAvoJ8gE60rIEeAKSQniT+ASwBZNE6gIkAZqHHAirEagUQc3pBjBP6kkC0rJP8AAIpLIDkkFGBZsBnZP4AqACmwCaI0BE+gn0MvgTwAKbI0BE+gn0MvgTIAObHUTtsgctgb8IPRf4ATvtssXxCA6EvwP6DvMcQ0/qLBNDVBMSAfECDkPqDBxDGAMxqvECCiMpg/gBwKSyAPgOIF/6ivoJ3QEi//dZ/9jxAQgLvweYBphBRgAhuvEAD8HRD0t7RNuIHkS3HHN4NHhE6gMkAZscQQvx/zMT8P8LpLKs0RmxBJr/9zr/WUYIRhuwvejwj0/w/zH45w7///84/v//H7XDssDzBxIACkDqAxDAsgApjfgFAI34CACN+AsAjfgOAAhGuL/IHY34BCCN+AYwjfgHII34CTCN+AogjfgMMI34DSCN+A8wwBD/9/P+EksSTAAiGmBaYKPyHE
View generic SDK11 single bank bootloader for SOftDevice S132 2.x and address 0x7a000
// -- 1. copy paste methods for flash writing and verification below to Espruino WebIDE left side
E.setFlags({unsafeFlash:1});
var fl=require("Flash");
var ladd=0;var lpg=0;var nadd=0;// last address, last page addr, next addr
var flash=function(a,d){
if (nadd>0 && nadd<a) console.log("Hole in data, got "+a.toString(16)+", expected "+nadd.toString(16));
var p=fl.getPage(a).addr;
if (p>lpg) {fl.erasePage(p);lpg=p;console.log("Erasing page 0x"+p.toString(16));}
p=fl.getPage(a+d.length-1).addr;
if (p>lpg) {fl.erasePage(p);lpg=p;console.log("Erasing page 0x"+p.toString(16));}
View NRF.onRestart.patch
diff --git a/targets/nrf5x/bluetooth.c b/targets/nrf5x/bluetooth.c
index e5aa77d5..5f15e041 100644
--- a/targets/nrf5x/bluetooth.c
+++ b/targets/nrf5x/bluetooth.c
@@ -2489,6 +2489,7 @@ void jsble_restart_softdevice() {
jshUtilTimerDisable(); // don't want the util timer firing during this!
JsSysTime lastTime = jshGetSystemTime();
jsble_kill();
+ jsvUnLock(jspEvaluate("if(typeof(NRF.onRestart)=='function')NRF.onRestart();",true));
jsble_init();
@fanoush
fanoush / P8-SPILCD-demo.js
Last active Oct 11, 2020
Inline C P8 LCD DMA demo
View P8-SPILCD-demo.js
E.kickWatchdog();
function KickWd(){
if( (typeof(BTN1)=='undefined')||(!BTN1.read()) ) E.kickWatchdog();
}
var wdint=setInterval(KickWd,2000);
E.enableWatchdog(15, false);
/*
// MIT License (c) 2020 fanoush https://github.com/fanoush
// see full license text at https://choosealicense.com/licenses/mit/
var SPI2 = E.compiledC(`
You can’t perform that action at this time.