summaryrefslogtreecommitdiff
path: root/components/drivers/can
diff options
context:
space:
mode:
authorAubr.Cool <[email protected]>2015-07-07 12:06:24 +0800
committerAubr.Cool <[email protected]>2015-07-07 12:06:24 +0800
commit7051f01f48268e55f30a5cdf939b1a378d72a209 (patch)
tree877bd33cde4f33006d6424d3edea44e1fcbff9d1 /components/drivers/can
parent5f860e8f94445bd2186d2fbcac1a714c1815a9c1 (diff)
[DeviceDriver]can add bus_hook
Diffstat (limited to 'components/drivers/can')
-rw-r--r--components/drivers/can/can.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/components/drivers/can/can.c b/components/drivers/can/can.c
index 4de965a2fa..3781a24009 100644
--- a/components/drivers/can/can.c
+++ b/components/drivers/can/can.c
@@ -645,7 +645,11 @@ static rt_err_t rt_can_control(struct rt_device *dev,
}
break;
#endif /*RT_CAN_USING_HDR*/
-
+#ifdef RT_CAN_USING_BUS_HOOK
+ case RT_CAN_CMD_SET_BUS_HOOK:
+ can->bus_hook = (rt_can_bus_hook) args;
+ break;
+#endif /*RT_CAN_USING_BUS_HOOK*/
default :
/* control device */
if (can->ops->control != RT_NULL)
@@ -666,15 +670,21 @@ static void cantimeout(void *arg)
rt_can_t can = (rt_can_t)arg;
rt_device_control((rt_device_t)can, RT_CAN_CMD_GET_STATUS, (void *)&can->status);
- if (can->timerinitflag == 1)
- {
- can->timerinitflag = 0xFF;
- }
if (can->status_indicate.ind != RT_NULL)
{
can->status_indicate.ind(can, can->status_indicate.args);
}
+#ifdef RT_CAN_USING_BUS_HOOK
+ if(can->bus_hook)
+ {
+ can->bus_hook(can);
+ }
+#endif /*RT_CAN_USING_BUS_HOOK*/
+ if (can->timerinitflag == 1)
+ {
+ can->timerinitflag = 0xFF;
+ }
}
/*
@@ -699,7 +709,9 @@ rt_err_t rt_hw_can_register(struct rt_can_device *can,
can->can_rx = RT_NULL;
can->can_tx = RT_NULL;
rt_mutex_init(&(can->lock), "can", RT_IPC_FLAG_PRIO);
-
+#ifdef RT_CAN_USING_BUS_HOOK
+ can->bus_hook = RT_NULL;
+#endif /*RT_CAN_USING_BUS_HOOK*/
device->init = rt_can_init;
device->open = rt_can_open;
device->close = rt_can_close;