This project is a part of a larger project CubeMonitor+Vue Demo. This part contains the code for MCU created with HAL libraries, in this for STM32F407 evaluation board (code is quite portable if you do not have exactly this board).
Check this project github page for more info and Doxygen build documentation.
Check the UI Vue part for integration with CubeMonitor
You will need: - STM32F407 Discovery board or any other evaluation board - STM IDE (turns out the Atollic and STM IDE are not really back-compatible, the configuration is broken...)
Steps:
- Fork and clone this repository
- Import the project into STM IDE
- (if you have the STM32F407 Discovery board) flash it with the
program_VX.X.hex
from the Release folder - (build yourself for a different MCU) The project setting should be imported as well but just to be sure this is the build command used:
-mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F407xx -c -I../Core/Inc -I../Drivers/STM32F4xx_HAL_Driver/Inc -I../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb
- Continue with the VUE part setup
This project was created to demonstrate the possibilities of the CubeMonitor Vue UI, but it also contains libraries that can be used separately.
- make sure to define your HW correctly, if you are not using STM HAL, redefine the weak function
input_get_hw_HAL
- define symbol
LIB_DI
- create an enum listing all inputs you would like to use, do not forget to include one extra named
DI_NONE
typedef enum digInputs {
YOUR_INPUT_1,
YOUR_INPUT_2,
DI_NONE,
}digInputs;
- initialize your inputs using
input_init
anddigitalInputInitData
structure. Check the documentation for more info on the types.
digitalInputInitData digital_input_init;
digital_input_init.debounc_time = DI_DEBOUNC_MS;
digital_input_init.double_press_spacing = DI_DOUBLE_PRESS_SPACING;
digital_input_init.long_press_ms = DI_LONG_PRESS_MIN_DURATION;
digital_input_init.input_get_hw_state = NULL;
digital_input_init.mcu_pin = BUTTON_Pin;
digital_input_init.mcu_port = BUTTON_GPIO_Port;
digital_input_init.sw_type = INPUT_SW_BUTTON;
digital_input_init.hw_type = INPUT_HW_ACTIVE_HIGH;
input_init(DI_BUTTON, digital_input_init);
- call the
input_handle
every 1ms - then you can use
input_get_action
to fetch input actions:
INPUT_ACT_FALLING_EDGE
INPUT_ACT_RISING_EDGE
INPUT_ACT_SHORT_PRESS
INPUT_ACT_LONG_PRESS
INPUT_ACT_DOUBLE_PRESS
- make sure to define your HW correctly
- define symbol
LIB_AI
- create an enum listing all analog inputs you would like to use, do not forget to include one extra named
AI_NONE
typedef enum anaInputs {
YOUR_ANALOG_INPUT_1,
YOUR_ANALOG_INPUT_2,
AI_NONE
}anaInputs;
- initialize your inputs using
analog_input_init
Check the documentation for more info on the types.
analog_input_init(AI_1, AI_SAMPLING_AI1,
lin_adc_no_scaling_no_corrections);
- call
analog_input_start
- place
analog_input_handle
intoHAL_ADC_ConvCpltCallback
- fetch current value, averaged current value or directly scaled voltage with
analog_input_get