fix bugs of hc32 driver adc and can (#6077)
* fix bugs of hc32 driver adc and can
This commit is contained in:
parent
14cd8d0145
commit
c8d92d7529
|
@ -237,7 +237,7 @@ menu "On-chip Peripheral Drivers"
|
||||||
bool "Enable CAN"
|
bool "Enable CAN"
|
||||||
default n
|
default n
|
||||||
select RT_USING_CAN
|
select RT_USING_CAN
|
||||||
select BSP_USING_TCA9539
|
select RT_CAN_USING_HDR
|
||||||
if BSP_USING_CAN
|
if BSP_USING_CAN
|
||||||
config BSP_USING_CAN1
|
config BSP_USING_CAN1
|
||||||
bool "using can1"
|
bool "using can1"
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2022-04-28 CDT first version
|
* 2022-04-28 CDT first version
|
||||||
* 2022-06-08 xiaoxiaolisunny add hc32f460 series
|
* 2022-06-08 xiaoxiaolisunny add hc32f460 series
|
||||||
|
* 2022-06-14 CDT fix a bug of internal trigger
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
|
@ -128,8 +129,8 @@ static void _adc_internal_trigger1_set(adc_device *p_adc_dev)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG1, (en_functional_state_t)p_adc_dev->init.internal_trig0_comtrg0_enable);
|
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG1, (en_functional_state_t)p_adc_dev->init.internal_trig1_comtrg0_enable);
|
||||||
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG2, (en_functional_state_t)p_adc_dev->init.internal_trig0_comtrg1_enable);
|
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG2, (en_functional_state_t)p_adc_dev->init.internal_trig1_comtrg1_enable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HC32F460)
|
#if defined(HC32F460)
|
||||||
|
@ -144,8 +145,8 @@ static void _adc_internal_trigger1_set(adc_device *p_adc_dev)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG1, (en_functional_state_t)p_adc_dev->init.internal_trig0_comtrg0_enable);
|
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG1, (en_functional_state_t)p_adc_dev->init.internal_trig1_comtrg0_enable);
|
||||||
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG2, (en_functional_state_t)p_adc_dev->init.internal_trig0_comtrg1_enable);
|
AOS_CommonTriggerCmd(u32TriggerSel, AOS_COMM_TRIG2, (en_functional_state_t)p_adc_dev->init.internal_trig1_comtrg1_enable);
|
||||||
#endif
|
#endif
|
||||||
AOS_SetTriggerEventSrc(u32TriggerSel, p_adc_dev->init.internal_trig1_sel);
|
AOS_SetTriggerEventSrc(u32TriggerSel, p_adc_dev->init.internal_trig1_sel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2022-04-28 CDT first version
|
* 2022-04-28 CDT first version
|
||||||
* 2022-06-07 xiaoxiaolisunny add hc32f460 series
|
* 2022-06-07 xiaoxiaolisunny add hc32f460 series
|
||||||
|
* 2022-06-08 CDT fix a bug of RT_CAN_CMD_SET_FILTER
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "drv_can.h"
|
#include "drv_can.h"
|
||||||
|
@ -274,7 +275,14 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
|
||||||
{
|
{
|
||||||
p_can_dev->ll_init.pstcFilter[i].u32ID = filter_cfg->items[i].id;
|
p_can_dev->ll_init.pstcFilter[i].u32ID = filter_cfg->items[i].id;
|
||||||
p_can_dev->ll_init.pstcFilter[i].u32IDMask = filter_cfg->items[i].mask;
|
p_can_dev->ll_init.pstcFilter[i].u32IDMask = filter_cfg->items[i].mask;
|
||||||
p_can_dev->ll_init.pstcFilter[i].u32IDType = filter_cfg->items[i].ide;
|
if (filter_cfg->items[i].ide == RT_CAN_STDID)
|
||||||
|
{
|
||||||
|
p_can_dev->ll_init.pstcFilter[i].u32IDType = CAN_ID_STD;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p_can_dev->ll_init.pstcFilter[i].u32IDType = CAN_ID_EXT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)CAN_Init(p_can_dev->instance, &p_can_dev->ll_init);
|
(void)CAN_Init(p_can_dev->instance, &p_can_dev->ll_init);
|
||||||
|
@ -623,7 +631,7 @@ int rt_hw_can_init(void)
|
||||||
g_can_dev_array[i].ll_init.u16FilterSelect = CAN_FILTER1;
|
g_can_dev_array[i].ll_init.u16FilterSelect = CAN_FILTER1;
|
||||||
g_can_dev_array[i].rt_can.config = rt_can_config;
|
g_can_dev_array[i].rt_can.config = rt_can_config;
|
||||||
|
|
||||||
/* register CAN1 device */
|
/* register CAN device */
|
||||||
rt_hw_board_can_init(g_can_dev_array[i].instance);
|
rt_hw_board_can_init(g_can_dev_array[i].instance);
|
||||||
rt_hw_can_register(&g_can_dev_array[i].rt_can,
|
rt_hw_can_register(&g_can_dev_array[i].rt_can,
|
||||||
g_can_dev_array[i].init.name,
|
g_can_dev_array[i].init.name,
|
||||||
|
|
Loading…
Reference in New Issue