Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly program Murata module in Arduino MKRWAN1300 #57

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,54 @@ Gnat-L082CZ.menu.opt.o3=Fastest
Gnat-L082CZ.menu.opt.o3.build.flags.optimize=-O3
Gnat-L082CZ.menu.opt.o3.build.flags.ldspecs=

# Arduino MKRWAN 1300
# ---------------------------------------
mkrwan.name=Arduino MKRWAN 1300
mkrwan.vid.0=0x0483
mkrwan.pid.0=0x374b

mkrwan.upload.tool=stm32flash
mkrwan.upload.protocol=
mkrwan.upload.maximum_size=196608
mkrwan.upload.maximum_data_size=20480
mkrwan.upload.use_1200bps_touch=false
mkrwan.upload.wait_for_upload_port=false
mkrwan.upload.native_usb=false

mkrwan.build.mcu=cortex-m0plus
mkrwan.build.f_cpu=32000000L
mkrwan.build.board=STM32L0_B_L072Z_LRWAN1
mkrwan.build.arch=stm32l0
mkrwan.build.core=arduino
mkrwan.build.vid=0x0483
mkrwan.build.pid=0x374b
mkrwan.build.did=0xffff
mkrwan.build.extra_flags=-DSTM32L072xx -march=armv6-m -mthumb -mabi=aapcs -mfloat-abi=soft -fsingle-precision-constant
mkrwan.build.ldscript=linker_scripts/STM32L072CZ_FLASH.ld
mkrwan.build.openocdscript=openocd_scripts/b-l072z-lrwan1.cfg
mkrwan.build.variant=B-L072Z-LRWAN1
mkrwan.build.variant_system_libs="-L{runtime.platform.path}/system/STM32L0xx/Lib" "-L{runtime.platform.path}/system/CMSIS/Lib" -lstm32l072xx -larm_cortexM0l_math
mkrwan.build.variant_system_include="-I{runtime.platform.path}/system/CMSIS/Include" "-I{runtime.platform.path}/system/CMSIS/Device/ST/STM32L0xx/Include" "-I{runtime.platform.path}/system/STM32L0xx/Include"

mkrwan.menu.speed.32=32 MHz
mkrwan.menu.speed.32.build.f_cpu=32000000L
mkrwan.menu.speed.16=16 MHz (No USB)
mkrwan.menu.speed.16.build.f_cpu=16000000L
mkrwan.menu.speed.4=4.2 MHz (No USB)
mkrwan.menu.speed.4.build.f_cpu=4200000L

mkrwan.menu.opt.os=Smallest Code
mkrwan.menu.opt.os.build.flags.optimize=-Os
mkrwan.menu.opt.os.build.flags.ldspecs=--specs=nano.specs
mkrwan.menu.opt.o1=Fast
mkrwan.menu.opt.o1.build.flags.optimize=-O1
mkrwan.menu.opt.o1.build.flags.ldspecs=
mkrwan.menu.opt.o2=Faster
mkrwan.menu.opt.o2.build.flags.optimize=-O2
mkrwan.menu.opt.o2.build.flags.ldspecs=
mkrwan.menu.opt.o3=Fastest
mkrwan.menu.opt.o3.build.flags.optimize=-O3
mkrwan.menu.opt.o3.build.flags.ldspecs=

# ST B-L072Z-LRWAN1
# ---------------------------------------
Expand Down
1 change: 1 addition & 0 deletions cores/arduino/Uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#pragma once

#include "HardwareSerial.h"
#include "Callback.h"

#define UART_RX_BUFFER_SIZE 64
#define UART_TX_BUFFER_SIZE 64
Expand Down
79 changes: 79 additions & 0 deletions libraries/STM32L0/examples/MKRWANBridge/MKRWANBridge.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
MKRWAN Bridge
This sketch needs to be flashed on a MKR WAN 1300 to allow using the board as an STM32L0 target.
Once flashed using Arduino SAMD core, select Arduino MKRWAN 1300 target from STM32L0 core.

This example code is in the public domain.
*/

int baud = 115200;
uint8_t parity = 0;

void setup() {
Serial.begin(baud);
pinMode(LED_BUILTIN, OUTPUT);
}

char rx_buf[512];
char tx_buf[512];

int rx = 0;
int tx = 0;

void doStuff() {
if (Serial.baud() != baud) {
baud = Serial.baud();
if (baud == 2400) {
digitalWrite(LORA_BOOT0, HIGH);
pinMode(LORA_BOOT0, OUTPUT);
digitalWrite(LORA_BOOT0, HIGH);
pinMode(LORA_RESET, OUTPUT);
digitalWrite(LORA_RESET, HIGH);
delay(100);
digitalWrite(LORA_RESET, LOW);
delay(100);
digitalWrite(LORA_RESET, HIGH);
Serial2.begin(115200, SERIAL_8E1);
while (Serial2.available()) {
Serial2.read();
}
digitalWrite(LED_BUILTIN, HIGH);
} else {
Serial2.begin(baud, SERIAL_8N1);
pinMode(LORA_BOOT0, OUTPUT);
digitalWrite(LORA_BOOT0, LOW);
pinMode(LORA_RESET, OUTPUT);
digitalWrite(LORA_RESET, HIGH);
delay(100);
digitalWrite(LORA_RESET, LOW);
delay(100);
digitalWrite(LORA_RESET, HIGH);
digitalWrite(LED_BUILTIN, LOW);
}
}
}

void loop() {

doStuff();

while (Serial.available()) { // If anything comes in Serial (USB),
tx_buf[tx++] = Serial.read(); // read it and send it out Serial1 (pins 0 & 1)
}

if (tx > 0) {
Serial2.write(tx_buf, tx);
tx = 0;
}

while (Serial2.available()) { // If anything comes in Serial (USB),
rx_buf[rx++] = Serial2.read(); // read it and send it out Serial1 (pins 0 & 1)
}

if (rx > 0) {
Serial.write(rx_buf, rx);
rx = 0;
}


}
15 changes: 15 additions & 0 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,18 @@ tools.stm32l0_openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{runt
tools.stm32l0_openocd.erase.params.verbose=-d3
tools.stm32l0_openocd.erase.params.quiet=-d0
tools.stm32l0_openocd.erase.pattern=

# STM32FLASH
tools.stm32flash.cmd=stm32flash
tools.stm32flash.path={runtime.platform.path}/tools/windows
tools.stm32flash.path.macosx={runtime.platform.path}/tools/macosx
tools.stm32flash.path.linux={runtime.platform.path}/tools/linux
tools.stm32flash.upload.params.verbose=-v
tools.stm32flash.upload.params.quiet=
tools.stm32flash.upload.pattern="{path}/{cmd}" {serial.port} -e 512 -b 2400 -w "{build.path}/{build.project_name}.dfu"
tools.stm32flash.program.params.verbose=-v
tools.stm32flash.program.params.quiet=
tools.stm32flash.program.pattern="{path}/{cmd}" {serial.port} -e 512 -b 2400 -w "{build.path}/{build.project_name}.dfu"
tools.stm32flash.erase.params.verbose=-v
tools.stm32flash.erase.params.quiet=
tools.stm32flash.erase.pattern="{path}/{cmd}" {serial.port} -e 512 -b 2400
Binary file added tools/linux/stm32flash
Binary file not shown.
Binary file added tools/macosx/stm32flash
Binary file not shown.
Binary file added tools/windows/stm32flash.exe
Binary file not shown.