-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Haarer
committed
May 21, 2024
1 parent
85c30c6
commit 21d4c65
Showing
3 changed files
with
66 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
|
||
#include "stm32f10x.h" | ||
|
||
#include <uart.h> | ||
|
||
static void __attribute__((constructor)) uartInit(void) | ||
char uartGetch(void) | ||
{ | ||
|
||
return 0; | ||
} | ||
|
||
int uartGetch(void) | ||
void uartPutch(char c) | ||
{ | ||
return 0; | ||
// wait for tx data register to be empty | ||
while (!(USART1->SR & USART_SR_TXE)) | ||
; | ||
USART1->DR = 0x000000ff & c; | ||
} | ||
|
||
void uartPutch(unsigned int ch) | ||
void uartPuts(const char *ch) | ||
{ | ||
while (*ch) | ||
{ | ||
uartPutch(*ch); | ||
ch++; | ||
} | ||
} | ||
|
||
|
||
void USART1_IRQHandler(void) | ||
{ | ||
if (USART1->SR & USART_SR_RXNE) | ||
{ | ||
// this clears RXNE flag | ||
uartPutch(USART1->DR & 0xff); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters