sexta-feira, 18 de novembro de 2022

LOM204A - Comunicação entre Cliente/Servidor utilizando Library RADIOHEAD - Não é MESH

LOM204A - Comunicação entre Cliente/Servidor utilizando Library RADIOHEAD - Não é MESH


O objetivo deste BLOG é demonstrar como é possível utilizar o ARDUINO para programação do WISOL LOM204A e efetuar uma comunicação Cliente/Server. Foram utilizados o 2 KITS LOM204A para os testes. 

Horas de muita pesquisa!

BETA - EM TESTES - APENAS PARA PROGRAMADORES ARDUINO QUE CONHEÇAM A LIBRARY RADIOHEAD

Baseado no cmwx1zzabz

Módulo

Cliente/Server - P2P
RADIOHEAD

É uma biblioteca completa orientada a objetos para enviar e receber pacotes de mensagens por meio de uma variedade de rádios de dados e outros transportes em uma variedade de microprocessadores.

DRIVER

Neste caso, será utilizado com o SX1276 o driver RH_ABZ da RADIOHEAD, incorporado no LOM204A

Veja

MANAGER

RHDatagram Addressed
RHReliableDatagram Addressed
RHRouter Multi-hop
RHMesh Multi-hop 

PRIMEIROS PASSOS
CONFIGURAÇÕES PARA SEREM COMPATÍVEIS COM LOM204A

NO ARDUINO, ESCOLHA NUCLEO-L073RZ


ABRA O EXEMPLO EXEMPLO ABZ_CLIENT E ALTERE O CÓDIGO PARA 

// abz_client.pde // -*- mode: C++ -*- // Example sketch showing how to create a simple messageing client // with the RH_ABZ class. RH_ABZ class does not provide for addressing or // reliability, so you should only use RH_ABZ directly if you do not need the higher // level messaging abilities. // It is designed to work with the other example abz_server // Tested with Tested with EcoNode SmartTrap, Arduino 1.8.9, GrumpyOldPizza Arduino Core for STM32L0. #include <SPI.h> #include <RH_ABZ.h> // Singleton instance of the radio driver RH_ABZ abz; // Valid for SmartTrap, maybe not other boards void setup() { //MIGUEL //TCXO - ENABLE pinMode(24, OUTPUT); digitalWrite(24, HIGH); Serial.begin(9600); // Wait for serial port to be available // If you do this, it will block here until a USB serial connection is made. // If not, it will continue without a Serial connection, but DFU mode will not be available // to the host without resetting the CPU with the Boot button // while (!Serial) ; // You must be sure that the TCXO settings are appropriate for your board and radio. // See the RH_ABZ documentation for more information. // This call is adequate for Tlera boards supported by the Grumpy Old Pizza Arduino Core // It may or may not be innocuous for others SX1276SetBoardTcxo(true); delay(1); if (!abz.init()) Serial.println("init failed"); // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on abz.setFrequency(868.0); // You can change the modulation speed etc from the default //abz.setModemConfig(RH_RF95::Bw125Cr45Sf128); //abz.setModemConfig(RH_RF95::Bw125Cr45Sf2048); // The default transmitter power is 13dBm, using PA_BOOST. // You can set transmitter powers from 2 to 20 dBm: //abz.setTxPower(20); // Max power } void loop() { Serial.println("Sending to abz_server"); // Send a message to abz_server uint8_t data[] = "Hello World!"; abz.send(data, sizeof(data)); abz.waitPacketSent(); // Now wait for a reply uint8_t buf[RH_RF95_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); // You might need a longer timeout for slow modulatiuon schemes and/or long messages if (abz.waitAvailableTimeout(3000)) { // Should be a reply message for us now if (abz.recv(buf, &len)) { Serial.print("got reply: "); Serial.println((char*)buf); // Serial.print("RSSI: "); // Serial.println(abz.lastRssi(), DEC); } else { Serial.println("recv failed"); } } else { Serial.println("No reply, is abz_server running?"); } delay(400); }


ABRA O EXEMPLO EXEMPLO ABZ_SERVER E ALTERE O CÓDIGO PARA 

// abz_server.pde // -*- mode: C++ -*- // Example sketch showing how to create a simple messageing server // with the RH_ABZ class. RH_ABZ class does not provide for addressing or // reliability, so you should only use RH_ABZ directly if you do not need the higher // level messaging abilities. // It is designed to work with the other example abz_server // Tested with Tested with EcoNode SmartTrap, Arduino 1.8.9, GrumpyOldPizza Arduino Core for STM32L0. #include <SPI.h> #include <RH_ABZ.h> // Singleton instance of the radio driver RH_ABZ abz; void setup() { //MIGUEL //TCXO - ENABLE pinMode(24, OUTPUT); digitalWrite(24, HIGH); Serial.begin(9600); // Wait for serial port to be available // If you do this, it will block here until a USB serial connection is made. // If not, it will continue without a Serial connection, but DFU mode will not be available // to the host without resetting the CPU with the Boot button // while (!Serial) ; // You must be sure that the TCXO settings are appropriate for your board and radio. // See the RH_ABZ documentation for more information. // This call is adequate for Tlera boards supported by the Grumpy Old Pizza Arduino Core // It may or may not be innocuous for others SX1276SetBoardTcxo(true); delay(1); if (!abz.init()) Serial.println("init failed"); // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on abz.setFrequency(868.0); // You can change the modulation speed etc from the default //abz.setModemConfig(RH_RF95::Bw125Cr45Sf128); //abz.setModemConfig(RH_RF95::Bw125Cr45Sf2048); // The default transmitter power is 13dBm, using PA_BOOST. // You can set transmitter powers from 2 to 20 dBm: //abz.setTxPower(20); // Max power } void loop() { if (abz.available()) { // Should be a message for us now uint8_t buf[RH_RF95_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); if (abz.recv(buf, &len)) { // RH_ABZ::printBuffer("request: ", buf, len); Serial.print("got request: "); Serial.println((char*)buf); // Serial.print("RSSI: "); // Serial.println(abz.lastRssi(), DEC); // Send a reply uint8_t data[] = "And hello back to you"; abz.send(data, sizeof(data)); abz.waitPacketSent(); Serial.println("Sent a reply"); } else { Serial.println("recv failed"); } } }

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)

PRESSIONE O RESET ASSIM QUE O ARDUINO ACIONAR O OPENOCD

RESULTADOS

PA2 (TX) PA3(RX)


Sobre a SMARTCORE

A 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