|
|
@ -38,7 +38,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
SPI_HandleTypeDef hspi1;
|
|
|
|
SPI_HandleTypeDef hspi1;
|
|
|
|
|
|
|
|
|
|
|
|
TIM_HandleTypeDef htim1;
|
|
|
|
TIM_HandleTypeDef htim1;
|
|
|
|
TIM_HandleTypeDef htim2;
|
|
|
|
TIM_HandleTypeDef htim2;
|
|
|
|
|
|
|
|
|
|
|
@ -67,7 +66,6 @@ static void MX_SPI1_Init(void);
|
|
|
|
int main(void)
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
// прописать нули в л12 л11
|
|
|
|
|
|
|
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
|
|
|
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
|
|
|
|
GPIOA->MODER &= ~(3U << (0 * 2));
|
|
|
|
GPIOA->MODER &= ~(3U << (0 * 2));
|
|
|
|
GPIOA->MODER &= ~(3U << (3 * 2));
|
|
|
|
GPIOA->MODER &= ~(3U << (3 * 2));
|
|
|
@ -107,9 +105,7 @@ int main(void)
|
|
|
|
uint8_t recData[10] = {0};
|
|
|
|
uint8_t recData[10] = {0};
|
|
|
|
|
|
|
|
|
|
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, GPIO_PIN_SET);
|
|
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, GPIO_PIN_SET);
|
|
|
|
//volatile uint32_t start_ticks = DWT->CYCCNT;
|
|
|
|
|
|
|
|
if (HAL_SPI_Receive(&hspi1, recData, 10, HAL_MAX_DELAY) == HAL_OK) {
|
|
|
|
if (HAL_SPI_Receive(&hspi1, recData, 10, HAL_MAX_DELAY) == HAL_OK) {
|
|
|
|
//volatile uint32_t end_ticks= DWT->CYCCNT;
|
|
|
|
|
|
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, GPIO_PIN_RESET);
|
|
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, GPIO_PIN_RESET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//----------------КАНАЛ 1---------------
|
|
|
|
//----------------КАНАЛ 1---------------
|
|
|
@ -141,10 +137,8 @@ int main(void)
|
|
|
|
modes[1].pwm_value_res = (modes[1].pwm_value * modes[1].freq_pwm_new) / MAX_PWM_FREQ; // пересчет скважности для 2 канала
|
|
|
|
modes[1].pwm_value_res = (modes[1].pwm_value * modes[1].freq_pwm_new) / MAX_PWM_FREQ; // пересчет скважности для 2 канала
|
|
|
|
|
|
|
|
|
|
|
|
HAL_TIM_Base_Start_IT(&htim1);
|
|
|
|
HAL_TIM_Base_Start_IT(&htim1);
|
|
|
|
while (1)
|
|
|
|
while (1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
/* USER CODE END WHILE */
|
|
|
|
/* USER CODE END WHILE */
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
|
|
if (channel == 1 && settings_set == 0) {
|
|
|
|
if (channel == 1 && settings_set == 0) {
|
|
|
|
settings_set = 1; // канал 1 настроен
|
|
|
|
settings_set = 1; // канал 1 настроен
|
|
|
|