Skip to content

Commit b64e322

Browse files
committed
add fflush to exit
enable DEVICE_STDIO_MESSAGES on k64f remove all line endings from error messages throughout mbed sdk (all targets)
1 parent e209490 commit b64e322

File tree

41 files changed

+67
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+67
-59
lines changed

libraries/mbed/api/error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* To generate a fatal run-time error, you can use the mbed error() function.
3838
*
3939
* @code
40-
* error("That shouldn't have happened!\n");
40+
* error("That shouldn't have happened!");
4141
* @endcode
4242
*
4343
* If the mbed running the program executes this function, it will print the
@@ -48,7 +48,7 @@
4848
*
4949
* @code
5050
* if(x >= 5) {
51-
* error("expected x to be less than 5, but got %d\n", x);
51+
* error("expected x to be less than 5, but got %d", x);
5252
* }
5353
* #endcode
5454
*/

libraries/mbed/common/exit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
*/
1616
#include "semihost_api.h"
1717
#include "mbed_interface.h"
18+
#if DEVICE_STDIO_MESSAGES
19+
#include <stdio.h>
20+
#endif
1821

1922
#ifdef TOOLCHAIN_GCC_CW
2023
// TODO: Ideally, we would like to define directly "_ExitProcess"
@@ -23,6 +26,11 @@ void mbed_exit(int return_code) {
2326
void exit(int return_code) {
2427
#endif
2528

29+
#if DEVICE_STDIO_MESSAGES
30+
fflush(stdout);
31+
fflush(stderr);
32+
#endif
33+
2634
#if DEVICE_SEMIHOST
2735
if (mbed_interface_connected()) {
2836
semihost_exit();

libraries/mbed/common/pinmap_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void pinmap_pinout(PinName pin, const PinMap *map) {
2828
}
2929
map++;
3030
}
31-
error("could not pinout\n");
31+
error("could not pinout");
3232
}
3333

3434
uint32_t pinmap_merge(uint32_t a, uint32_t b) {
@@ -40,7 +40,7 @@ uint32_t pinmap_merge(uint32_t a, uint32_t b) {
4040
if (b == (uint32_t)NC) return a;
4141

4242
// mis-match error case
43-
error("pinmap mis-match\n");
43+
error("pinmap mis-match");
4444
return (uint32_t)NC;
4545
}
4646

@@ -60,6 +60,6 @@ uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
6060
return (uint32_t)NC;
6161
peripheral = pinmap_find_peripheral(pin, map);
6262
if ((uint32_t)NC == peripheral) // no mapping available
63-
error("pinmap not found for peripheral\n");
63+
error("pinmap not found for peripheral");
6464
return peripheral;
6565
}

libraries/mbed/common/retarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ extern "C" int mkdir(const char *path, mode_t mode) {
386386
#include "error.h"
387387
namespace __gnu_cxx {
388388
void __verbose_terminate_handler() {
389-
error("Exception\n");
389+
error("Exception");
390390
}
391391
}
392392
extern "C" WEAK void __cxa_pure_virtual(void);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/analogin_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static const PinMap PinMap_ADC[] = {
3939
void analogin_init(analogin_t *obj, PinName pin) {
4040
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
4141
if (obj->adc == (ADCName)NC)
42-
error("ADC pin mapping failed\n");
42+
error("ADC pin mapping failed");
4343

4444
SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK;
4545

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_irq_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
108108
break;
109109

110110
default:
111-
error("gpio_irq only supported on port A-E.\n");
111+
error("gpio_irq only supported on port A-E.");
112112
break;
113113
}
114114
NVIC_SetVector(irq_n, vector);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
5757
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
5858
obj->i2c = (I2C_Type*)pinmap_merge(i2c_sda, i2c_scl);
5959
if ((int)obj->i2c == NC)
60-
error("I2C pin mapping failed\n");
60+
error("I2C pin mapping failed");
6161

6262
SIM->SCGC4 |= SIM_SCGC4_I2C0_MASK;
6363
SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
5454
// determine the channel
5555
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
5656
if (pwm == (PWMName)NC)
57-
error("PwmOut pin mapping failed\n");
57+
error("PwmOut pin mapping failed");
5858

5959
uint32_t clkdiv = 0;
6060
float clkval = SystemCoreClock / 1000000.0f;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/serial_api.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
4848
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
4949
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
5050
if ((int)uart == NC)
51-
error("Serial pinout mapping failed\n");
51+
error("Serial pinout mapping failed");
5252

5353
obj->uart = (UART_Type *)uart;
5454
// enable clk
@@ -126,7 +126,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
126126

127127
// 8 data bits = 0 ... 9 data bits = 1
128128
if ((data_bits < 8) || (data_bits > 9))
129-
error("Invalid number of bits (%d) in serial format, should be 8..9\n", data_bits);
129+
error("Invalid number of bits (%d) in serial format, should be 8..9", data_bits);
130130

131131
data_bits -= 8;
132132

@@ -136,13 +136,13 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
136136
case ParityOdd : parity_enable = 1; parity_select = 1; data_bits++; break;
137137
case ParityEven: parity_enable = 1; parity_select = 0; data_bits++; break;
138138
default:
139-
error("Invalid serial parity setting\n");
139+
error("Invalid serial parity setting");
140140
return;
141141
}
142142

143143
// 1 stop bits = 0, 2 stop bits = 1
144144
if ((stop_bits != 1) && (stop_bits != 2))
145-
error("Invalid stop bits specified\n");
145+
error("Invalid stop bits specified");
146146
stop_bits -= 1;
147147

148148
uint32_t m10 = 0;
@@ -151,7 +151,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
151151
if (data_bits == 2) {
152152
// only uart0 supports 10 bit communication
153153
if (obj->index != 0)
154-
error("Invalid number of bits (9) to be used with parity\n");
154+
error("Invalid number of bits (9) to be used with parity");
155155
data_bits = 0;
156156
m10 = 1;
157157
}

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/spi_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
5757

5858
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
5959
if ((int)obj->spi == NC) {
60-
error("SPI pinout mapping failed\n");
60+
error("SPI pinout mapping failed");
6161
}
6262

6363
SIM->SCGC5 |= SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK;
@@ -94,11 +94,11 @@ void spi_free(spi_t *obj) {
9494
}
9595
void spi_format(spi_t *obj, int bits, int mode, int slave) {
9696
if ((bits != 8) && (bits != 16)) {
97-
error("Only 8/16 bits SPI supported\n");
97+
error("Only 8/16 bits SPI supported");
9898
}
9999

100100
if ((mode < 0) || (mode > 3)) {
101-
error("SPI mode unsupported\n");
101+
error("SPI mode unsupported");
102102
}
103103

104104
uint32_t polarity = (mode & 0x2) ? 1 : 0;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
9999
break;
100100

101101
default:
102-
error("gpio_irq only supported on Port A and B\n");
102+
error("gpio_irq only supported on Port A and B");
103103
break;
104104
}
105105
NVIC_SetVector(irq_n, vector);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/spi_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
5252

5353
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
5454
if ((int)obj->spi == NC) {
55-
error("SPI pinout mapping failed\n");
55+
error("SPI pinout mapping failed");
5656
}
5757

5858
// enable power and clocking
@@ -88,11 +88,11 @@ void spi_free(spi_t *obj) {
8888
}
8989
void spi_format(spi_t *obj, int bits, int mode, int slave) {
9090
if (bits != 8) {
91-
error("Only 8bits SPI supported\n");
91+
error("Only 8bits SPI supported");
9292
}
9393

9494
if ((mode < 0) || (mode > 3)) {
95-
error("SPI mode unsupported\n");
95+
error("SPI mode unsupported");
9696
}
9797

9898
uint8_t polarity = (mode & 0x2) ? 1 : 0;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
8989
break;
9090

9191
default:
92-
error("gpio_irq only supported on port A and D\n");
92+
error("gpio_irq only supported on port A and D");
9393
break;
9494
}
9595
NVIC_SetVector(irq_n, vector);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/spi_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
3434

3535
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
3636
if ((int)obj->spi == NC) {
37-
error("SPI pinout mapping failed\n");
37+
error("SPI pinout mapping failed");
3838
}
3939

4040
// enable power and clocking
@@ -68,11 +68,11 @@ void spi_free(spi_t *obj) {
6868
}
6969
void spi_format(spi_t *obj, int bits, int mode, int slave) {
7070
if (bits != 8) {
71-
error("Only 8bits SPI supported\n");
71+
error("Only 8bits SPI supported");
7272
}
7373

7474
if ((mode < 0) || (mode > 3)) {
75-
error("SPI mode unsupported\n");
75+
error("SPI mode unsupported");
7676
}
7777

7878
uint8_t polarity = (mode & 0x2) ? 1 : 0;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
109109
break;
110110

111111
default:
112-
error("gpio_irq only supported on port A,C and D\n");
112+
error("gpio_irq only supported on port A,C and D");
113113
break;
114114
}
115115
NVIC_SetVector(irq_n, vector);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/spi_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
9191

9292
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
9393
if ((int)obj->spi == NC) {
94-
error("SPI pinout mapping failed\n");
94+
error("SPI pinout mapping failed");
9595
}
9696

9797
// enable power and clocking
@@ -126,11 +126,11 @@ void spi_free(spi_t *obj) {
126126
}
127127
void spi_format(spi_t *obj, int bits, int mode, int slave) {
128128
if ((bits != 8) && (bits != 16)) {
129-
error("Only 8/16 bits SPI supported\n");
129+
error("Only 8/16 bits SPI supported");
130130
}
131131

132132
if ((mode < 0) || (mode > 3)) {
133-
error("SPI mode unsupported\n");
133+
error("SPI mode unsupported");
134134
}
135135

136136
uint8_t polarity = (mode & 0x2) ? 1 : 0;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogin_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
void analogin_init(analogin_t *obj, PinName pin) {
2929
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
3030
if (obj->adc == (ADCName)NC) {
31-
error("ADC pin mapping failed\n");
31+
error("ADC pin mapping failed");
3232
}
3333

3434
SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
void analogout_init(dac_t *obj, PinName pin) {
2727
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
2828
if (obj->dac == (DACName)NC) {
29-
error("DAC pin mapping failed\n");
29+
error("DAC pin mapping failed");
3030
}
3131

3232
SIM->SCGC6 |= SIM_SCGC6_DAC0_MASK;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
4646
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
4747
obj->i2c = (I2C_Type*)pinmap_merge(i2c_sda, i2c_scl);
4848
if ((int)obj->i2c == NC) {
49-
error("I2C pin mapping failed\n");
49+
error("I2C pin mapping failed");
5050
}
5151

5252
// enable power

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
2727
// determine the channel
2828
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
2929
if (pwm == (PWMName)NC)
30-
error("PwmOut pin mapping failed\n");
30+
error("PwmOut pin mapping failed");
3131

3232
uint32_t clkdiv = 0;
3333
float clkval;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/serial_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
6262
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
6363
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
6464
if ((int)uart == NC) {
65-
error("Serial pinout mapping failed\n");
65+
error("Serial pinout mapping failed");
6666
}
6767

6868
obj->uart = (UARTLP_Type *)uart;
@@ -159,7 +159,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
159159

160160
// TODO: Support other number of data bits (also in the write method!)
161161
if ((data_bits < 8) || (data_bits > 8)) {
162-
error("Invalid number of bits (%d) in serial format, should be 8\n", data_bits);
162+
error("Invalid number of bits (%d) in serial format, should be 8", data_bits);
163163
}
164164

165165
uint8_t parity_enable, parity_select;
@@ -168,13 +168,13 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
168168
case ParityOdd : parity_enable = 1; parity_select = 1; data_bits++; break;
169169
case ParityEven: parity_enable = 1; parity_select = 0; data_bits++; break;
170170
default:
171-
error("Invalid serial parity setting\n");
171+
error("Invalid serial parity setting");
172172
return;
173173
}
174174

175175
// 1 stop bits = 0, 2 stop bits = 1
176176
if ((stop_bits != 1) && (stop_bits != 2)) {
177-
error("Invalid stop bits specified\n");
177+
error("Invalid stop bits specified");
178178
}
179179
stop_bits -= 1;
180180

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/analogin_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static const PinMap PinMap_ADC[] = {
5050
void analogin_init(analogin_t *obj, PinName pin) {
5151
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
5252
if (obj->adc == (ADCName)NC) {
53-
error("ADC pin mapping failed\n");
53+
error("ADC pin mapping failed");
5454
}
5555
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
5656

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/analogout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const PinMap PinMap_DAC[] = {
2929
void analogout_init(dac_t *obj, PinName pin) {
3030
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
3131
if (obj->dac == (DACName)NC) {
32-
error("DAC pin mapping failed\n");
32+
error("DAC pin mapping failed");
3333
}
3434

3535
SIM->SCGC2 |= SIM_SCGC2_DAC0_MASK;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
#define DEVICE_DEBUG_AWARENESS 0
5151

52-
#define DEVICE_STDIO_MESSAGES 0
52+
#define DEVICE_STDIO_MESSAGES 1
5353

5454
#define DEVICE_ERROR_RED 1
5555

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_irq_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
109109
break;
110110

111111
default:
112-
error("gpio_irq only supported on port A-E.\n");
112+
error("gpio_irq only supported on port A-E.");
113113
break;
114114
}
115115
NVIC_SetVector(irq_n, vector);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
5151
uint32_t i2c_scl = pinmap_peripheral(scl, PinMap_I2C_SCL);
5252
obj->instance = pinmap_merge(i2c_sda, i2c_scl);
5353
if ((int)obj->instance == NC) {
54-
error("I2C pin mapping failed\n");
54+
error("I2C pin mapping failed");
5555
}
5656

5757
clock_manager_set_gate(kClockModuleI2C, obj->instance, true);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static float pwm_clock_mhz;
7474
void pwmout_init(pwmout_t* obj, PinName pin) {
7575
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
7676
if (pwm == (PWMName)NC) {
77-
error("PwmOut pin mapping failed\n");
77+
error("PwmOut pin mapping failed");
7878
}
7979
obj->pwm_name = pwm;
8080

0 commit comments

Comments
 (0)