The following code results in a linker error:
// -*- c++ -*-
// Device: PIC18F1320
#include <system.h>
typedef unsigned char uint8_t;
#include "usart.h"
static Usart _usart;
void main()
{
_usart.init();
for (;;) _usart.putc(_usart.getc());
// NOREACH
}
Header file (usart.h):
class Usart {
public:
void init() {
// SYNC=0, BRGH=1, BRG16=1
// SPBRG=16, -2.12% error
txsta = 0x24;
rcsta = 0x90;
baudctl = 0x08;
spbrg = 16; // 115.2k
spbrgh = 0;
}
void putc(uint8_t c) { while (!txsta.TRMT) continue; txreg = c; }
uint8_t getc() { while (!pir1.RCIF) continue