Topic: tech dcc pc src prev next

tech dcc pc src > dcc.h

#ifndef CONTROLLER_DCC_H
#define CONTROLLER_DCC_H

#include <avr/pgmspace.h>

#include "packet.h"

// Maximum length of a raw packet (including preamable and separators) in
// bytes.
#define DCC_PACKET_LENGTH 12

typedef short int cv_type;

void DCC_Setup();

void DCC_SignalUpdateIsr();

// Prepare the output ports to send a DCC signal and start transmitting power.
void DCC_Start();
/*
 * Remove power from the rails.  Transmission may be resumed with start().
 * This function may be called multiple times between calls to DCC_Start().
 */
void DCC_Stop();
// Transmit a complete packet.
void DCC_Transmit(packet p);
// Transmit a complete packet.
void DCC_TransmitRepeat(packet p, unsigned char repeat);
// Transmit a page preset sequence.
void DCC_TransmitPagePresetSequence();
// Wait for any packet to finish transmission.
void DCC_AwaitCompletion();

// Complete a full CV write, choosing the most appropriate method for the CV location.
void DCC_AutoCvWrite(cv_type cv, unsigned char value);

// Complete a full, paged CV write.
void DCC_DirectCvWrite(cv_type cv, unsigned char value);

// Complete a full, direct CV write.
void DCC_PagedCvWrite(cv_type cv, unsigned char value);

// Complete a full, physical register CV write.
void DCC_RegisterCvWrite(unsigned char reg, unsigned char value);

// Complete a full hard reset sequence.
void DCC_HardReset();

#endif