/* serial.h - serial port prototypes. Busy waiting, no interrupts.
 *  Copyright (C) 2022 by Jed Marti
 *   This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see https://www.gnu.org/licenses/.
 */


#ifndef serial_h
#define serial_h

#ifndef uint16_t
  #include <stdint.h>
#endif

// Initialize UART0 to UART0_BAUD_RATE (see config.h). Uses Timer 1
void initUART0(void);

// Write a character to the port.
void putch(unsigned char v);

// Write a zero terminated string.
void putstring(char *s);

// Single unsigned byte in zero-suppressed decimal.
void putbyte(uint8_t v);

// Short unsigned int and short int's to the serial port.
void putuint16(uint16_t v);
void putint16(int16_t v);


// Single unsigned byte in hexadecimal prefixed with 0x.
void puthexbyte(uint8_t v);

// Same but 16 bits.
void puthex16(uint16_t v);

// Used everywhere.
void terpri(void);

// Wait for a character. LED1 on whilst waiting.
uint8_t getch(void);

// Get a line, backspace, line size checkings, zero terminated at CR.
uint8_t getline(char *buf, uint8_t sz);

#endif



// EOF
