collab/PineapplePad
git clone https://git.julia.blue/collab/PineapplePad
ca230b6
master
1#ifndef __UART_H__ 2#define __UART_H__ 3#include <stdint.h> 4// standard ASCII symbols 5#define STX 0x02 6#define ETX 0x03 7#define CR 0x0D 8#define LF 0x0A 9#define BS 0x08 10#define ESC 0x1B 11#define SP 0x20 12#define DEL 0x7F 13 14//------------UART_Init------------ 15// Initialize the UART for 115,200 baud rate (assuming 50 MHz clock), 16// 8 bit word length, no parity bits, one stop bit, FIFOs enabled 17// Input: none 18// Output: none 19void UART_Init (void ); 20 21//------------UART_InChar------------ 22// Wait for new serial port input 23// Input: none 24// Output: ASCII code for key typed 25char UART_InChar (void ); 26 27//------------UART_InStatus------------ 28// check for possible input ready 29// Input: none 30// Output: true if some input is ready 31bool UART_InStatus (void ); 32 33//------------UART_OutChar------------ 34// Output 8-bit to serial port 35// Input: letter is an 8-bit ASCII character to be transferred 36// Output: none 37void UART_OutChar (char data ); 38 39//------------UART_OutString------------ 40// Output String (NULL termination) 41// Input: pointer to a NULL-terminated string to be transferred 42// Output: none 43void UART_OutString (char * pt ); 44 45//-----------------------UART_OutUDec----------------------- 46// Output a 32-bit number in unsigned decimal format 47// Input: 32-bit number to be transferred 48// Output: none 49// Variable format 1-10 digits with no space before or after 50void UART_OutUDec (uint32_t n ); 51 52//------------UART_InMessage------------ 53// Accepts ASCII characters from the serial port 54// and adds them to a string until ETX is typed 55// or until max length of the string is reached. 56// Input: pointer to empty buffer of 8 characters 57// Output: Null terminated string 58void UART_InMessage (char * bufPt ); 59#endif