Skip to content

Instantly share code, notes, and snippets.

@MarrekNozka
Last active February 3, 2021 07:32
Show Gist options
  • Select an option

  • Save MarrekNozka/505b6ef1af9745053ff55fb8859d0a9b to your computer and use it in GitHub Desktop.

Select an option

Save MarrekNozka/505b6ef1af9745053ff55fb8859d0a9b to your computer and use it in GitHub Desktop.
uart snipp
void main(void) {
UART1_DeInit();
/* UART1 configuration ------------------------------------------------------*/
/* UART1 configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Receive and transmit enabled
- UART1 Clock disabled
*/
UART1_Init((uint32_t)115200, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
//UART1_Cmd(ENABLE);
}
char putchar (char c)
{
/* Write a character to the UART1 */
UART1_SendData8(c);
/* Loop until the end of transmission */
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
return (c);
}
char getchar (void)
{
int c = 0;
/* Loop until the Read data register flag is SET */
while (UART1_GetFlagStatus(UART1_FLAG_RXNE) == RESET);
c = UART1_ReceiveData8();
return (c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment