Skip to content

Commit

Permalink
fix hardfault when RT_CAN_USING_BUS_HOOK is enabled in bsp/stm32f10x
Browse files Browse the repository at this point in the history
function `rt_pin_write` is invoked by  function `can_bus_hook`, and it should to be initialized by gpio.c.
but gpio.c was not added in SConscript
  • Loading branch information
gbcwbz committed Apr 14, 2016
1 parent b420e83 commit 0d63eb5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bsp/stm32f10x/drivers/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ led.c
usart.c
""")

if GetDepend(['RT_USING_PIN']):
src += ['gpio.c']

# add canbus driver.
if GetDepend('RT_USING_CAN'):
src += ['bxcan.c']
Expand Down
2 changes: 1 addition & 1 deletion bsp/stm32f10x/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

#define RT_USING_CAN

//#define RT_CAN_USING_BUS_HOOK
#define RT_CAN_USING_BUS_HOOK

#define RT_CAN_USING_HDR
/* SECTION: device filesystem */
Expand Down
3 changes: 3 additions & 0 deletions components/drivers/misc/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,21 @@ int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void
/* RT-Thread Hardware PIN APIs */
void rt_pin_mode(rt_base_t pin, rt_base_t mode)
{
RT_ASSERT(_hw_pin.ops != RT_NULL);
_hw_pin.ops->pin_mode(&_hw_pin.parent, pin, mode);
}
FINSH_FUNCTION_EXPORT_ALIAS(rt_pin_mode, pinMode, set hardware pin mode);

void rt_pin_write(rt_base_t pin, rt_base_t value)
{
RT_ASSERT(_hw_pin.ops != RT_NULL);
_hw_pin.ops->pin_write(&_hw_pin.parent, pin, value);
}
FINSH_FUNCTION_EXPORT_ALIAS(rt_pin_write, pinWrite, write value to hardware pin);

int rt_pin_read(rt_base_t pin)
{
RT_ASSERT(_hw_pin.ops != RT_NULL);
return _hw_pin.ops->pin_read(&_hw_pin.parent, pin);
}
FINSH_FUNCTION_EXPORT_ALIAS(rt_pin_read, pinRead, read status from hardware pin);

0 comments on commit 0d63eb5

Please sign in to comment.