Corrected minor bug that prevented the use of long periods (beyond 500ms).
Updated timer instance to be const to allow compiler optimisation
minor code cleanups
The previous pwm implementation was subject to innaccurracies
due to BLE interrupts. This new implementation, courtesy of
@finneyj is resiliant to BLE interrupts, other than a small
time window when changing the pwm period.
Previously if a user used wait[_ms,_us] in interrupt context the device would
hang indefinitely. This was due to incrementing overflowCount from
interrupt context only.
This meant that if a user used wait[_ms,_us] in an ISR with
the same or greater interrupt priority, it would result in an infinite
loop as the overflowCount variable would never be incremented, and
wait[_ms,_us] would never return.
This patch simply applies a better solution for the race condition
mentioned in the previous commit. It instead disables the timer1
interrupt and increments the overflowCount variable, preventing
the race condition whilst supporting wait[_ms,_us] in interrupt
context.
Upstream mbed doesn't have the correct version of nrf51.h for builds
with mbed-classic on mbed.org.
This means that builds fail online due to incompatible nrf51.h's.
This commit adds the correct version of nrf51.h to our repo.
Updated ticker implementation to:
- Ensure initialisation of overflowount variable to zero (was previously undefined)
- Update internal counter 'read' operation to handle overflow conditions
differently. Instead of re-implementing the overflow handler in the 'read'
operation, it now leaves this to a single code path in the ISR. Instead, the
code is simply made aware of overflows and handles this as a local event. This
prevents the possibility of duplicate increments to overflowCount (which
appeared to occur under testing, especially when the mbed wait_ms busy-wait function is used).
The mbed PortOut and PortIn abstractions require the definition of a mask that
specifies which pins in the given port are to be used.
The nrf51822 implementation did not respect this funcitonality, and would
overwrite all pins defined as an output, regardless of whether they were
defined as part of the mask.