RTT works
This commit is contained in:
60
Core/Src/uart_commands.c
Normal file
60
Core/Src/uart_commands.c
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "uart_commands.h"
|
||||
#include "tim.h"
|
||||
|
||||
enum name
|
||||
{
|
||||
ATop,
|
||||
ABottom,
|
||||
BTop,
|
||||
BBottom,
|
||||
CTop,
|
||||
CBottom,
|
||||
NAME_MAX
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CCR1_OFFSET = 0x34,
|
||||
CCR2_OFFSET = 0x38,
|
||||
CCR3_OFFSET = 0x3C,
|
||||
CCR4_OFFSET = 0x40,
|
||||
};
|
||||
|
||||
static volatile uint32_t *(pwm_registers)[NAME_MAX] =
|
||||
{
|
||||
(volatile uint32_t *)(TIM3_BASE + CCR1_OFFSET),
|
||||
(volatile uint32_t *)(TIM3_BASE + CCR2_OFFSET),
|
||||
(volatile uint32_t *)(TIM3_BASE + CCR3_OFFSET),
|
||||
(volatile uint32_t *)(TIM3_BASE + CCR4_OFFSET),
|
||||
(volatile uint32_t *)(TIM15_BASE + CCR1_OFFSET),
|
||||
(volatile uint32_t *)(TIM15_BASE + CCR2_OFFSET),
|
||||
};
|
||||
|
||||
// void Start_pwm(TIM_HandleTypeDef *htim, uint8_t no_channels)
|
||||
// {
|
||||
// HAL_StatusTypeDef ret;
|
||||
// uint32_t all_channels[] = {TIM_CHANNEL_1, TIM_CHANNEL_2, TIM_CHANNEL_3, TIM_CHANNEL_4};
|
||||
// for (uint8_t i = 0; i < no_channels; i++)
|
||||
// {
|
||||
// ret = HAL_TIM_PWM_Start(htim, all_channels[i]);
|
||||
// if (ret != HAL_OK)
|
||||
// {
|
||||
// Error_Handler();
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
void set_ccr(volatile uint32_t *CCRX, enum name name)
|
||||
{
|
||||
pwm_registers[name] = CCRX;
|
||||
}
|
||||
|
||||
void led_set(uint8_t power, uint8_t name, uint8_t mode)
|
||||
{
|
||||
*pwm_registers[name] = power * 199UL / 100;
|
||||
}
|
||||
|
||||
void led_get(uint8_t name)
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user