mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
add WioLTE utility class for Seeed WIO board, allow 'make flash' to use DFU for board
This commit is contained in:
parent
99a179d772
commit
d3c59d2d74
7
Makefile
7
Makefile
@ -609,6 +609,13 @@ ifdef USE_HEXBADGE
|
||||
WRAPPERSOURCES += libs/hexbadge/jswrap_hexbadge.c
|
||||
endif
|
||||
|
||||
ifdef USE_WIO_LTE
|
||||
INCLUDE += -I$(ROOT)/libs/wio_lte
|
||||
WRAPPERSOURCES += libs/wio_lte/jswrap_wio_lte.c
|
||||
SOURCES += targets/stm32/stm32_ws2812b_driver.c
|
||||
endif
|
||||
|
||||
|
||||
ifdef WICED
|
||||
WRAPPERSOURCES += targets/emw3165/jswrap_emw3165.c
|
||||
endif
|
||||
|
||||
@ -27,10 +27,12 @@ info = {
|
||||
'NET',
|
||||
'NEOPIXEL',
|
||||
'FILESYSTEM', # Add FILESYSTEM will force javascript module to load from SD card, remain to be seen.
|
||||
'WIO_LTE'
|
||||
],
|
||||
'makefile' : [
|
||||
'DEFINES+=-DUSE_USB_OTG_FS=1',
|
||||
'DEFINES+=-DWIO_LTE',
|
||||
'USE_DFU=1',
|
||||
'STLIB=STM32F405xx',
|
||||
'PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f4/lib/startup_stm32f40_41xxx.o'
|
||||
]
|
||||
@ -91,7 +93,7 @@ board["_css"] = """
|
||||
width: 680px;
|
||||
height: 1020px;
|
||||
left: 200px;
|
||||
background-image: url(img/STM32F4DISCOVERY.jpg);
|
||||
background-image: url(img/WIO_LTE.jpg);
|
||||
}
|
||||
#boardcontainer {
|
||||
height: 1020px;
|
||||
|
||||
112
libs/wio_lte/jswrap_wio_lte.c
Normal file
112
libs/wio_lte/jswrap_wio_lte.c
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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/.
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
* This file is designed to be parsed during the build process
|
||||
*
|
||||
* Contains JavaScript interface for the Seeed WIO LTE board
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include <jswrap_wio_lte.h>
|
||||
#include "jsparse.h"
|
||||
#include "stm32_ws2812b_driver.h"
|
||||
#include "jspininfo.h"
|
||||
|
||||
|
||||
/*JSON{
|
||||
"type": "class",
|
||||
"class" : "WioLTE"
|
||||
}
|
||||
Class containing utility functions for the Seeed WIO LTE board
|
||||
*/
|
||||
|
||||
/*JSON{
|
||||
"type" : "staticmethod",
|
||||
"class" : "WioLTE",
|
||||
"name" : "LED",
|
||||
"generate" : "jswrap_wio_lte_led",
|
||||
"params" : [
|
||||
["red","int","0-255, red LED intensity"],
|
||||
["green","int","0-255, green LED intensity"],
|
||||
["blue","int","0-255, blue LED intensity"]
|
||||
]
|
||||
}
|
||||
Set the WIO's LED
|
||||
*/
|
||||
void jswrap_wio_lte_led(int r, int g, int b) {
|
||||
if (r<0) r=0;
|
||||
if (g<0) g=0;
|
||||
if (b<0) b=0;
|
||||
if (r>255) r=255;
|
||||
if (g>255) g=255;
|
||||
if (b>255) b=255;
|
||||
unsigned char rgb[] = {(unsigned char)g,(unsigned char)r,(unsigned char)b};
|
||||
stm32_neopixelWrite(JSH_PORTB_OFFSET+1, rgb, 3);
|
||||
}
|
||||
|
||||
/*JSON{
|
||||
"type" : "staticproperty",
|
||||
"class" : "WioLTE",
|
||||
"name" : "D38",
|
||||
"generate_full" : "jspEvaluate(\"[C6,C7]\",true)",
|
||||
"return" : [ "JsVar", ""]
|
||||
}
|
||||
*/ // D38,D39
|
||||
/*JSON{
|
||||
"type" : "staticproperty",
|
||||
"class" : "WioLTE",
|
||||
"name" : "D20",
|
||||
"generate_full" : "jspEvaluate(\"[B4,B3]\",true)",
|
||||
"return" : [ "JsVar", ""]
|
||||
}
|
||||
*/ // D20,D19
|
||||
/*JSON{
|
||||
"type" : "staticproperty",
|
||||
"class" : "WioLTE",
|
||||
"name" : "A6",
|
||||
"generate_full" : "jspEvaluate(\"[A6,A7]\",true)",
|
||||
"return" : [ "JsVar", ""]
|
||||
}
|
||||
*/ // A6,A7
|
||||
|
||||
/*JSON{
|
||||
"type" : "staticproperty",
|
||||
"class" : "WioLTE",
|
||||
"name" : "I2C",
|
||||
"generate_full" : "jspEvaluate(\"[B8,B9]\",true)",
|
||||
"return" : [ "JsVar", ""]
|
||||
}
|
||||
*/ // I2C1 SCL,SDA
|
||||
/*JSON{
|
||||
"type" : "staticproperty",
|
||||
"class" : "WioLTE",
|
||||
"name" : "UART",
|
||||
"generate_full" : "jspEvaluate(\"[B7,B6]\",true)",
|
||||
"return" : [ "JsVar", ""]
|
||||
}
|
||||
*/ // UART1 RX,TX
|
||||
/*JSON{
|
||||
"type" : "staticproperty",
|
||||
"class" : "WioLTE",
|
||||
"name" : "A4",
|
||||
"generate_full" : "jspEvaluate(\"[A4,A5]\",true)",
|
||||
"return" : [ "JsVar", ""]
|
||||
}
|
||||
*/ // A4,A5
|
||||
|
||||
/*JSON{
|
||||
"type" : "init",
|
||||
"generate" : "jswrap_wio_lte_init"
|
||||
}*/
|
||||
void jswrap_wio_lte_init() {
|
||||
// initialise the SD card
|
||||
//jsvUnLock(jspEvaluate("(function(){digitalWrite(A15,1);var spi=new SPI();spi.setup({mosi:D2,miso:C8,sck:C12});E.connectSDCard(spi,C11);})();",true));
|
||||
}
|
||||
17
libs/wio_lte/jswrap_wio_lte.h
Normal file
17
libs/wio_lte/jswrap_wio_lte.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* This file is part of Espruino, a JavaScript interpreter for Microcontrollers
|
||||
*
|
||||
* Copyright (C) 2016 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/.
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
* Contains JavaScript interface for the Seeed WIO LTE board
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
#include "jspin.h"
|
||||
|
||||
void jswrap_wio_lte_led(int r, int g, int b);
|
||||
void jswrap_wio_lte_init();
|
||||
@ -6,8 +6,7 @@ ifndef BOOTLOADER
|
||||
SOURCES += \
|
||||
targets/stm32/main.c \
|
||||
targets/stm32/jshardware.c \
|
||||
targets/stm32/stm32_it.c \
|
||||
targets/stm32/stm32_ws2812b_driver.c
|
||||
targets/stm32/stm32_it.c
|
||||
ifdef USE_BOOTLOADER
|
||||
BUILD_LINKER_FLAGS+=--using_bootloader
|
||||
# -k applies bootloader hack for Espruino 1v3 boards
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
/* Software-based WS2812 driver */
|
||||
|
||||
#include "stm32_ws2812b_driver.h"
|
||||
|
||||
@ -37,4 +38,4 @@ bool stm32_neopixelWrite(Pin pin, unsigned char *rgbData, size_t rgbSize)
|
||||
jshInterruptOn();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* Software-based WS2812 driver - timings are designed for STM32F405 */
|
||||
|
||||
#ifndef STM32_WS2812B_DRIVER_H__
|
||||
#define STM32_WS2812B_DRIVER_H__
|
||||
|
||||
@ -37,4 +39,4 @@
|
||||
bool stm32_neopixelWrite(Pin pin, unsigned char *rgbData, size_t rgbSize);
|
||||
|
||||
|
||||
#endif // STM32_WS2812B_DRIVER_H__
|
||||
#endif // STM32_WS2812B_DRIVER_H__
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user