From 96fd1f88b0faae3cdb16d4ad144cea276e59e03f Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Fri, 16 Mar 2018 08:27:48 -0600 Subject: [PATCH 01/13] Add support RAK811 Alpha Test --- variants/RAK811/PeripheralPins.c | 220 ++++++++++++++++++++ variants/RAK811/ldscript.ld | 202 ++++++++++++++++++ variants/RAK811/stm32l1xx_hal_conf.h | 292 +++++++++++++++++++++++++++ variants/RAK811/variant.cpp | 136 +++++++++++++ variants/RAK811/variant.h | 178 ++++++++++++++++ 5 files changed, 1028 insertions(+) create mode 100644 variants/RAK811/PeripheralPins.c create mode 100755 variants/RAK811/ldscript.ld create mode 100755 variants/RAK811/stm32l1xx_hal_conf.h create mode 100755 variants/RAK811/variant.cpp create mode 100755 variants/RAK811/variant.h diff --git a/variants/RAK811/PeripheralPins.c b/variants/RAK811/PeripheralPins.c new file mode 100644 index 0000000000..6b74b6cefb --- /dev/null +++ b/variants/RAK811/PeripheralPins.c @@ -0,0 +1,220 @@ +/* + ******************************************************************************* + * Copyright (c) 2016, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +// ===== +// Note: Commented lines are alternative possibilities which are not used per default. +// If you change them, you will have to know what you do +// ===== + + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC_IN2 + //{PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC_IN3 + //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC_IN4 + //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC_IN5 + //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC_IN6 + //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC_IN9 + {PB_12, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC_IN18 + {PB_13, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC_IN19 + {PB_14, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 20, 0)}, // ADC_IN20 + {PB_15, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 21, 0)}, // ADC_IN21 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +const PinMap PinMap_DAC[] = { + //{PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + //{PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SDA[] = { + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + //{PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SCL[] = { + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +const PinMap PinMap_PWM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PA_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PB_12, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + {PB_13, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + {PB_14, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PB_15, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_TX[] = { + {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RX[] = { + {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RTS[] = { + {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_CTS[] = { + {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +//*** No CAN_RD *** + +//*** No CAN_TD *** + +//*** ETHERNET *** + +//*** No Ethernet *** + +//*** QUADSPI *** + +//*** No QUADSPI *** diff --git a/variants/RAK811/ldscript.ld b/variants/RAK811/ldscript.ld new file mode 100755 index 0000000000..6f6b80e7a9 --- /dev/null +++ b/variants/RAK811/ldscript.ld @@ -0,0 +1,202 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Author : Auto-generated by Ac6 System Workbench +** +** Abstract : Linker script for STM32L151CBUx Device from STM32L1 series +** 16Kbytes RAM +** 128Kbytes ROM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed �as is,� without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2018 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20004000; /* end of RAM */ + +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K + ROM (rx) : ORIGIN = 0x8000000, LENGTH = 128K +} + +/* Sections */ +SECTIONS +{ + /* The startup code into ROM memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >ROM + + /* The program code and other data into ROM memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >ROM + + /* Constant data into ROM memory*/ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >ROM + + .ARM.extab : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >ROM + + .ARM : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >ROM + + .preinit_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >ROM + + .init_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >ROM + + .fini_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >ROM + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into RAM memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> ROM + + + /* Uninitialized data section into RAM memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} \ No newline at end of file diff --git a/variants/RAK811/stm32l1xx_hal_conf.h b/variants/RAK811/stm32l1xx_hal_conf.h new file mode 100755 index 0000000000..25299b213a --- /dev/null +++ b/variants/RAK811/stm32l1xx_hal_conf.h @@ -0,0 +1,292 @@ +/** + ****************************************************************************** + * @file stm32l1xx_hal_conf.h + * @author MCD Application Team + * @version 21-April-2017 + * @date V1.3.0 + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32l1xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32L1xx_HAL_CONF_H +#define __STM32L1xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +/*#define HAL_COMP_MODULE_ENABLED*/ +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +/*#define HAL_CRYP_MODULE_ENABLED*/ +#define HAL_DAC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/*#define HAL_IRDA_MODULE_ENABLED*/ +/*#define HAL_IWDG_MODULE_ENABLED*/ +/*#define HAL_LCD_MODULE_ENABLED*/ +/*#define HAL_NOR_MODULE_ENABLED*/ +/*#define HAL_OPAMP_MODULE_ENABLED*/ +/*#define HAL_PCD_MODULE_ENABLED*/ +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +/*#define HAL_RTC_MODULE_ENABLED*/ +/*#define HAL_SD_MODULE_ENABLED*/ +/*#define HAL_SMARTCARD_MODULE_ENABLED*/ +#define HAL_SPI_MODULE_ENABLED +/*#define HAL_SRAM_MODULE_ENABLED*/ +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/*#define HAL_WWDG_MODULE_ENABLED*/ + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal Multiple Speed oscillator (MSI) default value. + * This value is the default MSI range value after Reset. + */ +#if !defined (MSI_VALUE) + #define MSI_VALUE (2097000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz*/ +#endif /* LSE_VALUE */ + +/** + * @brief Time out for LSE start up value in ms. + */ +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (0x000FU) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 0U +#define DATA_CACHE_ENABLE 0U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/*#define USE_FULL_ASSERT 1U*/ + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32l1xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32l1xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32l1xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32l1xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32l1xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32l1xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32l1xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32l1xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32l1xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32l1xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32l1xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32l1xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32l1xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32l1xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32l1xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LCD_MODULE_ENABLED + #include "stm32l1xx_hal_lcd.h" +#endif /* HAL_LCD_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED + #include "stm32l1xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32l1xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32l1xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32l1xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32l1xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32l1xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32l1xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32l1xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32l1xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32l1xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32l1xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32l1xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32L1xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/variants/RAK811/variant.cpp b/variants/RAK811/variant.cpp new file mode 100755 index 0000000000..c7cbbc86b0 --- /dev/null +++ b/variants/RAK811/variant.cpp @@ -0,0 +1,136 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#include "variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +// This array allows to wrap Arduino pin number(Dx or x) +// to STM32 PinName (PX_n) +const PinName digitalPin[] = { +//PX_n, //Dx + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_8, //D3 + PA_9, //D4 + PA_10, //D5 + PA_12, //D6 + PA_13, //D7 + PA_14, //D8 + PA_15, //D9 + PB_2, //D10 + PB_3, //D11 + PB_4, //D12 + PB_5, //D13 + PB_8, //D14 + PB_9, //D15 + PB_10, //D16 + PB_11, //D17 + PB_12, //D18/A18 + PB_14, //D19/A20 + PB_15, //D20/A21 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * @param None + * @retval None + */ +/* +WEAK void SystemClock_Config(void) +{ +// Here copy the desired System Clock Configuration +// It could be generated thanks STM32CubeMX after code generation for Toolchain/IDE: 'SW4STM32', +// available in src/main.c +// or +// copied from a STM32CubeYY project examples +// where 'YY' could be F0, F1, F2, F3, F4, F7, L0, L1, L4 +} +*/ +WEAK void SystemClockConfig( void ) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_PeriphCLKInitTypeDef PeriphClkInit; + + __HAL_RCC_PWR_CLK_ENABLE( ); + + __HAL_PWR_VOLTAGESCALING_CONFIG( PWR_REGULATOR_VOLTAGE_SCALE2 ); + + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.LSEState = RCC_LSE_ON; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_OFF; +// RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; +// RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; +// RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL8; +// RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3; + HAL_RCC_OscConfig( &RCC_OscInitStruct ); + + RCC_ClkInitStruct.ClockType = ( RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 ); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + HAL_RCC_ClockConfig( &RCC_ClkInitStruct, FLASH_LATENCY_1 ); + + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; + PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; + HAL_RCCEx_PeriphCLKConfig( &PeriphClkInit ); + + HAL_SYSTICK_Config( HAL_RCC_GetHCLKFreq( ) / 1000 ); + + HAL_SYSTICK_CLKSourceConfig( SYSTICK_CLKSOURCE_HCLK ); + + /* HAL_NVIC_GetPriorityGrouping*/ + HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_4 ); + + /* SysTick_IRQn interrupt configuration */ + HAL_NVIC_SetPriority( SysTick_IRQn, 0, 0 ); +} + +#ifdef __cplusplus +} +#endif diff --git a/variants/RAK811/variant.h b/variants/RAK811/variant.h new file mode 100755 index 0000000000..3b45743af0 --- /dev/null +++ b/variants/RAK811/variant.h @@ -0,0 +1,178 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ +extern const PinName digitalPin[]; + +// Enum defining pin names to match digital pin number --> Dx +// !!! +// !!! Copy the digitalPin[] array in variant.cpp +// !!! and remove all '_': PX_n --> PXn +// !!! For NC, suffix by _x where x is the number of NC: +// !!! NC_1, NC_2,... +// !!! For duplicated pin name, suffix by _x where x is the number of pin: +// !!! PA7, PA7_2, PA7_3,... +enum { + PA0, //D0 + PA1, //D1 + PA2, //D2 + PA8, //D3 + PA9, //D4 + PA10, //D5 + PA12, //D6 + PA13, //D7 + PA14, //D8 + PA15, //D9 + PB2, //D10 + PB3, //D11 + PB4, //D12 + PB5, //D13 + PB8, //D15 + PB9, //D14 + PB10, //D16 + PB11, //D17 + PB12, //D18/A18 + PB14, //D19/A20 + PB15, //D20/A21 + PEND +}; +// Enum defining Arduino style alias for analog pin number --> Ax +// !!! +// !!! It must be aligned with the number of analog PinName +// !!! defined in digitalPin[] array in variant.cpp +// !!! +enum { + A_START_AFTER = D20, // pin number preceding A0 + A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, + A10, A11, A12, A13, A14, A15, A16, A17, + AEND +}; + + +// Below ADC, DAC and PWM definitions already done in the core +// Could be redefined here if needed +// ADC resolution is 12bits +//#define ADC_RESOLUTION 12 +//#define DACC_RESOLUTION 12 + +// PWM resolution +//#define PWM_RESOLUTION 8 +//#define PWM_FREQUENCY 1000 +//#define PWM_MAX_DUTY_CYCLE 255 + +// On-board LED pin number +#define LED_BUILTIN 13 +#define LED_GREEN LED_BUILTIN + +// On-board user button +//#define USER_BTN Dx + +// Below SPI and I2C definitions already done in the core +// Could be redefined here if needed +// SPI Definitions +//#define SS 10 // Default for Arduino connector compatibility +//#define MOSI 11 // Default for Arduino connector compatibility +//#define MISO 12 // Default for Arduino connector compatibility +//#define SCK 13 // Default for Arduino connector compatibility + +// I2C Definitions +#define SDA 14 // Default for Arduino connector compatibility +#define SCL 15 // Default for Arduino connector compatibility + +// Timer Definitions +//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +#define TIMER_TONE TIM10 +//#define TIMER_UART_EMULATED TIMx + +// Do not use basic timer: OC is required +#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work + +// UART Definitions +// Define here Serial instance number to map on Serial generic name +#define SERIAL_UART_INSTANCE x //ex: 2 for Serial2 (USART2) +// DEBUG_UART could be redefined to print on another instance than 'Serial' +//#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 +// DEBUG_UART baudrate, default: 9600 if not defined +//#define DEBUG_UART_BAUDRATE x +// DEBUG_UART Tx pin name, default: the first one found in PinMap_UART_TX for DEBUG_UART +//#define DEBUG_PINNAME_TX PX_n // PinName used for TX + +// UART Emulation (uncomment if needed, required TIM1) +//#define UART_EMUL_RX PX_n // PinName used for RX +//#define UART_EMUL_TX PX_n // PinName used for TX + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX D5 +#define PIN_SERIAL_TX D4 + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ From d29a5497c20983f3db031afa05586e7d45b1ee29 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Fri, 16 Mar 2018 08:40:22 -0600 Subject: [PATCH 02/13] Add RAK811 to boards.txt --- boards.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/boards.txt b/boards.txt index d7524d1f82..8d5d3373aa 100644 --- a/boards.txt +++ b/boards.txt @@ -189,6 +189,19 @@ Nucleo_64.menu.pnum.NUCLEO_L053R8.build.variant=NUCLEO_L053R8 Nucleo_64.menu.pnum.NUCLEO_L053R8.build.cmsis_lib_gcc=arm_cortexM0l_math Nucleo_64.menu.pnum.NUCLEO_L053R8.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 +# RAK811 board +# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (UART4 on PC11, PC10) +Nucleo_64.menu.pnum.RAK811=RAK811 +Nucleo_64.menu.pnum.RAK811.node="NODE_RAK811" +Nucleo_64.menu.pnum.RAK811.upload.maximum_size=128000 +Nucleo_64.menu.pnum.RAK811.upload.maximum_data_size=32768 +Nucleo_64.menu.pnum.RAK811.build.mcu=cortex-m3 +Nucleo_64.menu.pnum.RAK811.build.board=STM32L151CBUx +Nucleo_64.menu.pnum.RAK811.build.series=STM32L1xx +Nucleo_64.menu.pnum.RAK811.build.product_line=STM32L151xB +Nucleo_64.menu.pnum.RAK811.build.variant=RAK811 +Nucleo_64.menu.pnum.RAK811.build.cmsis_lib_gcc=arm_cortexM3l_math + # NUCLEO_L152RE board # Support: Serial1 (USART1 on PA10, PA9) and Serial2 (UART4 on PC11, PC10) Nucleo_64.menu.pnum.NUCLEO_L152RE=Nucleo L152RE From 150e38e6edd18e95e6054f94a99b4fec305c6b3c Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Fri, 16 Mar 2018 13:24:46 -0600 Subject: [PATCH 03/13] Handle for stm32l151xb --- cores/arduino/stm32/stm32_eeprom.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cores/arduino/stm32/stm32_eeprom.c b/cores/arduino/stm32/stm32_eeprom.c index 2470eb2c0f..a3ec917e32 100644 --- a/cores/arduino/stm32/stm32_eeprom.c +++ b/cores/arduino/stm32/stm32_eeprom.c @@ -72,8 +72,10 @@ #if defined (STM32F0xx) || defined (STM32F1xx) || defined(STM32L1xx) #ifdef FLASH_BANK2_END #define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_BANK2_END + 1) - FLASH_PAGE_SIZE)) -#else +#elif defined(FLASH_BANK1_END) #define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_BANK1_END + 1) - FLASH_PAGE_SIZE)) +#else +#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END + 1) - FLASH_PAGE_SIZE)) #endif // FLASH_BANK2_END #elif defined (STM32F2xx) || defined (STM32F4xx) || defined (STM32F7xx) #define FLASH_BASE_ADDRESS ((uint32_t)(FLASH_END + 1) - FLASH_PAGE_SIZE) From 0968ea74bd84e5604a532df0c02825b14f4f71bb Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Fri, 16 Mar 2018 13:30:08 -0600 Subject: [PATCH 04/13] Fix Typo --- variants/RAK811/variant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/RAK811/variant.cpp b/variants/RAK811/variant.cpp index c7cbbc86b0..d21ee0a96f 100755 --- a/variants/RAK811/variant.cpp +++ b/variants/RAK811/variant.cpp @@ -88,7 +88,7 @@ WEAK void SystemClock_Config(void) // where 'YY' could be F0, F1, F2, F3, F4, F7, L0, L1, L4 } */ -WEAK void SystemClockConfig( void ) +WEAK void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; From f13ede4fdeb7c083a69664d5e8a396c55c1ddb0b Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Fri, 16 Mar 2018 13:41:26 -0600 Subject: [PATCH 05/13] define SERIAL_UART_INSTANCE --- variants/RAK811/variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/RAK811/variant.h b/variants/RAK811/variant.h index 3b45743af0..2aa870bf9a 100755 --- a/variants/RAK811/variant.h +++ b/variants/RAK811/variant.h @@ -131,7 +131,7 @@ enum { // UART Definitions // Define here Serial instance number to map on Serial generic name -#define SERIAL_UART_INSTANCE x //ex: 2 for Serial2 (USART2) +#define SERIAL_UART_INSTANCE 2 //ex: 2 for Serial2 (USART2) // DEBUG_UART could be redefined to print on another instance than 'Serial' //#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 // DEBUG_UART baudrate, default: 9600 if not defined From e7f120afb63be00855d7ca710fed10eb20d7c620 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Fri, 16 Mar 2018 22:08:35 -0600 Subject: [PATCH 06/13] Define LED_BUILTIN --- variants/RAK811/variant.cpp | 4 ++-- variants/RAK811/variant.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/variants/RAK811/variant.cpp b/variants/RAK811/variant.cpp index d21ee0a96f..c0c0565630 100755 --- a/variants/RAK811/variant.cpp +++ b/variants/RAK811/variant.cpp @@ -45,13 +45,13 @@ const PinName digitalPin[] = { PA_8, //D3 PA_9, //D4 PA_10, //D5 - PA_12, //D6 + PA_12, //D6 - LED1 PA_13, //D7 PA_14, //D8 PA_15, //D9 PB_2, //D10 PB_3, //D11 - PB_4, //D12 + PB_4, //D12 - LED2 PB_5, //D13 PB_8, //D14 PB_9, //D15 diff --git a/variants/RAK811/variant.h b/variants/RAK811/variant.h index 2aa870bf9a..bbd9ac99c6 100755 --- a/variants/RAK811/variant.h +++ b/variants/RAK811/variant.h @@ -61,13 +61,13 @@ enum { PA8, //D3 PA9, //D4 PA10, //D5 - PA12, //D6 + PA12, //D6 - LED1 PA13, //D7 PA14, //D8 PA15, //D9 PB2, //D10 PB3, //D11 - PB4, //D12 + PB4, //D12 - LED2 PB5, //D13 PB8, //D15 PB9, //D14 @@ -103,7 +103,7 @@ enum { //#define PWM_MAX_DUTY_CYCLE 255 // On-board LED pin number -#define LED_BUILTIN 13 +#define LED_BUILTIN 6 #define LED_GREEN LED_BUILTIN // On-board user button @@ -145,8 +145,8 @@ enum { // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata -#define PIN_SERIAL_RX D5 -#define PIN_SERIAL_TX D4 +#define PIN_SERIAL_RX 5 +#define PIN_SERIAL_TX 4 #ifdef __cplusplus } // extern "C" From 403db0f909a40cb4906e9934c7fabc7bb04a2e1a Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Fri, 16 Mar 2018 23:12:16 -0600 Subject: [PATCH 07/13] Add LoRa pins definition for RAK811 --- variants/RAK811/PeripheralPins.c | 11 ++++++----- variants/RAK811/variant.cpp | 12 +++++++++++- variants/RAK811/variant.h | 33 +++++++++++++++++++++++++++----- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/variants/RAK811/PeripheralPins.c b/variants/RAK811/PeripheralPins.c index 6b74b6cefb..28fab9b488 100644 --- a/variants/RAK811/PeripheralPins.c +++ b/variants/RAK811/PeripheralPins.c @@ -169,8 +169,8 @@ const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_MOSI[] = { - {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - {PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // RADIO_MOSI_PORT + //{PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, //LED1 {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {NC, NP, 0} @@ -179,9 +179,9 @@ const PinMap PinMap_SPI_MOSI[] = { #ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_MISO[] = { - {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // RADIO_MISO_PORT {PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, //LED2 {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {NC, NP, 0} }; @@ -189,7 +189,7 @@ const PinMap PinMap_SPI_MISO[] = { #ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_SCLK[] = { - {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},// RADIO_SCLK_PORT {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {NC, NP, 0} @@ -198,6 +198,7 @@ const PinMap PinMap_SPI_SCLK[] = { #ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_SSEL[] = { + {PB_0, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // RADIO_NSS_PORT {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, diff --git a/variants/RAK811/variant.cpp b/variants/RAK811/variant.cpp index c0c0565630..75811a270e 100755 --- a/variants/RAK811/variant.cpp +++ b/variants/RAK811/variant.cpp @@ -45,21 +45,31 @@ const PinName digitalPin[] = { PA_8, //D3 PA_9, //D4 PA_10, //D5 + PA_11, //DIO0 PA_12, //D6 - LED1 PA_13, //D7 PA_14, //D8 PA_15, //D9 PB_2, //D10 PB_3, //D11 - PB_4, //D12 - LED2 + PB_4, //D12 PB_5, //D13 PB_8, //D14 PB_9, //D15 PB_10, //D16 PB_11, //D17 PB_12, //D18/A18 + PB_13, //RESET LORA PB_14, //D19/A20 PB_15, //D20/A21 + PA_5, //SCK RADIO LORA + PA_6, //MISO RADIO LORA + PA_7, //MOSI RADIO LORA + PB_0, //NSS RADIO LORA + PB_1, //DIO1 + PA_3, //DIO2 + PH_0, //DIO3 + PC_13, //DIO4 }; #ifdef __cplusplus diff --git a/variants/RAK811/variant.h b/variants/RAK811/variant.h index bbd9ac99c6..7d5dc4fe74 100755 --- a/variants/RAK811/variant.h +++ b/variants/RAK811/variant.h @@ -61,6 +61,7 @@ enum { PA8, //D3 PA9, //D4 PA10, //D5 + PA11, //DIO0 PA12, //D6 - LED1 PA13, //D7 PA14, //D8 @@ -75,7 +76,16 @@ enum { PB11, //D17 PB12, //D18/A18 PB14, //D19/A20 + PB13, //RESET LORA PB15, //D20/A21 + PA5, //SCK RADIO LORA + PA6, //MISO RADIO LORA + PA7, //MOSI RADIO LORA + PB0, //NSS RADIO LORA + PB1, //DIO1 + PA3, //DIO2 + PH0, //DIO3 + PC13, //DIO4 PEND }; // Enum defining Arduino style alias for analog pin number --> Ax @@ -103,7 +113,7 @@ enum { //#define PWM_MAX_DUTY_CYCLE 255 // On-board LED pin number -#define LED_BUILTIN 6 +#define LED_BUILTIN PA12 #define LED_GREEN LED_BUILTIN // On-board user button @@ -112,10 +122,23 @@ enum { // Below SPI and I2C definitions already done in the core // Could be redefined here if needed // SPI Definitions -//#define SS 10 // Default for Arduino connector compatibility -//#define MOSI 11 // Default for Arduino connector compatibility -//#define MISO 12 // Default for Arduino connector compatibility -//#define SCK 13 // Default for Arduino connector compatibility +//#define SS PB0 // Default for Arduino connector compatibility +//#define MOSI PA7 // Default for Arduino connector compatibility +//#define MISO PA6 // Default for Arduino connector compatibility +//#define SCK PA5 // Default for Arduino connector compatibility + +// LORA +#define RADIO_RESET_PORT PB13 +#define RADIO_MOSI_PORT PA7 +#define RADIO_MISO_PORT PA6 +#define RADIO_SCLK_PORT PA5 +#define RADIO_NSS_PORT PB0 +#define RADIO_DIO_0_PORT PA11 +#define RADIO_DIO_1_PORT PB1 +#define RADIO_DIO_2_PORT PA3 +#define RADIO_DIO_3_PORT PH0 +#define RADIO_DIO_4_PORT PC13 +//#define RADIO_DIO_5_PORT PA4 // I2C Definitions #define SDA 14 // Default for Arduino connector compatibility From e25c44954a3e31245643451d9d8c68a87b6367e1 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Sat, 17 Mar 2018 12:30:36 -0600 Subject: [PATCH 08/13] Update version varian.h --- variants/RAK811/variant.h | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/variants/RAK811/variant.h b/variants/RAK811/variant.h index 7d5dc4fe74..0a6ae675fd 100755 --- a/variants/RAK811/variant.h +++ b/variants/RAK811/variant.h @@ -34,8 +34,7 @@ /*---------------------------------------------------------------------------- * Headers *----------------------------------------------------------------------------*/ - -#include "pins_arduino.h" +#include "PeripheralPins.h" #ifdef __cplusplus extern "C"{ @@ -88,18 +87,27 @@ enum { PC13, //DIO4 PEND }; -// Enum defining Arduino style alias for analog pin number --> Ax + +// This must be a literal with the same value as PEND +// It is used with preprocessor tests (e.g. #if NUM_DIGITAL_PINS > 3) +// so an enum will not work. +#define NUM_DIGITAL_PINS 31 + +// Allow to define Arduino style alias for analog input pin number --> Ax +// All pins are digital, analog inputs are a subset of digital pins +// and must be contiguous to be able to loop on each value +// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS +// defined in pin_arduino.h +// It is used with preprocessor tests (e.g. #if NUM_ANALOG_INPUTS > 3) +// so an enum will not work. // !!! // !!! It must be aligned with the number of analog PinName // !!! defined in digitalPin[] array in variant.cpp // !!! -enum { - A_START_AFTER = D20, // pin number preceding A0 - A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, - A10, A11, A12, A13, A14, A15, A16, A17, - AEND -}; - +#define NUM_ANALOG_INPUTS 3 +// Define digital pin number of the first analog input (i.e. which digital pin is A0) +// First analog pin value (A0) must be greater than or equal to NUM_ANALOG_INPUTS +#define NUM_ANALOG_FIRST 18 // Below ADC, DAC and PWM definitions already done in the core // Could be redefined here if needed @@ -117,15 +125,15 @@ enum { #define LED_GREEN LED_BUILTIN // On-board user button -//#define USER_BTN Dx +//#define USER_BTN x // Below SPI and I2C definitions already done in the core -// Could be redefined here if needed +// Could be redefined here if differs from the default one // SPI Definitions -//#define SS PB0 // Default for Arduino connector compatibility -//#define MOSI PA7 // Default for Arduino connector compatibility -//#define MISO PA6 // Default for Arduino connector compatibility -//#define SCK PA5 // Default for Arduino connector compatibility +//#define PIN_SPI_SS 10 // Default for Arduino connector compatibility +//#define PIN_SPI_MOSI 11 // Default for Arduino connector compatibility +//#define PIN_SPI_MISO 12 // Default for Arduino connector compatibility +//#define PIN_SPI_SCK 13 // Default for Arduino connector compatibility // LORA #define RADIO_RESET_PORT PB13 @@ -141,8 +149,8 @@ enum { //#define RADIO_DIO_5_PORT PA4 // I2C Definitions -#define SDA 14 // Default for Arduino connector compatibility -#define SCL 15 // Default for Arduino connector compatibility +#define PIN_WIRE_SDA PB9 // Default for Arduino connector compatibility +#define PIN_WIRE_SCL PB8 // Default for Arduino connector compatibility // Timer Definitions //Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c @@ -198,4 +206,4 @@ enum { #define SERIAL_PORT_HARDWARE Serial #endif -#endif /* _VARIANT_ARDUINO_STM32_ */ +#endif /* _VARIANT_ARDUINO_STM32_ */ \ No newline at end of file From 6abc2f7761346154acdbad5c8af65520069dbef7 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Sat, 17 Mar 2018 12:48:26 -0600 Subject: [PATCH 09/13] Add menu RAKWireless board --- boards.txt | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/boards.txt b/boards.txt index 8d5d3373aa..f4bbdc235b 100644 --- a/boards.txt +++ b/boards.txt @@ -189,19 +189,6 @@ Nucleo_64.menu.pnum.NUCLEO_L053R8.build.variant=NUCLEO_L053R8 Nucleo_64.menu.pnum.NUCLEO_L053R8.build.cmsis_lib_gcc=arm_cortexM0l_math Nucleo_64.menu.pnum.NUCLEO_L053R8.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 -# RAK811 board -# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (UART4 on PC11, PC10) -Nucleo_64.menu.pnum.RAK811=RAK811 -Nucleo_64.menu.pnum.RAK811.node="NODE_RAK811" -Nucleo_64.menu.pnum.RAK811.upload.maximum_size=128000 -Nucleo_64.menu.pnum.RAK811.upload.maximum_data_size=32768 -Nucleo_64.menu.pnum.RAK811.build.mcu=cortex-m3 -Nucleo_64.menu.pnum.RAK811.build.board=STM32L151CBUx -Nucleo_64.menu.pnum.RAK811.build.series=STM32L1xx -Nucleo_64.menu.pnum.RAK811.build.product_line=STM32L151xB -Nucleo_64.menu.pnum.RAK811.build.variant=RAK811 -Nucleo_64.menu.pnum.RAK811.build.cmsis_lib_gcc=arm_cortexM3l_math - # NUCLEO_L152RE board # Support: Serial1 (USART1 on PA10, PA9) and Serial2 (UART4 on PC11, PC10) Nucleo_64.menu.pnum.NUCLEO_L152RE=Nucleo L152RE @@ -465,6 +452,42 @@ Maple.menu.upload_method.serialMethod=Serial Maple.menu.upload_method.serialMethod.upload.protocol=maple_serial Maple.menu.upload_method.serialMethod.upload.tool=serial_upload +################################################################################ +# RAK boards + +RAK.name=RAKWireless + +RAK.build.vid=0x0483 +RAK.build.pid=0x5711 +RAK.vid.0=0x0483 +RAK.pid.0=0x5711 + +RAK.build.core=arduino +RAK.build.board=RAK811 +RAK.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} + +# RAK811 board +# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (UART4 on PC11, PC10) +RAK.menu.pnum.RAK811=RAK811 +#RAK.menu.pnum.RAK811.node="NODE_RAK811" +RAK.menu.pnum.RAK811.upload.maximum_size=128000 +RAK.menu.pnum.RAK811.upload.maximum_data_size=32768 +RAK.menu.pnum.RAK811.build.mcu=cortex-m3 +RAK.menu.pnum.RAK811.build.board=STM32L151CBUx +RAK.menu.pnum.RAK811.build.series=STM32L1xx +RAK.menu.pnum.RAK811.build.product_line=STM32L151xB +RAK.menu.pnum.RAK811.build.variant=RAK811 +RAK.menu.pnum.RAK811.build.cmsis_lib_gcc=arm_cortexM3l_math + +# Upload menu +#RAK.menu.upload_method.MassStorage=Mass Storage +#RAK.menu.upload_method.MassStorage.upload.protocol= +#RAK.menu.upload_method.MassStorage.upload.tool=massStorageCopy + +RAK.menu.upload_method.STLink=STLink +RAK.menu.upload_method.STLink.upload.protocol=STLink +RAK.menu.upload_method.STLink.upload.tool=stlink_upload + ################################################################################ # Serialx activation From fad6d728da8174c4eda545f02fdd048560b866fe Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Sun, 18 Mar 2018 19:11:05 -0600 Subject: [PATCH 10/13] Update HAL conf --- variants/RAK811/stm32l1xx_hal_conf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/variants/RAK811/stm32l1xx_hal_conf.h b/variants/RAK811/stm32l1xx_hal_conf.h index 25299b213a..960f791fa9 100755 --- a/variants/RAK811/stm32l1xx_hal_conf.h +++ b/variants/RAK811/stm32l1xx_hal_conf.h @@ -72,7 +72,7 @@ /*#define HAL_PCD_MODULE_ENABLED*/ #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED -/*#define HAL_RTC_MODULE_ENABLED*/ +#define HAL_RTC_MODULE_ENABLED /*#define HAL_SD_MODULE_ENABLED*/ /*#define HAL_SMARTCARD_MODULE_ENABLED*/ #define HAL_SPI_MODULE_ENABLED @@ -89,7 +89,7 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */ + #define HSE_VALUE (12000000U) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) @@ -101,7 +101,7 @@ * This value is the default MSI range value after Reset. */ #if !defined (MSI_VALUE) - #define MSI_VALUE (2097000U) /*!< Value of the Internal oscillator in Hz*/ + #define MSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/ #endif /* MSI_VALUE */ /** * @brief Internal High Speed oscillator (HSI) value. @@ -137,9 +137,9 @@ #define VDD_VALUE (3300U) /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY (0x000FU) /*!< tick interrupt priority */ #define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 0U -#define DATA_CACHE_ENABLE 0U +#define PREFETCH_ENABLE 0U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U /* ########################## Assert Selection ############################## */ /** From 10939d0857b784c0943e8fb5063642fc1ab37ead Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Sun, 18 Mar 2018 23:07:34 -0600 Subject: [PATCH 11/13] Add Optimizations for RAK811 --- boards.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/boards.txt b/boards.txt index f4bbdc235b..2661b732fd 100644 --- a/boards.txt +++ b/boards.txt @@ -732,3 +732,31 @@ Maple.menu.opt.o3lto.build.flags.ldspecs=-flto Maple.menu.opt.ogstd=Debug (-g) Maple.menu.opt.ogstd.build.flags.optimize=-g -Og Maple.menu.opt.ogstd.build.flags.ldspecs= + +RAK.menu.opt.osstd=Smallest (-Os default) +RAK.menu.opt.osstd.build.flags.optimize=-Os +RAK.menu.opt.osstd.build.flags.ldspecs= +RAK.menu.opt.oslto=Smallest (-Os) with LTO +RAK.menu.opt.oslto.build.flags.optimize=-Os -flto +RAK.menu.opt.oslto.build.flags.ldspecs=-flto +RAK.menu.opt.o1std=Fast (-O1) +RAK.menu.opt.o1std.build.flags.optimize=-O1 +RAK.menu.opt.o1std.build.flags.ldspecs= +RAK.menu.opt.o1lto=Fast (-O1) with LTO +RAK.menu.opt.o1lto.build.flags.optimize=-O1 -flto +RAK.menu.opt.o1lto.build.flags.ldspecs=-flto +RAK.menu.opt.o2std=Faster (-O2) +RAK.menu.opt.o2std.build.flags.optimize=-O2 +RAK.menu.opt.o2std.build.flags.ldspecs= +RAK.menu.opt.o2lto=Faster (-O2) with LTO +RAK.menu.opt.o2lto.build.flags.optimize=-O2 -flto +RAK.menu.opt.o2lto.build.flags.ldspecs=-flto +RAK.menu.opt.o3std=Fastest (-O3) +RAK.menu.opt.o3std.build.flags.optimize=-O3 +RAK.menu.opt.o3std.build.flags.ldspecs= +RAK.menu.opt.o3lto=Fastest (-O3) with LTO +RAK.menu.opt.o3lto.build.flags.optimize=-O3 -flto +RAK.menu.opt.o3lto.build.flags.ldspecs=-flto +RAK.menu.opt.ogstd=Debug (-g) +RAK.menu.opt.ogstd.build.flags.optimize=-g -Og +RAK.menu.opt.ogstd.build.flags.ldspecs= From 827153807b13724958600f7ffc8b9e6bb3bcfdc4 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Thu, 19 Apr 2018 21:04:55 -0500 Subject: [PATCH 12/13] Add pines extra radio lora --- variants/RAK811/variant.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/variants/RAK811/variant.h b/variants/RAK811/variant.h index 0a6ae675fd..fd5d0c76fc 100755 --- a/variants/RAK811/variant.h +++ b/variants/RAK811/variant.h @@ -148,6 +148,11 @@ enum { #define RADIO_DIO_4_PORT PC13 //#define RADIO_DIO_5_PORT PA4 +#define RADIO_RF_CRX_RX PB_6 //CRF3 (ANT_SWITCH_TX_BOOST) RADIO_ANT_SWITCH_RX +#define RADIO_RF_CBT_HF PB_7 //CRF2 HF (ANT_SWITCH_TX_RFO) +#define RADIO_RF_CTX_PA PA_4 //CRF1 PA (ANT_SWITCH_RX) RADIO_ANT_SWITCH_TX_PA +#define RADIO_XTAL_EN PH_1 + // I2C Definitions #define PIN_WIRE_SDA PB9 // Default for Arduino connector compatibility #define PIN_WIRE_SCL PB8 // Default for Arduino connector compatibility From e3120d1c3e418f5faae81d938cb17a50433fd218 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Sat, 28 Apr 2018 18:16:54 -0500 Subject: [PATCH 13/13] Add to ppload menu serial method --- boards.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/boards.txt b/boards.txt index 2661b732fd..c0410e14bd 100644 --- a/boards.txt +++ b/boards.txt @@ -480,9 +480,9 @@ RAK.menu.pnum.RAK811.build.variant=RAK811 RAK.menu.pnum.RAK811.build.cmsis_lib_gcc=arm_cortexM3l_math # Upload menu -#RAK.menu.upload_method.MassStorage=Mass Storage -#RAK.menu.upload_method.MassStorage.upload.protocol= -#RAK.menu.upload_method.MassStorage.upload.tool=massStorageCopy +RAK.menu.upload_method.serialMethod=Serial +RAK.menu.upload_method.serialMethod.upload.protocol=maple_serial +RAK.menu.upload_method.serialMethod.upload.tool=serial_upload RAK.menu.upload_method.STLink=STLink RAK.menu.upload_method.STLink.upload.protocol=STLink