Skip to content

Commit fdd11ef

Browse files
committed
Merge pull request #1807 from sg-/update-critical
Remove __enable and __disable irq calls from mbed hal common code
2 parents d2fd820 + b2f2075 commit fdd11ef

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

hal/common/SPI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
#include "SPI.h"
17+
#include "critical.h"
1718

1819
#if DEVICE_SPI
1920

@@ -124,12 +125,12 @@ int SPI::queue_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, i
124125
if (_transaction_buffer.full()) {
125126
return -1; // the buffer is full
126127
} else {
127-
__disable_irq();
128+
core_util_critical_section_enter();
128129
_transaction_buffer.push(transaction);
129130
if (!spi_active(&_spi)) {
130131
dequeue_transaction();
131132
}
132-
__enable_irq();
133+
core_util_critical_section_exit();
133134
return 0;
134135
}
135136
#else

hal/common/board.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
#include "wait_api.h"
1818
#include "toolchain.h"
1919
#include "mbed_interface.h"
20+
#include "critical.h"
2021

2122
WEAK void mbed_die(void) {
2223
#if !defined (NRF51_H) && !defined(TARGET_EFM32)
23-
__disable_irq(); // dont allow interrupts to disturb the flash pattern
24+
core_util_critical_section_enter();
2425
#endif
2526
#if (DEVICE_ERROR_RED == 1)
2627
gpio_t led_red; gpio_init_out(&led_red, LED_RED);

libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2010-2011 ARM Limited. All rights reserved.
33
*/
44
#include "SerialHalfDuplex.h"
5+
#include "critical.h"
56

67
#if DEVICE_SERIAL
78

@@ -29,7 +30,7 @@ int SerialHalfDuplex::_putc(int c) {
2930
int retc;
3031

3132
// TODO: We should not disable all interrupts
32-
__disable_irq();
33+
core_util_critical_section_enter();
3334

3435
serial_pinout_tx(gpio.pin);
3536

@@ -38,7 +39,7 @@ int SerialHalfDuplex::_putc(int c) {
3839

3940
pin_function(gpio.pin, 0);
4041

41-
__enable_irq();
42+
core_util_critical_section_exit();
4243

4344
return retc;
4445
}

0 commit comments

Comments
 (0)