diff options
author | barthess <barthess@yandex.ru> | 2016-03-28 21:36:54 +0300 |
---|---|---|
committer | barthess <barthess@yandex.ru> | 2016-03-28 21:36:54 +0300 |
commit | c0e6748a9f9775f65a4fe2553d9ea2773d0380d8 (patch) | |
tree | cd8a6612d09852ba76474fed29fcd4c41d08b271 /os | |
parent | 53684030c9bb055e706a3f9c4826ecd52a0d31f7 (diff) | |
download | ChibiOS-Contrib-c0e6748a9f9775f65a4fe2553d9ea2773d0380d8.tar.gz ChibiOS-Contrib-c0e6748a9f9775f65a4fe2553d9ea2773d0380d8.tar.bz2 ChibiOS-Contrib-c0e6748a9f9775f65a4fe2553d9ea2773d0380d8.zip |
1-wire. Fixed possible deadlock situation.
In old code thread could be suspended *after* the callback was called.
New code protected with more wide critical section.
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/src/onewire.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/os/hal/src/onewire.c b/os/hal/src/onewire.c index d11196c..85f0fdc 100644 --- a/os/hal/src/onewire.c +++ b/os/hal/src/onewire.c @@ -664,11 +664,11 @@ bool onewireReset(onewireDriver *owp) { pwmcfg->channels[sch].mode = PWM_OUTPUT_ACTIVE_LOW; ow_bus_active(owp); - pwmEnableChannel(pwmd, mch, ONEWIRE_RESET_LOW_WIDTH); - pwmEnableChannel(pwmd, sch, ONEWIRE_RESET_SAMPLE_WIDTH); - pwmEnableChannelNotification(pwmd, sch); osalSysLock(); + pwmEnableChannelI(pwmd, mch, ONEWIRE_RESET_LOW_WIDTH); + pwmEnableChannelI(pwmd, sch, ONEWIRE_RESET_SAMPLE_WIDTH); + pwmEnableChannelNotificationI(pwmd, sch); osalThreadSuspendS(&owp->thread); osalSysUnlock(); @@ -717,11 +717,10 @@ void onewireRead(onewireDriver *owp, uint8_t *rxbuf, size_t rxbytes) { pwmcfg->channels[sch].mode = PWM_OUTPUT_ACTIVE_LOW; ow_bus_active(owp); - pwmEnableChannel(pwmd, mch, ONEWIRE_ONE_WIDTH); - pwmEnableChannel(pwmd, sch, ONEWIRE_SAMPLE_WIDTH); - pwmEnableChannelNotification(pwmd, sch); - osalSysLock(); + pwmEnableChannelI(pwmd, mch, ONEWIRE_ONE_WIDTH); + pwmEnableChannelI(pwmd, sch, ONEWIRE_SAMPLE_WIDTH); + pwmEnableChannelNotificationI(pwmd, sch); osalThreadSuspendS(&owp->thread); osalSysUnlock(); @@ -776,9 +775,8 @@ void onewireWrite(onewireDriver *owp, uint8_t *txbuf, #endif ow_bus_active(owp); - pwmEnablePeriodicNotification(pwmd); - osalSysLock(); + pwmEnablePeriodicNotificationI(pwmd); osalThreadSuspendS(&owp->thread); osalSysUnlock(); @@ -853,11 +851,10 @@ size_t onewireSearchRom(onewireDriver *owp, uint8_t *result, pwmcfg->channels[sch].mode = PWM_OUTPUT_ACTIVE_LOW; ow_bus_active(owp); - pwmEnableChannel(pwmd, mch, ONEWIRE_ONE_WIDTH); - pwmEnableChannel(pwmd, sch, ONEWIRE_SAMPLE_WIDTH); - pwmEnableChannelNotification(pwmd, sch); - osalSysLock(); + pwmEnableChannelI(pwmd, mch, ONEWIRE_ONE_WIDTH); + pwmEnableChannelI(pwmd, sch, ONEWIRE_SAMPLE_WIDTH); + pwmEnableChannelNotificationI(pwmd, sch); osalThreadSuspendS(&owp->thread); osalSysUnlock(); |