1.修复驱动部分问题。
This commit is contained in:
@@ -52,33 +52,54 @@ static mr_err_t ch32_adc_channel_configure(mr_adc_t adc, mr_adc_config_t config)
|
||||
|
||||
for (count = 0; count <= 17; count++)
|
||||
{
|
||||
if (((1 << count) & config->channel._mask) == MR_ENABLE)
|
||||
if (count <= 7)
|
||||
{
|
||||
if (count <= 7)
|
||||
if (((1 << count) & config->channel._mask) == MR_ENABLE)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
GPIOx = GPIOA;
|
||||
} else if (count <= 10)
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
} else
|
||||
{
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
}
|
||||
GPIOx = GPIOA;
|
||||
GPIO_InitStructure.GPIO_Pin = (1 << count);
|
||||
GPIO_Init(GPIOx, &GPIO_InitStructure);
|
||||
} else if (count <= 10)
|
||||
{
|
||||
if (((1 << count) & config->channel._mask) == MR_ENABLE)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
GPIOx = GPIOB;
|
||||
} else if (count <= 15)
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
} else
|
||||
{
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
}
|
||||
GPIOx = GPIOB;
|
||||
GPIO_InitStructure.GPIO_Pin = (1 << count);
|
||||
GPIO_Init(GPIOx, &GPIO_InitStructure);
|
||||
} else if (count <= 15)
|
||||
{
|
||||
if (((1 << count) & config->channel._mask) == MR_ENABLE)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||
GPIOx = GPIOC;
|
||||
} else if (count <= 17)
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
} else
|
||||
{
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
}
|
||||
GPIOx = GPIOC;
|
||||
GPIO_InitStructure.GPIO_Pin = (1 << count);
|
||||
GPIO_Init(GPIOx, &GPIO_InitStructure);
|
||||
} else if (count <= 17)
|
||||
{
|
||||
if (((1 << count) & config->channel._mask) == MR_ENABLE)
|
||||
{
|
||||
ADC_TempSensorVrefintCmd(ENABLE);
|
||||
} else
|
||||
{
|
||||
ADC_TempSensorVrefintCmd(DISABLE);
|
||||
}
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
GPIO_InitStructure.GPIO_Pin = (1 << count);
|
||||
GPIO_Init(GPIOx, &GPIO_InitStructure);
|
||||
} else
|
||||
{
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
GPIO_InitStructure.GPIO_Pin = (1 << count);
|
||||
GPIO_Init(GPIOx, &GPIO_InitStructure);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +148,7 @@ mr_err_t drv_adc_init(void)
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
}
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_adc_init);
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ mr_err_t drv_dac_init(void)
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
}
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_dac_init);
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ mr_err_t drv_gpio_init(void)
|
||||
ret = mr_pin_device_add(&pin_device, "pin", &drv_ops, MR_NULL);
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_gpio_init);
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ mr_err_t drv_soft_i2c_bus_init(void)
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
}
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_soft_i2c_bus_init);
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ mr_err_t drv_pwm_init(void)
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
}
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_pwm_init);
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ mr_err_t drv_spi_bus_init(void)
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
}
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_spi_bus_init);
|
||||
|
||||
|
||||
@@ -151,7 +151,6 @@ static mr_err_t ch32_timer_configure(mr_timer_t timer, mr_timer_config_t config)
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
TIM_ClearITPendingBit(timer_data->instance, TIM_IT_Update);
|
||||
TIM_ITConfig(timer_data->instance, TIM_IT_Update, ENABLE);
|
||||
|
||||
TIM_TimeBaseInitStructure.TIM_Period = 0;
|
||||
@@ -166,7 +165,7 @@ static void ch32_timer_start(mr_timer_t timer, mr_uint32_t period_reload)
|
||||
{
|
||||
struct ch32_timer_data *timer_data = (struct ch32_timer_data *)timer->device.data;
|
||||
|
||||
if (timer->data->count_max == MR_TIMER_COUNT_MODE_UP)
|
||||
if (timer->data->count_mode == MR_TIMER_COUNT_MODE_UP)
|
||||
{
|
||||
timer_data->instance->CNT = 0;
|
||||
} else
|
||||
@@ -174,6 +173,7 @@ static void ch32_timer_start(mr_timer_t timer, mr_uint32_t period_reload)
|
||||
timer_data->instance->CNT = period_reload - 1;
|
||||
}
|
||||
timer_data->instance->ATRLR = period_reload - 1;
|
||||
|
||||
TIM_Cmd(timer_data->instance, ENABLE);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ mr_err_t drv_timer_init(void)
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
}
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_timer_init);
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ mr_err_t drv_uart_init(void)
|
||||
MR_ASSERT(ret == MR_ERR_OK);
|
||||
}
|
||||
|
||||
return MR_ERR_OK;
|
||||
return ret;
|
||||
}
|
||||
MR_INIT_DRIVER_EXPORT(drv_uart_init);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user