lujji / stm8-bare-min

Tiny peripheral library for STM8 microcontrolles
MIT License
120 stars 38 forks source link

getchar definition wrong in UART example #2

Closed seken closed 6 years ago

seken commented 6 years ago

In the the trunk for SDCC, the definition for getchar returns an int https://github.com/lujji/stm8-bare-min/blob/787c487f92a15fbd976b21e28b8576e0e08fe5f8/examples/UART/main.c#L19

zoomx commented 6 years ago

Are you sure? A char is only one byte. char getchar() { return uart_read(); }

stm8/uart.c uint8_t uart_read() { while (!(UART1_SR & (1 << UART1_SR_RXNE))); return UART1_DR; }

seken commented 6 years ago

Yes here is the header file that shows this.

Its in the C99 standard, i'm not sure about before, and its been correct sdcc since this commit.

I'm not sure how to switch automatically depending upon which compiler version is being used. I'm more familiar with c++.

zoomx commented 6 years ago

I am not sure but I believe that the function getchar has only the same name of the one in stdio.h

lujji commented 6 years ago

fixed in https://github.com/lujji/stm8-bare-min/commit/2c2f9f731c120592a04cfd0e96f46fee466ca710