LOM204A - ACESSANDO LoRaWAN VIA ARDUINO com LOM204 - grumpyoldpizza
O objetivo deste BLOG é demonstrar como é possível utilizar o ARDUINO para programação do WISOL LOM204A e assim criar uma rede LoRaWAN. Foi utilizado o KIT LOM204A para o teste.
BETA - EM TESTES - APENAS PARA PROGRAMADORES ARDUINO
Baseado no cmwx1zzabz
Portado e testado no STARTER KIT LOM204
TTN
The Thing Network
A Rede de Coisas (TTN) é uma iniciativa iniciada pela sociedade civil holandesa. O objetivo é ter redes LoRaWAN instaladas em todas as cidades do mundo. Ao interconectar essas redes locais, a TTN quer construir uma infra-estrutura mundial para facilitar uma Internet das Coisas (IoT) pública.
A The Things Network (TTN) é o servidor IoT na nuvem utilizado nesse projeto. É um dos servidores gratuitos para LoRaWAN mais utilizados, com mais de 90 mil desenvolvedores, mais de 9 mil gateways de usuários conectados à rede ao redor do mundo e mais de 50 mil aplicações em funcionamento.
A TTN comercializa nós e gateways LoRa e provê treinamento individual e coletivo para empresas e desenvolvedores que desejam utilizar o LoRa. Possui uma comunidade bem ativa nos fóruns, sempre colaborando e ajudando a resolver problemas, além de prover diversos meios de integrar a TTN com a aplicação que se deseja usar. Possui integração nativa com diversas aplicações como: Cayenne, Hypertext Transfer Protocol (HTTP), permitindo ao usuário realizar uplink para um gateway e receber downlink por HTTP, OpenSensors e EVRYTHNG . Caso o usuário queira criar sua própria aplicação, a TTN disponibiliza Application Programming Interface (API) para uso com Message Queuing Telemetry Transport (MQTT) e diversos Software Developer Kits (SDK) para uso com as linguagens Python, Java , Node.Js , NODE-RED e Go
A rede TTN utiliza o protocolo LoRaWAN objetivando uma cobertura em longo alcance para os dispositivos da rede, caracterizando-a assim com uma Wide Area Network (WAN). Devido ao baixo consumo de energia e ao uso da tecnologia LoRa, é chamada de LPWAN (Low Power Wide Area Network). O grande diferencial da TTN é seu estabelecimento como uma rede aberta (open-source) e colaborativa (crowd-sourced), onde qualquer usuário pode contribuir instalando um gateway em sua residência.
Os elementos da TTN são classificados como:
• Endpoints (nós): Os dispositivos responsáveis pela camada de sensoriamento da rede, o endpoint LoRaWAN. Podem coletar informações através de sensores e também acionar dispositivos/máquinas via atuadores. São configurados através de uma das três classes distintas do protocolo LaRaWAN;
• Gateways: Elementos responsáveis por concentrar e processar as informações enviadas pelos endpoints. Os gateways em geral estão conectados a internet, seja por WiFi/Ethernet ou 3G/4G em locais remotos. Mesmo que uma mesma rede LoRaWAN tenha diferentes objetivos, baseados em aplicações distintas, os gateways possuem o objetivo comum de fornecer a maior área de cobertura possível;
• Aplicações: Conectar e interligar os diferentes dispositivos da rede TTN para o fornecimento de informações gerais sobre a coleta de dados dos dispositivos.
PRIMEIROS PASSOS
- INSTALE ARDUINO EM SUA MÁQUINA
- INSTALE O PACOTE PARA STM32L0
https://grumpyoldpizza.github.io/ArduinoCore-stm32l0/package_stm32l0_boards_index.json
ARQUIVO-->PREFERENCIAS-->URLS
CONFIGURAÇÕES PARA SEREM COMPATÍVEIS COM LOM204A
NO ARDUINO, ESCOLHA NUCLEO-L073RZ
Em qualquer um dos exemplos LoRaWAN, coloque no Setup()
//TCXO - ENABLE
pinMode(24, OUTPUT);
digitalWrite(24, HIGH);
ALTERE VARIANT.H PARA
/*
* Copyright (c) 2017-2018 Thomas Roell. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Thomas Roell, nor the names of its contributors
* may be used to endorse or promote products derived from this Software
* without specific prior written permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* WITH THE SOFTWARE.
*/
#ifndef _VARIANT_NUCLEO_STM32L073RZ_
#define _VARIANT_NUCLEO_STM32L073RZ_
/*----------------------------------------------------------------------------
* Definitions
*----------------------------------------------------------------------------*/
#define STM32L0_CONFIG_LSECLK 32768
#define STM32L0_CONFIG_HSECLK 0
#define STM32L0_CONFIG_SYSOPT 0
/** Master clock frequency */
#define VARIANT_MCK F_CPU
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
#include "Uart.h"
#endif // __cplusplus
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
/*----------------------------------------------------------------------------
* Pins
*----------------------------------------------------------------------------*/
// Number of pins defined in PinDescription array
//MIGUEL
#define PINS_COUNT (25u)
#define NUM_DIGITAL_PINS (16u)
#define NUM_ANALOG_INPUTS (6u)
#define NUM_ANALOG_OUTPUTS (0u)
// LEDs
#define PIN_LED (13ul)
#define LED_BUILTIN PIN_LED
/*
* Analog pins
*/
#define PIN_A0 (16ul)
#define PIN_A1 (17ul)
#define PIN_A2 (18ul)
#define PIN_A3 (19ul)
#define PIN_A4 (20ul)
#define PIN_A5 (21ul)
static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
#define ADC_RESOLUTION 12
/*
* Other pins
*/
#define PIN_BUTTON (22l)
static const uint8_t BUTTON = PIN_BUTTON;
/*
* Serial interfaces
*/
#define SERIAL_INTERFACES_COUNT 2
#define PIN_SERIAL_RX (0ul)
#define PIN_SERIAL_TX (1ul)
#define PIN_SERIAL_RX (0ul)
#define PIN_SERIAL_TX (1ul)
#define PIN_SERIAL1_RX (2ul)
#define PIN_SERIAL1_TX (8ul)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (12u)
#define PIN_SPI_MOSI (11u)
#define PIN_SPI_SCK (13u)
//MIGUEL
static const uint8_t SS = (18u);
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (14u)
#define PIN_WIRE_SCL (15u)
static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;
#define PWM_INSTANCE_COUNT 2
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern Uart Serial;
extern Uart Serial1;
#endif
// 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_HARDWARE1 Serial
#define SERIAL_PORT_HARDWARE2 Serial1
#define SERIAL_PORT_HARDWARE_OPEN2 Serial1
#endif /*_VARIANT_NUCLEO_STM32L073RZ_ */
ALTERE RH_ABZ.CPP PARA
// RH_ABZ.cpp
//
// Copyright (C) 2020 Mike McCauley
// $Id: RH_ABZ.cpp,v 1.1 2020/06/15 23:39:39 mikem Exp $
#if (RH_PLATFORM == RH_PLATFORM_STM32L0) && (defined STM32L082xx || defined STM32L072xx)
#include <RH_ABZ.h>
// Pointer to the _only_ permitted ABZ instance (there is only one radio connected to this device)
RH_ABZ* RH_ABZ::_thisDevice;
// The muRata cmwx1zzabz module has its builtin SX1276 radio connected to the processor's SPI1 port,
// but the Arduino compatible SPI interface in Grumpy Pizzas Arduino Core is configured for SPI1 or SPI2
// depending on the exact board variant selected.
// So here we define our own Arduino compatible SPI interface
// so we are _sure_ to get the one connected to the radio, independent of the board variant selected
#include <stm32l0_spi.h>
static const stm32l0_spi_params_t RADIO_SPI_PARAMS = {
STM32L0_SPI_INSTANCE_SPI1,
0,
STM32L0_DMA_CHANNEL_NONE,
STM32L0_DMA_CHANNEL_NONE,
{
STM32L0_GPIO_PIN_PA7_SPI1_MOSI,
STM32L0_GPIO_PIN_PA6_SPI1_MISO,
STM32L0_GPIO_PIN_PA5_SPI1_SCK,
STM32L0_GPIO_PIN_NONE,
},
};
// Create and configure an Arduino compatible SPI interface. This will be referred to in RHHardwareSPI.cpp
// and used as the SPI interface to the radio.
static stm32l0_spi_t RADIO_SPI;
SPIClass radio_spi(&RADIO_SPI, &RADIO_SPI_PARAMS);
// Glue code between the 'C' DIO0 interrupt and the C++ interrupt handler in RH_RF95
void RH_INTERRUPT_ATTR RH_ABZ::isr()
{
_thisDevice->handleInterrupt();
}
RH_ABZ::RH_ABZ():
RH_RF95(RH_INVALID_PIN, RH_INVALID_PIN)
{
}
bool RH_ABZ::init()
{
_thisDevice = this;
// REVISIT: RESET THE RADIO???
// The SX1276 radio DIO0 is connected to STM32 pin PB4
// It will later be configured as an interrupt
//MIGUEL
stm32l0_gpio_pin_configure(STM32L0_GPIO_PIN_PA12, (STM32L0_GPIO_PARK_NONE | STM32L0_GPIO_PUPD_PULLDOWN | STM32L0_GPIO_OSPEED_HIGH | STM32L0_GPIO_OTYPE_PUSHPULL | STM32L0_GPIO_MODE_INPUT));
// Here we configure the interrupt handler for DIO0 to call the C++
// interrupt handler in RH_RF95, in a roundabout way
#ifdef STM32L0_EXTI_CONTROL_PRIORITY_CRITICAL
//MIGUEL
stm32l0_exti_attach(STM32L0_GPIO_PIN_PA12, (STM32L0_EXTI_CONTROL_PRIORITY_CRITICAL | STM32L0_EXTI_CONTROL_EDGE_RISING), (stm32l0_exti_callback_t)isr, NULL); // STM32L0_EXTI_CONTROL_PRIORITY_CRITICAL not in 0.0.10
#else
//MIGUEL
stm32l0_exti_attach(STM32L0_GPIO_PIN_PA12, STM32L0_EXTI_CONTROL_EDGE_RISING, (stm32l0_exti_callback_t)isr, NULL);
#endif
//MIGUEL
// The SX1276 radio slave select (NSS) is connected to STM32 pin PA15
stm32l0_gpio_pin_configure(STM32L0_GPIO_PIN_PA4, (STM32L0_GPIO_PARK_HIZ | STM32L0_GPIO_PUPD_NONE | STM32L0_GPIO_OSPEED_HIGH | STM32L0_GPIO_OTYPE_PUSHPULL | STM32L0_GPIO_MODE_OUTPUT));
// muRata cmwx1zzabz module has an antenna switch which must be driven the right way to connect the antenna
// to the appropriate SX1276 pins.
// Antenna switch might be something like NJG180K64, but not sure.
// See Application note: AN-ZZABZ-001 P. 20/20
// in typeABZ_hardware_design_guide_revC.pdf
// with 3 pins connected to STM32L0_GPIO_PIN_PA1, STM32L0_GPIO_PIN_PC2, STM32L0_GPIO_PIN_PC1
// which select RX, RFO or PA_BOOST respecitvely
// See modeWillChange() for implementation of pin twiddling when the transmitter is on
//
// We use native STM32 calls because the various different variants in the Grumpy Pizza
// Arduino core and various forks of that core have inconsistent definitions of the Arduino compatible
// pins. We want to be sure we get the right ones for the muRata modules connections to the Radio
//MIGUEL*
stm32l0_gpio_pin_configure(STM32L0_GPIO_PIN_PA15, (STM32L0_GPIO_PARK_NONE | STM32L0_GPIO_PUPD_NONE | STM32L0_GPIO_OSPEED_LOW | STM32L0_GPIO_OTYPE_PUSHPULL | STM32L0_GPIO_MODE_OUTPUT));
//MIGUEL*
stm32l0_gpio_pin_configure(STM32L0_GPIO_PIN_PC2, (STM32L0_GPIO_PARK_NONE | STM32L0_GPIO_PUPD_NONE | STM32L0_GPIO_OSPEED_LOW | STM32L0_GPIO_OTYPE_PUSHPULL | STM32L0_GPIO_MODE_OUTPUT));
//MIGUEL*
stm32l0_gpio_pin_configure(STM32L0_GPIO_PIN_PC1, (STM32L0_GPIO_PARK_NONE | STM32L0_GPIO_PUPD_NONE | STM32L0_GPIO_OSPEED_LOW | STM32L0_GPIO_OTYPE_PUSHPULL | STM32L0_GPIO_MODE_OUTPUT));
return RH_RF95::init();
}
void RH_ABZ::selectSlave()
{
//MIGUEL
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PA4, 0);
}
void RH_ABZ::deselectSlave()
{
//MIGUEL
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PA4, 1);
}
bool RH_ABZ::modeWillChange(RHMode mode)
{
if (mode == RHModeTx)
{
// Tell the antenna switch to connect to one of thetransmoitter output pins
//MIGUEL - medir sinal do RF..
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PA15, 0); // RX
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PC2, _useRFO ? 1 : 0); // RFO
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PC1, _useRFO ? 0 : 1); // BOOST
}
else
{
// Enabling the RX from the antenna switch improves reception RSSI by about 5
//MIGUEL
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PA15, 1); // RX
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PC2, 0); // RFO
stm32l0_gpio_pin_write(STM32L0_GPIO_PIN_PC1, 0); // BOOST
}
return true;
}
#endif
ALTERE VARIANT.CPP PARA
/*
* Copyright (c) 2017-2018 Thomas Roell. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Thomas Roell, nor the names of its contributors
* may be used to endorse or promote products derived from this Software
* without specific prior written permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* WITH THE SOFTWARE.
*/
#include "Arduino.h"
#include "wiring_private.h"
#define PWM_INSTANCE_TIM2 0
#define PWM_INSTANCE_TIM3 1
/*
* Pins descriptions
*/
extern const PinDescription g_APinDescription[PINS_COUNT] =
{
// 0..13 - Digital pins
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA3), STM32L0_GPIO_PIN_PA3, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA2), STM32L0_GPIO_PIN_PA2, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA10), STM32L0_GPIO_PIN_PA10, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB3), STM32L0_GPIO_PIN_PB3_TIM2_CH2, (PIN_ATTR_EXTI), PWM_INSTANCE_TIM2, PWM_CHANNEL_2, ADC_CHANNEL_NONE },
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB5), STM32L0_GPIO_PIN_PB5, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB4), STM32L0_GPIO_PIN_PB4_TIM3_CH1, 0, PWM_INSTANCE_TIM3, PWM_CHANNEL_1, ADC_CHANNEL_NONE },
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB10), STM32L0_GPIO_PIN_PB10_TIM2_CH3, 0, PWM_INSTANCE_TIM2, PWM_CHANNEL_3, ADC_CHANNEL_NONE },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA8), STM32L0_GPIO_PIN_PA8, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA9), STM32L0_GPIO_PIN_PA9, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOC, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PC7), STM32L0_GPIO_PIN_PC7_TIM3_CH2, (PIN_ATTR_EXTI), PWM_INSTANCE_TIM3, PWM_CHANNEL_2, ADC_CHANNEL_NONE },
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB6), STM32L0_GPIO_PIN_PB6, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA7), STM32L0_GPIO_PIN_PA7, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA6), STM32L0_GPIO_PIN_PA6, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA5), STM32L0_GPIO_PIN_PA5, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
// 14..15 - I2C pins (SDA,SCL)
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB9), STM32L0_GPIO_PIN_PB9, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB8), STM32L0_GPIO_PIN_PB8, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
// 16..21 - Analog pins
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA0), STM32L0_GPIO_PIN_PA0, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_0 },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA1), STM32L0_GPIO_PIN_PA1, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_1 },
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA4), STM32L0_GPIO_PIN_PA4, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_4 },
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB0), STM32L0_GPIO_PIN_PB0, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_8 },
{ GPIOC, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PC1), STM32L0_GPIO_PIN_PC1, (PIN_ATTR_EXTI), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_11 },
{ GPIOC, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PC0), STM32L0_GPIO_PIN_PC0, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_10 },
// 22 - Button
{ GPIOC, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PC13), STM32L0_GPIO_PIN_PC13, (PIN_ATTR_EXTI | PIN_ATTR_WKUP1), PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
//MIGUEL - DIO0 - INTERRUPT
{ GPIOA, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PA12), STM32L0_GPIO_PIN_PA12, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
//TCXO
{ GPIOB, STM32L0_GPIO_PIN_MASK(STM32L0_GPIO_PIN_PB1), STM32L0_GPIO_PIN_PB1, 0, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, ADC_CHANNEL_NONE },
};
extern const unsigned int g_PWMInstances[PWM_INSTANCE_COUNT] = {
STM32L0_TIMER_INSTANCE_TIM2,
STM32L0_TIMER_INSTANCE_TIM3,
};
static uint8_t stm32l0_usart2_rx_fifo[32];
extern const stm32l0_uart_params_t g_SerialParams = {
STM32L0_UART_INSTANCE_USART2,
STM32L0_UART_IRQ_PRIORITY,
STM32L0_DMA_CHANNEL_DMA1_CH6_USART2_RX,
STM32L0_DMA_CHANNEL_DMA1_CH4_USART2_TX,
&stm32l0_usart2_rx_fifo[0],
sizeof(stm32l0_usart2_rx_fifo),
{
STM32L0_GPIO_PIN_PA3_USART2_RX,
STM32L0_GPIO_PIN_PA2_USART2_TX,
STM32L0_GPIO_PIN_NONE,
STM32L0_GPIO_PIN_NONE,
},
};
static uint8_t stm32l0_usart1_rx_fifo[32];
extern const stm32l0_uart_params_t g_Serial1Params = {
STM32L0_UART_INSTANCE_USART1,
STM32L0_UART_IRQ_PRIORITY,
STM32L0_DMA_CHANNEL_DMA1_CH5_USART1_RX,
STM32L0_DMA_CHANNEL_NONE,
&stm32l0_usart1_rx_fifo[0],
sizeof(stm32l0_usart1_rx_fifo),
{
STM32L0_GPIO_PIN_PA10_USART1_RX,
STM32L0_GPIO_PIN_PA9_USART1_TX,
STM32L0_GPIO_PIN_NONE,
STM32L0_GPIO_PIN_NONE,
},
};
extern const stm32l0_spi_params_t g_SPIParams = {
STM32L0_SPI_INSTANCE_SPI1,
STM32L0_SPI_IRQ_PRIORITY,
STM32L0_DMA_CHANNEL_DMA1_CH2_SPI1_RX,
STM32L0_DMA_CHANNEL_DMA1_CH3_SPI1_TX,
{
STM32L0_GPIO_PIN_PA7_SPI1_MOSI,
STM32L0_GPIO_PIN_PA6_SPI1_MISO,
STM32L0_GPIO_PIN_PA5_SPI1_SCK,
STM32L0_GPIO_PIN_NONE,
},
};
extern const stm32l0_i2c_params_t g_WireParams = {
STM32L0_I2C_INSTANCE_I2C1,
STM32L0_I2C_IRQ_PRIORITY,
STM32L0_DMA_CHANNEL_DMA1_CH7_I2C1_RX,
STM32L0_DMA_CHANNEL_NONE,
{
STM32L0_GPIO_PIN_PB8_I2C1_SCL,
STM32L0_GPIO_PIN_PB9_I2C1_SDA,
},
};
void initVariant()
{
}
GRAVANDO (ST-LINK V2)
Altere as credenciais obtidas da TTN
const char *devAddr = "0100000A";
const char *nwkSKey = "2B7E151628AED2A6ABF7158809CF4F3C";
const char *appSKey = "2B7E151628AED2A6ABF7158809CF4F3C";
E a região para AU915 e subband
LoRaWAN.begin(US915);
LoRaWAN.setSubBand(2);
DÚVIDASsuporte@smartcore.com.brREFERÊNCIASSobre a SMARTCOREA SmartCore fornece módulos para comunicação wireless, biometria, conectividade, rastreamento e automação.Nosso portfólio inclui modem 2G/3G/4G/NB-IoT/Cat.M, satelital, módulos WiFi, Bluetooth, GNSS / GPS, Sigfox, LoRa, leitor de cartão, leitor QR code, mecanismo de impressão, mini-board PC, antena, pigtail, LCD, bateria, repetidor GPS e sensores.Mais detalhes em www.smartcore.com.br
Nenhum comentário:
Postar um comentário