mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 23:10:22 +00:00
3c2711102c
* Lib: move cube to libs. Firmware: prepare for code base refactoring, detach from cube, port to cmsis_os2. * Firmware, target f2: regenerate project with latest cube package, tim17 for os ticks. * Firmware: unified codebase. * Core: do not include semaphore on old targets. Firmware: dfu uplaod target. * CI: submodules, add firmware build. * CI: proper submodule config. * refactor build system * CI: update chain to use new targets. Documentation: update to match current structure. * CI: clean before rebuild. * Add local test docker-compose exec dev make -C firmware TARGET=local TEST=1 run * Makefile: target specific build directory. CI: updated artifacts path. * Makefile: init git submodules if they don't exists. * Makefile: debug rule now doesn't reset MCU, prevent SIGINT propagation to st-util. * Makefile: proper rebuild sequence in zz and zzz * Makefile: timestamp tracking for flash and upload commands. * Apps: modular build. Input: fix flipper hal inline. * Wiki: proper bootloader link. * Applications: fix broken build for local targets. * add st-flash to docker * fix build * force rebuild app * move app force to firmware part * fix build deps * qrcode build ok * fix example display * add testing routine * update build instruction Co-authored-by: Aleksandr Kutuzov <aku@plooks.com> Co-authored-by: aanper <mail@s3f.ru>
60 lines
No EOL
1.6 KiB
C
60 lines
No EOL
1.6 KiB
C
/*
|
|
Flipper devices inc.
|
|
|
|
GPIO and HAL implementations
|
|
*/
|
|
|
|
#include "main.h"
|
|
#include "flipper_hal.h"
|
|
|
|
void app_gpio_init(GpioPin gpio, GpioMode mode) {
|
|
if(gpio.pin != 0) {
|
|
GPIO_InitTypeDef GPIO_InitStruct;
|
|
|
|
GPIO_InitStruct.Pin = gpio.pin;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
switch(mode) {
|
|
case GpioModeInput:
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
break;
|
|
|
|
case GpioModeOutput:
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
|
break;
|
|
|
|
case GpioModeOpenDrain:
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
|
break;
|
|
}
|
|
|
|
HAL_GPIO_Init(gpio.port, &GPIO_InitStruct);
|
|
}
|
|
}
|
|
|
|
// TODO delay from timer
|
|
void delay_us(uint32_t time) {
|
|
time *= 11.8;
|
|
|
|
while(time--) {
|
|
}
|
|
}
|
|
|
|
void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) {
|
|
tim->Init.CounterMode = TIM_COUNTERMODE_UP;
|
|
tim->Init.Period = (uint32_t)((SystemCoreClock / tim->Init.Prescaler) / freq);
|
|
tim->Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
|
tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
|
HAL_TIM_PWM_Init(tim);
|
|
|
|
TIM_OC_InitTypeDef sConfigOC;
|
|
|
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
|
sConfigOC.Pulse = (uint16_t)(291 * value);
|
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
|
HAL_TIM_PWM_ConfigChannel(tim, &sConfigOC, channel);
|
|
HAL_TIM_PWM_Start(tim, channel);
|
|
} |