1.修改函数传参类型。
This commit is contained in:
@@ -51,45 +51,45 @@ mr_err_t ch32_adc_configure(mr_adc_t adc, mr_state_t state)
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
|
||||
mr_err_t ch32_adc_channel_configure(mr_adc_t adc, mr_uint16_t channel, mr_state_t state)
|
||||
mr_err_t ch32_adc_channel_configure(mr_adc_t adc, struct mr_adc_config *config)
|
||||
{
|
||||
struct ch32_adc *hw = (struct ch32_adc *)adc->device.data;
|
||||
GPIO_InitTypeDef GPIO_InitStructure = {0};
|
||||
GPIO_TypeDef *GPIOx = {0};
|
||||
|
||||
if (channel <= 7)
|
||||
if (config->channel <= 7)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
GPIOx = GPIOA;
|
||||
} else if (channel <= 10)
|
||||
} else if (config->channel <= 10)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
GPIOx = GPIOB;
|
||||
} else if (channel <= 15)
|
||||
} else if (config->channel <= 15)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||
GPIOx = GPIOC;
|
||||
}
|
||||
else if(channel <= 17)
|
||||
else if(config->channel <= 17)
|
||||
{
|
||||
ADC_TempSensorVrefintCmd(ENABLE);
|
||||
}
|
||||
else
|
||||
return -MR_ERR_INVALID;
|
||||
|
||||
if (state == MR_ENABLE)
|
||||
if (config->state == MR_ENABLE)
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
else
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = (1 << channel);
|
||||
GPIO_InitStructure.GPIO_Pin = (1 << config->channel);
|
||||
GPIO_Init(GPIOx, &GPIO_InitStructure);
|
||||
|
||||
MR_LOG_D(LOG_TAG,
|
||||
"Config %s %d %d\r\n",
|
||||
hw->name,
|
||||
channel,
|
||||
state);
|
||||
config->channel,
|
||||
config->state);
|
||||
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ mr_err_t ch32_dac_configure(mr_dac_t dac, mr_state_t state)
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
|
||||
mr_err_t ch32_dac_channel_configure(mr_dac_t dac, mr_uint16_t channel, mr_state_t state)
|
||||
mr_err_t ch32_dac_channel_configure(mr_dac_t dac, struct mr_dac_config *config)
|
||||
{
|
||||
struct ch32_dac *hw = (struct ch32_dac *)dac->device.data;
|
||||
GPIO_InitTypeDef GPIO_InitStructure = {0};
|
||||
@@ -83,8 +83,8 @@ mr_err_t ch32_dac_channel_configure(mr_dac_t dac, mr_uint16_t channel, mr_state_
|
||||
MR_LOG_D(LOG_TAG,
|
||||
"Config %s %d %d\r\n",
|
||||
hw->name,
|
||||
channel,
|
||||
state);
|
||||
config->channel,
|
||||
config->state);
|
||||
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user