Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added LORA-E5 and RAK3172 lorawan modules #14859

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,49 @@
#include "STM32WL_radio_driver.h"
#include "drivers/DigitalOut.h"


/* Sets up radio switch position according to the radio mode */
#if defined (TARGET_LORA_E5) || defined (TARGET_RAK3172)
Copy link
Collaborator

@jeromecoutant jeromecoutant Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this list of define will not be "nice" when we will add again more targets? :-)

Proposition:

  • create a new sub-directory here TARGET_NUCLEO_WL55JC with this current file inside
  • you can the create TARGET_LORA_E5 and TARGET_RAK3172 with the specific file content
    ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah don't like these define either. Subfolder is great, the deal is that I'm not a guru of cmake, so not sure how to tell which dir to include depending on target, I'll try that.

Copy link

@MarceloSalazar MarceloSalazar Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have targets configuration in libraries - these should be hw agnostic.
Instead, you can propose a sw configuration to enable/disable features. This could be used by any target configuration (e.g through mbed_app.json).

Copy link
Contributor Author

@hallard hallard Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, looks like it was easier than I thought

/* This configuration is for RAK3172 or LoRa-E5 modules */
/* Theese one use only HP mode the LP mode is not connected nor RF Switch ctrl3 */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo issues

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you precise what do you want me to fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/* Added to avoid declarion in sample code for lorawan example with these mmodules */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/* But provided as __weak so it has to be overwritten to match each specicific HW board */
MBED_WEAK void set_antenna_switch(RBI_Switch_TypeDef state)
{
// Radio specific controls (TX/RX duplexer switch control)
mbed::DigitalOut _rf_switch_ctrl1(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL1);
mbed::DigitalOut _rf_switch_ctrl2(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL2);

switch (state) {
case RBI_SWITCH_OFF: {
/* Turn off switch */
_rf_switch_ctrl1 = 0;
_rf_switch_ctrl2 = 0;
break;
}
case RBI_SWITCH_RX: {
/*Turns On in Rx Mode the RF Switch */
_rf_switch_ctrl1 = 1;
_rf_switch_ctrl2 = 0;
break;
}
case RBI_SWITCH_RFO_LP: {
/*Turns On in Tx High Power the RF Switch */
_rf_switch_ctrl1 = 0;
_rf_switch_ctrl2 = 1;
break;
}
case RBI_SWITCH_RFO_HP: {
/*Turns On in Tx High Power the RF Switch */
_rf_switch_ctrl1 = 0;
_rf_switch_ctrl2 = 1;
break;
}
default:
break;
}
}

#else
/* This configuration is for NUCLEO_WL55JC */
/* But provided as __weak so it has to be overwritten to match each specicific HW board */
MBED_WEAK void set_antenna_switch(RBI_Switch_TypeDef state)
Expand Down Expand Up @@ -62,3 +103,4 @@ MBED_WEAK void set_antenna_switch(RBI_Switch_TypeDef state)
}
}

#endif
8 changes: 8 additions & 0 deletions connectivity/drivers/lora/TARGET_STM32WL/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
"rf-switch-ctl1": "PC_4",
"rf-switch-ctl2": "PC_5",
"rf-switch-ctl3": "PC_3"
},
"LORA_E5": {
"rf-switch-ctl1": "PA_4",
"rf-switch-ctl2": "PA_5"
},
"RAK3172": {
"rf-switch-ctl1": "PB_8",
"rf-switch-ctl2": "PC_13"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(TARGET_LORA_E5 EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_RAK3172 EXCLUDE_FROM_ALL)

if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32wle5xx.S)
set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32wle5xc.ld)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32wle5xx.S)
set(LINKER_FILE TOOLCHAIN_ARM/stm32wle5xc.sct)
endif()

add_library(mbed-stm32wle5xc INTERFACE)

target_sources(mbed-stm32wle5xc
INTERFACE
${STARTUP_FILE}
)

target_include_directories(mbed-stm32wle5xc
INTERFACE
.
)

mbed_set_linker_script(mbed-stm32wle5xc ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})

target_link_libraries(mbed-stm32wle5xc INTERFACE mbed-stm32wl)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_library(mbed-lora-e5 INTERFACE)

target_sources(mbed-lora-e5
INTERFACE
PeripheralPins.c
system_clock.c
)

target_include_directories(mbed-lora-e5
INTERFACE
.
)

target_link_libraries(mbed-lora-e5 INTERFACE mbed-stm32wle5xc)
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* mbed Microcontroller Library
* Copyright (c) 2019 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_PERIPHERALNAMES_H
#define MBED_PERIPHERALNAMES_H

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you want, but I think we can move this file at TARGET_STM32WL level to be common for all ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolutely, once gain, need knowledge of CMake, will try.

Copy link
Contributor Author

@hallard hallard Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you ok to move 3 files PeripheralNames.c PeripheralPins.h system_clock.c to TARGET_STM32WL and keep only PinNames.h in target folder?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • PeripheralPins.c : no, specific for each target (you can manually disable or not a pin, you can add comment, etc...)
  • PeripheralNames.h : yes
  • system_clock.c: why not, as SetSysClock is weak

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok done

#include "cmsis.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
DAC_1 = (int)DAC_BASE
} DACName;


typedef enum {
ADC_1 = (int)ADC_BASE
} ADCName;


typedef enum {
UART_1 = (int)USART1_BASE,
UART_2 = (int)USART2_BASE,
LPUART_1 = (int)LPUART1_BASE
} UARTName;

#define DEVICE_SPI_COUNT 2
typedef enum {
SPI_1 = (int)SPI1_BASE,
SPI_2 = (int)SPI2_BASE
} SPIName;

typedef enum {
I2C_1 = (int)I2C1_BASE,
I2C_2 = (int)I2C2_BASE,
I2C_3 = (int)I2C3_BASE
} I2CName;

typedef enum {
PWM_1 = (int)TIM1_BASE,
PWM_2 = (int)TIM2_BASE,
PWM_16 = (int)TIM16_BASE,
PWM_17 = (int)TIM17_BASE
} PWMName;


#ifdef __cplusplus
}
#endif

#endif
Loading