Electronic Load 1.0 Programmable Constant Current Sink

Macros | Functions | Variables
uart.h File Reference
Include dependency graph for uart.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros
#define | CMDLINE_MAX 20
#define | HOST_BAUD 115200
#define | HOST_UBRR (F_CPU/16/HOST_BAUD-1)
#define | UART0_TXBUFSIZE 10
| Size of the UART0 transmit buffer. More...

## Functions
static void | AssertRTS (void)
| Asserts RTS to the Host Line, i.e. allows the Host to send Data. More...
int | hprintf_P (const char *fmt,...)
| printf_P for Communication with the Host More...
void | InitUart (void)
| Initialize USART Hardware and Pointers. More...
int | putchar_uart0 (char, FILE *)
| The Putchar-Routine for USART0 (Host-Interface) More...
static void | ReleaseRTS (void)
| Releases RTS to the Host Line, i.e. stops the Host from sending Data. More...
void | Usart0FlushRx (void)
static void | UsartTimerCallback (void)
| Timer Callback. Checks for CTS from the Host to resume Communication. More...

## Variables
volatile uint8_t | byteFromHost
| Contains the last byte received from the host. More...
static const uint8_t | CFLAG_BYTERECEIVED =32
| Received a Byte from the host. More...
static const uint8_t | CFLAG_CHECKSUMERROR =8
| Checksum Error in received Telegram. More...
static const uint8_t | CFLAG_CMDRECEIVED =16
| Received the terminating CR of a Command. More...
static const uint8_t | CFLAG_PARITYERROR =4
| Parity Error in received Byte. More...
volatile uint8_t | cFlags
volatile char | cmdline [CMDLINE_MAX+1]
| Ready to hold CMDLINE_MAX chars plus terminating 0. More...
volatile uint8_t | hostCommandsLost
| Counts the number of commands lost due to buffer overrun. More...
volatile uint8_t | tbuf0_head
volatile uint8_t | tbuf0_tail
FILE | uart0

## Macro Definition Documentation

## ◆ HOST_BAUD

#define HOST_BAUD 115200

## ◆ HOST_UBRR

#define HOST_UBRR (F_CPU/16/HOST_BAUD-1)

## ◆ UART0_TXBUFSIZE

#define UART0_TXBUFSIZE 10

Size of the UART0 transmit buffer.

## ◆ CMDLINE_MAX

#define CMDLINE_MAX 20

## Function Documentation

## ◆ InitUart()

void InitUart | ( | void |  | ) |

Initialize USART Hardware and Pointers.

2 Stop-bits are used, USART0 connects to the Host at 9600 baud, 8 bits and no parity.

Here is the call graph for this function:

## ◆ putchar_uart0()

int putchar_uart0 | ( | char | c,
|  | FILE * | stream
| ) |  |

The Putchar-Routine for USART0 (Host-Interface)

Note
  This routine blocks when the transmit buffer is full.

Parameters

  c | The Character
  stream | A Pointer to the File (unused)

Returns
  Always 0

Here is the call graph for this function:

## ◆ hprintf_P()

int hprintf_P | ( | const char * | fmt,
|  |  | ...
| ) |  |

printf_P for Communication with the Host

Parameters

  fmt | Format String
  ... | Additional Parameters

Returns
  The return value of the underlying vfprintf_P

## ◆ Usart0FlushRx()

void Usart0FlushRx | ( | void |  | ) |

## ◆ UsartTimerCallback()

static void UsartTimerCallback | ( | void |  | ) |
| inlinestatic

Timer Callback. Checks for CTS from the Host to resume Communication.

This function re-enables interrupts after CTS becomes true again and must be called periodically e.g. from timer interrupt.

Here is the caller graph for this function:

## ◆ AssertRTS()

static void AssertRTS | ( | void |  | ) |
| inlinestatic

Asserts RTS to the Host Line, i.e. allows the Host to send Data.

Here is the caller graph for this function:

## ◆ ReleaseRTS()

static void ReleaseRTS | ( | void |  | ) |
| inlinestatic

Releases RTS to the Host Line, i.e. stops the Host from sending Data.

Here is the caller graph for this function:

## Variable Documentation

## ◆ cmdline

volatile char cmdline[CMDLINE_MAX+1]

Ready to hold CMDLINE_MAX chars plus terminating 0.

## ◆ cFlags

volatile uint8_t cFlags

## ◆ CFLAG_PARITYERROR

const uint8_t CFLAG_PARITYERROR =4
| static

Parity Error in received Byte.

## ◆ CFLAG_CHECKSUMERROR

const uint8_t CFLAG_CHECKSUMERROR =8
| static

Checksum Error in received Telegram.

## ◆ CFLAG_CMDRECEIVED

const uint8_t CFLAG_CMDRECEIVED =16
| static

Received the terminating CR of a Command.

## ◆ CFLAG_BYTERECEIVED

const uint8_t CFLAG_BYTERECEIVED =32
| static

Received a Byte from the host.

## ◆ tbuf0_tail

volatile uint8_t tbuf0_tail

## ◆ tbuf0_head

volatile uint8_t tbuf0_head

## ◆ byteFromHost

volatile uint8_t byteFromHost

Contains the last byte received from the host.

## ◆ hostCommandsLost

volatile uint8_t hostCommandsLost

Counts the number of commands lost due to buffer overrun.

## ◆ uart0

FILE uart0