Lancaster University's (short term!) clone of mbed-src for micro:bit. This is a copy of the github branch https://github.com/lancaster-university/mbed-classic
Fork of mbed-src by
common/error.c@641:be9b2017785a, 2016-07-13 (annotated)
- Committer:
- LancasterUniversity
- Date:
- Wed Jul 13 12:52:54 2016 +0100
- Revision:
- 641:be9b2017785a
- Parent:
- 285:31249416b6f9
Synchronized with git rev 1fb8ab4c
Author: James Devine
mbed-classic: BUGFIX for timer when using wait_ms from interrupt context
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.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 140:ca60b7a31055 | 1 | /* mbed Microcontroller Library |
mbed_official | 140:ca60b7a31055 | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 140:ca60b7a31055 | 3 | * |
mbed_official | 140:ca60b7a31055 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 140:ca60b7a31055 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 140:ca60b7a31055 | 6 | * You may obtain a copy of the License at |
mbed_official | 140:ca60b7a31055 | 7 | * |
mbed_official | 140:ca60b7a31055 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 140:ca60b7a31055 | 9 | * |
mbed_official | 140:ca60b7a31055 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 140:ca60b7a31055 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 140:ca60b7a31055 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 140:ca60b7a31055 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 140:ca60b7a31055 | 14 | * limitations under the License. |
mbed_official | 140:ca60b7a31055 | 15 | */ |
mbed_official | 140:ca60b7a31055 | 16 | #include <stdlib.h> |
mbed_official | 140:ca60b7a31055 | 17 | #include <stdarg.h> |
mbed_official | 140:ca60b7a31055 | 18 | #include "device.h" |
mbed_official | 140:ca60b7a31055 | 19 | #include "toolchain.h" |
mbed_official | 285:31249416b6f9 | 20 | #include "mbed_error.h" |
mbed_official | 140:ca60b7a31055 | 21 | #if DEVICE_STDIO_MESSAGES |
mbed_official | 140:ca60b7a31055 | 22 | #include <stdio.h> |
mbed_official | 140:ca60b7a31055 | 23 | #endif |
mbed_official | 140:ca60b7a31055 | 24 | |
mbed_official | 140:ca60b7a31055 | 25 | WEAK void error(const char* format, ...) { |
mbed_official | 140:ca60b7a31055 | 26 | #if DEVICE_STDIO_MESSAGES |
mbed_official | 140:ca60b7a31055 | 27 | va_list arg; |
mbed_official | 140:ca60b7a31055 | 28 | va_start(arg, format); |
mbed_official | 140:ca60b7a31055 | 29 | vfprintf(stderr, format, arg); |
mbed_official | 140:ca60b7a31055 | 30 | va_end(arg); |
mbed_official | 140:ca60b7a31055 | 31 | #endif |
mbed_official | 140:ca60b7a31055 | 32 | exit(1); |
mbed_official | 140:ca60b7a31055 | 33 | } |