Is there a way to add code that should disable PWM on a SysHalt?
I have the problem that when Chibi does a SysHalt and I am flying a quadrotor on it, the motor throttle PWM gets stuck and horror follows.
So I want to disable the PWM on SysHalt, but the problem I have is when I add a pwmStop (and include the headers for hal) I get an army of errors as:
Code: Select all
Compiling crt0_v7m.s
Compiling chcoreasm_v7m.s
Compiling crt1.c
Compiling vectors.c
Compiling chsys.c
In file included from ./ChibiOS/os/hal/include/hal.h:28:0,
from ./chconf.h:488,
from ./ChibiOS/os/rt/include/ch.h:71,
from ./ChibiOS/os/rt/src/chsys.c:36:
./ChibiOS/os/hal/osal/rt/osal.h: In function 'DisableMotors':
./ChibiOS/os/hal/osal/rt/osal.h:449:20: error: invalid storage class for function 'osalInit'
static inline void osalInit(void) {
^
./ChibiOS/os/hal/osal/rt/osal.h:460:20: error: invalid storage class for function 'osalSysHalt'
static inline void osalSysHalt(const char *reason) {
^
./ChibiOS/os/hal/osal/rt/osal.h: In function 'osalSysHalt':
./ChibiOS/os/hal/osal/rt/osal.h:462:3: warning: implicit declaration of function 'chSysHalt' [-Wimplicit-function-declaration]
chSysHalt(reason);
^
./ChibiOS/os/hal/osal/rt/osal.h: In function 'DisableMotors':
./ChibiOS/os/hal/osal/rt/osal.h:470:20: error: invalid storage class for function 'osalSysDisable'
static inline void osalSysDisable(void) {
^
./ChibiOS/os/hal/osal/rt/osal.h: In function 'osalSysDisable':
./ChibiOS/os/hal/osal/rt/osal.h:472:3: warning: implicit declaration of function 'chSysDisable' [-Wimplicit-function-declaration]
chSysDisable();
^
./ChibiOS/os/hal/osal/rt/osal.h: In function 'DisableMotors':
./ChibiOS/os/hal/osal/rt/osal.h:480:20: error: invalid storage class for function 'osalSysEnable'
static inline void osalSysEnable(void) {
^
./ChibiOS/os/hal/osal/rt/osal.h: In function 'osalSysEnable':
./ChibiOS/os/hal/osal/rt/osal.h:482:3: warning: implicit declaration of function 'chSysEnable' [-Wimplicit-function-declaration]
chSysEnable();
^
./ChibiOS/os/hal/osal/rt/osal.h: In function 'DisableMotors':
./ChibiOS/os/hal/osal/rt/osal.h:491:20: error: invalid storage class for function 'osalSysLock'
static inline void osalSysLock(voi
Code for disable motors:
Code: Select all
void RCOutputDisable(void)
{
if (rcoutput_cfg != NULL)
{
pwmDisableChannel(rcoutput_cfg->pwmp_lowbank, 0, 0);
pwmDisableChannel(rcoutput_cfg->pwmp_lowbank, 1, 0);
pwmDisableChannel(rcoutput_cfg->pwmp_lowbank, 2, 0);
pwmDisableChannel(rcoutput_cfg->pwmp_lowbank, 3, 0);
pwmDisableChannel(rcoutput_cfg->pwmp_highbank, 0, 0);
pwmDisableChannel(rcoutput_cfg->pwmp_highbank, 1, 0);
pwmDisableChannel(rcoutput_cfg->pwmp_highbank, 2, 0);
pwmDisableChannel(rcoutput_cfg->pwmp_highbank, 3, 0);
pwmStop(rcoutput_cfg->pwmp_lowbank, rcoutput_cfg->pwmcfg);
pwmStop(rcoutput_cfg->pwmp_highbank, rcoutput_cfg->pwmcfg);
}
}
Hook definition:
Code: Select all
#if !defined(_FROM_ASM_)
static inline void DisableMotors(void)
{
#include "ch.h"
#include "hal.h"
#include "rc_output.h"
RCOutputDisable();
}
#endif
/**
* @brief System halt hook.
* @details This hook is invoked in case to a system halting error before
* the system is halted.
*/
#define CH_CFG_SYSTEM_HALT_HOOK(reason) DisableMotors()
Any idea on how to fix this?
Best
Emil