/*

  Zerocat Chipflasher--- Flash free firmware, kick the Management Engine.

  Copyright (C) 2015, 2016  kai <kmx@posteo.net>
  Copyright (C) 2016, 2017, 2018, 2020, 2021, 2022  Kai Mertens <kmx@posteo.net>

  This file is part of Zerocat Chipflasher.

  Zerocat Chipflasher 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.

  Zerocat Chipflasher 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 Zerocat Chipflasher.
  If not, see <http://www.gnu.org/licenses/>.


***/


# ifndef __SERIAL_CODES_H__
#   define __SERIAL_CODES_H__


//  Serial Control Codes
//  ====================


// "\0"
#   define NUL              0x00

// Ascii 'start of header'
#   define SOH              0x01

// Ascii 'start of text'.
#   define STX              0x02

// Ascii 'end of text'.
#   define ETX              0x03

// Ascii 'end of transmission'
#   define EOT              0x04

// Ascii 'enquiry'
#   define ENQ              0x05

// Ascii 'acknowledge'
#   define ACK              0x06

// Ascii LF "\n" 'line feed'
#   define NEW_LINE         0x0a

// Ascii CR "\r" 'carriage return'
#   define CARR_RET         0x0d

// Ascii 'neg. acknowledge'
#   define NAK              0x15

// Ascii 'synchronous idle'
#   define SYN              0x16

// Ascii 'end of block transmission'
#   define ETB              0x17

// Ascii 'cancel'
#   define CAN              0x18

// Ascii 'end of medium'
#   define EM               0x19

// Ascii 'substitute'
#   define SUB              0x1a

// Ascii 'escape'
#   define ESC              0x1b

// Ascii 'file separator'
#   define FS               0x1c

// Ascii 'group separator'
#   define GS               0x1d

// Ascii 'record separator'
#   define RS               0x1e

// Ascii 'unit separator'
#   define US               0x1f


//  Line Ending Characters
//  ======================


// Used by outfifo() to send the CARR_RET character
// – or a different, printable character, to ease debugging!
#   define CLIM_CR          CARR_RET

// Used by outfifo() to send the NEW_LINE character
// – or a different, printable character, to ease debugging!
#   define CLIM_NL          NEW_LINE

// Function HEXD_rxline uses CLIM_HEXD for detection of line ending
// and returns that character in its feedback loop.
#   define CLIM_HEXD        CLIM_CR


//  Parallax Terminal Exit Sequence
//  ===============================


// First char of Parallax’ exit sequence.
#   define EXIT_CHAR_A      0xff

// Second char of Parallax’ exit sequence.
#   define EXIT_CHAR_B      0x00


//  Chipflasher File Actions
//  =========================


// Send data to terminal and save on disk.
#   define CHIP_TO_FILE             0x20

// Send data to terminal and save on disk, without feedback on screen.
#   define CHIP_TO_FILE_NOSCREEN    0x21

// Send data to Propeller and write to chip.
#   define FILE_TO_CHIP             0x22

// Send data to Propeller and write to chip, without output on screen.
#   define FILE_TO_CHIP_NOSCREEN    0x23

//! @ingroup SERIAL_CODES
//! @brief Start of input.
#   define INPUT_START              RS

//! @ingroup SERIAL_CODES
//! @brief End of input.
#   define INPUT_STOP               US


//  Types
//  =====


enum ERRCODE_t {
  ERRC__SUCCESS = 0,
  ERRC__NO_SREC,                  //file buffer flush
  ERRC__NO_HEX_DIGIT,             //file buffer flush
  ERRC__LINE_ENDING_ERROR,        //file buffer flush
  ERRC__LINE_COUNT_MISMATCH,      //file buffer flush
  ERRC__LINE_TOO_LONG,            //file buffer flush
  ERRC__BUFFER_OVERRUN,           //file buffer flush
  ERRC__HEXD_PARSE_ERROR,         //file buffer flush
  ERRC__NO_SUCH_FILE,             //file buffer flush
  ERRC__JOB_CANCELLATION,         //file buffer flush, used for comparison
  ERRC__PORT_OPEN_FAILURE,
  ERRC__INVALID_ADDRESS,
  ERRC__DEBUG,
  ERRC__CHECKSUM_MISMATCH,        //warning and error, used for comparison
  ERRC__LINE_LENGTH_MISMATCH,     //warning and error
  ERRC__WRONG_CHARACTER,          //warning and error
  ERRC__LINE_TIMEOUT              //warning and error
};

# endif
/* __SERIAL_CODES_H__ */

