Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tz1/bluev
base: 3951db4b48
...
head fork: tz1/bluev
compare: c26b049adb
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 166 additions and 144 deletions.
  1. +23 −0 ArduinoMega.HOWTO.txt
  2. +0 −8 bluev.ino
  3. +143 −136 bluevmega.c
View
23 ArduinoMega.HOWTO.txt
@@ -1,3 +1,7 @@
+You will need a modular phone cable, some extra wire, an Arduino Mega,
+and the Arduino development environment you can get from
+http://arduino.cc and some basic tools.
+
A modular jack inserted into the accessory port on a V1 power
connection will have the following connections:
@@ -21,11 +25,30 @@ you align the end with the colors (you can usually see through the
plug) as green for ground and red for power, which would make data
yellow and audio black.
+If you want a full passthrough, you can also get a dual line jack from
+Lowes or similar store. It has to be for two full (4 wire) circuits,
+so have eight screw terminals inside. Take the wires off one side and
+connect them in the opposite order on the other side, i.e. one will be
+black, red, green, yellow, attach yellow, green, red, and black from
+the far side respectively, and run wires out to the Mega, i.e.
+
+a+-d
+BRGY
+YGRB
+
+Here I would check with a meter to figure out which side is to the
+accessory power and which is to next accessory (I tend to think, which
+one goes toward the V1, which toward the Concealed Display - which
+also has one jack). Data is going to be next to ground here too.
+
You will need to connect ground - there is a power header near the
power plug - you can buy a plug or go to the ground on the power
header. You can connect battery to VIN or PWR_IN or the plug - the
power LED should turn on if you have this right.
+Note: If the Arduino is NOT powered, it will pull down the data line
+and disable the ESP function.
+
The DATA line goes both to pin 49 on the edge opposite the power plug
and to pin 18/TX1 near the adjacent corner.
View
8 bluev.ino
@@ -1,15 +1,7 @@
-extern "C" {
- extern void hwsetup(void);
- extern void hwloop(void);
-}
-/*========================================================================*/
void loop(void)
{
- hwloop();
}
-/*-------------------------------------------------------------------------*/
void setup(void)
{
- hwsetup();
}
View
279 bluevmega.c
@@ -14,7 +14,7 @@
#define PRESCALE1 8
#define BITTIME(x) ( ((x) * F_CPU) / PRESCALE1 / BAUD)
-#include <util/delay.h>
+//#include <util/delay.h>
/*-------------------------------------------------------------------------*/
#define INMSGSIZE 24
@@ -258,6 +258,40 @@ ISR(TIMER4_CAPT_vect)
polarity ^= 1;
}
+/*========================================================================*/
+// V1 Command, Response, and Info packet Processing
+/*========================================================================*/
+
+// LOW LEVEL ROUTINES FOR ARDUINO
+
+
+// Read one character from the V1 data stream
+static int readv1rx(void)
+{
+ while (v1head == v1tail)
+ sleep_mode();
+ return v1buf[v1tail++];
+}
+
+static char serbuf[256];
+// print out strings to the main (USB) serial port
+static void printser(char *str)
+{
+ while (*str) {
+ while (!(UCSR0A & _BV(UDRE0)));
+ UDR0 = *str++;
+ }
+}
+// print string from progmem
+static void printser_P(const char *p)
+{
+ char c;
+ while ((c = pgm_read_byte(p++))) {
+ while (!(UCSR0A & _BV(UDRE0)));
+ UDR0 = c;
+ }
+}
+
#define REQVERSION (1)
#define RESPVERSION (2)
#define REQSERIALNUMBER (3)
@@ -307,9 +341,16 @@ ISR(TIMER4_CAPT_vect)
#define NORESPONSE (0xfe)
-static unsigned char tstnocks = 0;
+static unsigned char tstnocks = 0; // is this a checksummed V1?
-static int makecmd(unsigned char *buf, unsigned char src, unsigned char dst, unsigned char pkt, unsigned char len, unsigned char *param)
+// Create a valid V1 command in BUF, return length. Returns 0 if something is invalid
+// Note it permits source and dest 0-15, not just a source of 3,4,5.
+// pkt is the ID of the command.
+// len is size of param, param points to the bytes to go after the length
+// (before and not including the optional checksum which will be handled
+// according to what the infDisplay is doing.
+static int makecmd(unsigned char *buf, unsigned char src, unsigned char dst, unsigned char pkt,
+ unsigned char len, unsigned char *param)
{
if (len > 16)
return 0;
@@ -343,22 +384,8 @@ static unsigned char v1idd = 0, v1infdisplaydata[8];
static unsigned char v1alerts = 0, v1alerttemp[16][7], v1alertout[16][7];
static unsigned char cddr = 0;
-static int readv1rx(void)
-{
- while (v1head == v1tail)
- sleep_mode();
- return v1buf[v1tail++];
-}
-
-static char serbuf[256];
-static void printser(char *str)
-{
- while (*str) {
- while (!(UCSR0A & 0x20));
- UDR0 = *str++;
- }
-}
-
+// Get a full, valid packet from the V1 - SOF, EOF, source, destination, and length bytes checked.
+// For unsolicited packets (infdisp, respalert, respdatarx), process internally
static int readpkt(unsigned char *buf)
{
unsigned char len, ix;
@@ -432,13 +459,14 @@ static int readpkt(unsigned char *buf)
sprintf(serbuf, " %02x", buf[ix]);
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
#endif
}
return len;
}
}
+// send a command, wait until it goes out, then look for a response packet (by ID), placing it in buf.
static int sendcmd(unsigned char *thiscmd, unsigned char resp, unsigned char *buf)
{
unsigned char ix;
@@ -448,6 +476,7 @@ static int sendcmd(unsigned char *thiscmd, unsigned char resp, unsigned char *bu
inmsglen = thiscmd[4] + 6;
inmsgstate = 4;
+// wait this many packets max for the command to go out on the bus
#define ECHOTIME 8
for (ix = 0; ix < ECHOTIME; ix++) { // look for command on bus
ret = readpkt(buf);
@@ -463,7 +492,8 @@ static int sendcmd(unsigned char *thiscmd, unsigned char resp, unsigned char *bu
if (resp == NORESPONSE)
return 0;
- // look for response
+ // FIXME - we don't check that the destination is our ID.
+ // look for response, max packets to wait - busy will reset.
#define RESPTIME 20
for (ix = 0; ix < RESPTIME; ix++) {
ret = readpkt(buf);
@@ -480,13 +510,14 @@ static int sendcmd(unsigned char *thiscmd, unsigned char resp, unsigned char *bu
// maybe abort, return -3?
break;
case INFV1BUSY:
+ // FIXME, we don't check packet ID
#if 0
- printser("V1Busy:");
+ printser_P(PSTR("V1Busy:"));
for (ix = 0; ix < buf[4] - 1; ix++) {
sprintf(serbuf, " %02x", buf[5 + ix]);
printser(serbuf);
}
- printser(serbuf, "\r\n");
+ printser(serbuf, "\r\n"));
#endif
ix = 0; // reset timer
break;
@@ -504,9 +535,12 @@ static int sendcmd(unsigned char *thiscmd, unsigned char resp, unsigned char *bu
return 0;
}
+// command and response buffers
static unsigned char respget[22], cmdsend[22];
static unsigned int maxswp = 5;
+// make sure the buffer is clear by getting an echo.
+// FIXME - should have long timeout and return status.
static void syncresp() {
int iy;
// send one request version to clear out the incoming packet respgetfer
@@ -521,13 +555,14 @@ static void syncresp() {
}
}
+// This is the first part of the sweep probe getting the sections and maximum index
static void sweep1()
{
int ix, ret;
// Sweep Sections and Definitions
makecmd(cmdsend, slice, 0xa, REQSWEEPSECTIONS, 0, NULL);
sendcmd(cmdsend, RESPSWEEPSECTIONS, respget);
- printser("SweepSections:\r\n");
+ printser_P(PSTR("SweepSections:\r\n"));
sprintf(serbuf, "+%d/%d %5u - %5u\r\n", respget[5] >> 4, respget[5] & 15, respget[8] << 8 | respget[9],
respget[6] << 8 | respget[7]);
printser(serbuf);
@@ -573,6 +608,7 @@ static void sweep1()
maxswp = respget[5];
}
+// This is the second part of the sweep probe which gets the actual sweep definitions
static void sweep2()
{
int ix, ret;
@@ -595,6 +631,7 @@ static void sweep2()
}
}
+// user interactive program to get a 16 bit unsigned word (frequency to write sweep)
static unsigned getword()
{
unsigned ret = 0;
@@ -624,13 +661,13 @@ static unsigned getword()
case 127:
case 8:
ret /= 10;
- printser("\b \b");
+ printser_P(PSTR("\b \b"));
break;
case '\r':
return ret;
case 0x15:
ret = 0;
- printser("\r \r");
+ printser_P(PSTR("\r \r"));
break;
case 0x1b:
return 0;
@@ -640,6 +677,7 @@ static unsigned getword()
}
}
+// Set a new set of sweep definitions
static void sweepset()
{
int ix, iy;
@@ -649,18 +687,18 @@ static void sweepset()
sweep1();
sweep2();
- printser("Enter Definition Ranges, low and high, 0 to end\r\n");
+ printser_P(PSTR("Enter Definition Ranges, low and high, 0 to end\r\n"));
for (ix = 0; ix <= maxswp; ix++) {
sprintf(serbuf, "Def %d Low:\r\n", ix);
printser(serbuf);
low[ix] = getword();
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
if (low[ix] == 0)
break;
sprintf(serbuf, "Def %d High:\r\n", ix);
printser(serbuf);
high[ix] = getword();
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
if (high[ix] == 0)
break;
}
@@ -672,7 +710,7 @@ static void sweepset()
sprintf(serbuf, "%2d: %5u - %5u\r\n", iy + 1, low[iy], high[iy]);
printser(serbuf);
}
- printser("Write to V1? (Y/N):");
+ printser_P(PSTR("Write to V1? (Y/N):"));
while (inhead == intail)
readpkt(respget);
if (inbuf[intail] != 'Y' && inbuf[intail] != 'y') {
@@ -708,27 +746,31 @@ static void sweepset()
printser(serbuf);
}
else
- printser("Write Successfup\r\n");
+ printser_P(PSTR("Write Successfup\r\n"));
sweep2();
}
+// set default sweeps
static void defaultsweeps()
{
syncresp();
makecmd(cmdsend, slice, 0xa, REQDEFAULTSWEEPS, 0, NULL);
sendcmd(cmdsend, NORESPONSE, respget);
- printser("Default Sweeps Done, Please use infoscan to confirm\r\n");
+ printser_P(PSTR("Default Sweeps Done, Please use infoscan to confirm\r\n"));
}
// This setup can be used for Savvy override and unmute setting, by changing the command
+// set scan mode
+// 1=AllBogeys, 2=Logic, 3=AdvancedLogic
static void setmode(unsigned char mode)
-{ // 1=AllBogeys, 2=Logic, 3=AdvancedLogic
+{
syncresp();
makecmd(cmdsend, slice, 0xa, REQCHANGEMODE, 1, &mode);
sendcmd(cmdsend, NORESPONSE, respget);
}
// This setup can be used for display on/off, mute on/off, by changing the command
+// set factory defaults (userbytes)
static void factorydefaults()
{
syncresp();
@@ -736,6 +778,7 @@ static void factorydefaults()
sendcmd(cmdsend, NORESPONSE, respget);
}
+// show user bytes
static void usershow()
{
int ix;
@@ -743,7 +786,7 @@ static void usershow()
makecmd(cmdsend, slice, 0xa, REQUSERBYTES, 0, NULL);
sendcmd(cmdsend, RESPUSERBYTES, respget);
char userset[] = "12345678AbCdEFGHJuUtL ";
- printser("UserSet: (default) ");
+ printser_P(PSTR("UserSet: (default) "));
for (ix = 0; ix < 8; ix++) {
sprintf(serbuf, "%c", (respget[5] >> ix) & 1 ? userset[ix] : '_');
printser(serbuf);
@@ -756,7 +799,7 @@ static void usershow()
sprintf(serbuf, "%c", (respget[7] >> ix) & 1 ? userset[ix + 16] : '_');
printser(serbuf);
}
- printser("\r\nUserSet: (changed) ");
+ printser_P(PSTR("\r\nUserSet: (changed) "));
for (ix = 0; ix < 8; ix++) {
sprintf(serbuf, "%c", (respget[5] >> ix) & 1 ? '_' : userset[ix]);
printser(serbuf);
@@ -769,54 +812,55 @@ static void usershow()
sprintf(serbuf, "%c", (respget[7] >> ix) & 1 ? '_' : userset[ix + 16]);
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
}
// prototype - need to add set/reset dialog and edit the buffer
static void userbytes()
{
syncresp();
- printser("Old\r\n");
+ printser_P(PSTR("Old\r\n"));
usershow();
- printser("Updating\r\n");
-
+ printser_P(PSTR("Updating\r\n"));
+// INCOMPLETE
// Edit userbytes at respget[5-7]
makecmd(cmdsend, slice, 0xa, REQWRITEUSERBYTES, 6, &respget[5]);
sendcmd(cmdsend, NORESPONSE, respget);
- printser("New\r\n");
+ printser_P(PSTR("New\r\n"));
usershow();
}
+// Scan for everything I could find in the spec for all devices
static void infoscan()
{
int ix;
// sprintf( serbuf, "VN: %d: %02x %02x %02x %02x %02x %02x %02x\r\n", ix, cmdsend[0], cmdsend[1], cmdsend[2], cmdsend[3], cmdsend[4], cmdsend[5], cmdsend[6] );
- printser("=====INFOSCAN=====\r\n");
+ printser_P(PSTR("=====INFOSCAN=====\r\n"));
syncresp();
// do commands
makecmd(cmdsend, slice, 0xa, REQVERSION, 0, NULL);
sendcmd(cmdsend, RESPVERSION, respget);
- printser("V1 Version: ");
+ printser_P(PSTR("V1 Version: "));
for (ix = 0; ix < respget[4] - 1; ix++) {
sprintf(serbuf, "%c", respget[5 + ix] < 127 && respget[5 + ix] > 31 ? respget[5 + ix] : '.');
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
makecmd(cmdsend, slice, 0xa, REQSERIALNUMBER, 0, NULL);
sendcmd(cmdsend, RESPSERIALNUMBER, respget);
- printser("V1 SerialNo: ");
+ printser_P(PSTR("V1 SerialNo: "));
for (ix = 0; ix < respget[4] - 1; ix++) {
sprintf(serbuf, "%c", respget[5 + ix] < 127 && respget[5 + ix] > 31 ? respget[5 + ix] : '.');
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
makecmd(cmdsend, slice, 0xa, REQBATTERYVOLTAGE, 0, NULL);
sendcmd(cmdsend, RESPBATTERYVOLTAGE, respget);
@@ -831,41 +875,41 @@ static void infoscan()
// Concealed Display
makecmd(cmdsend, slice, 0, REQVERSION, 0, NULL);
sendcmd(cmdsend, RESPVERSION, respget);
- printser("CD Version: ");
+ printser_P(PSTR("CD Version: "));
for (ix = 0; ix < respget[4] - 1; ix++) {
sprintf(serbuf, "%c", respget[5 + ix] < 127 && respget[5 + ix] > 31 ? respget[5 + ix] : '.');
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
// Remote Audio
makecmd(cmdsend, slice, 1, REQVERSION, 0, NULL);
sendcmd(cmdsend, RESPVERSION, respget);
- printser("RA Version: ");
+ printser_P(PSTR("RA Version: "));
for (ix = 0; ix < respget[4] - 1; ix++) {
sprintf(serbuf, "%c", respget[5 + ix] < 127 && respget[5 + ix] > 31 ? respget[5 + ix] : '.');
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
// Savvy
makecmd(cmdsend, slice, 2, REQVERSION, 0, NULL);
sendcmd(cmdsend, RESPVERSION, respget);
- printser("SV Version: ");
+ printser_P(PSTR("SV Version: "));
for (ix = 0; ix < respget[4] - 1; ix++) {
sprintf(serbuf, "%c", respget[5 + ix] < 127 && respget[5 + ix] > 31 ? respget[5 + ix] : '.');
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
makecmd(cmdsend, slice, 2, REQSERIALNUMBER, 0, NULL);
sendcmd(cmdsend, RESPSERIALNUMBER, respget);
- printser("SV SerialNo: ");
+ printser_P(PSTR("SV SerialNo: "));
for (ix = 0; ix < respget[4] - 1; ix++) {
sprintf(serbuf, "%c", respget[5 + ix] < 127 && respget[5 + ix] > 31 ? respget[5 + ix] : '.');
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
makecmd(cmdsend, slice, 2, REQSAVVYSTATUS, 0, NULL);
sendcmd(cmdsend, RESPSAVVYSTATUS, respget);
@@ -875,14 +919,15 @@ static void infoscan()
sendcmd(cmdsend, RESPVEHICLESPEED, respget);
sprintf(serbuf, "SavvyVehSpd: %d kph\r\n", respget[5]);
printser(serbuf);
- printser("=====END INFOSCAN=====\r\n");
+ printser_P(PSTR("=====END INFOSCAN=====\r\n"));
}
+// Ask for and Displayu (decoded) alerts
static void alerts()
{
int ix;
syncresp();
- printser("=====ALERTS=====\r\n");
+ printser_P(PSTR("=====ALERTS=====\r\n"));
makecmd(cmdsend, slice, 0xa, REQSTARTALERTDATA, 0, NULL);
sendcmd(cmdsend, NORESPONSE, respget);
for (;;) {
@@ -890,7 +935,7 @@ static void alerts()
intail = inhead;
break;
}
- printser("===\r\n");
+ printser_P(PSTR("===\r\n"));
ix = v1alerts;
while (ix == v1alerts)
readpkt(respget);
@@ -908,12 +953,36 @@ static void alerts()
sprintf(serbuf, "!");
printser(serbuf);
}
- printser("\r\n");
+ printser_P(PSTR("\r\n"));
}
}
makecmd(cmdsend, slice, 0xa, REQSTOPALERTDATA, 0, NULL);
sendcmd(cmdsend, NORESPONSE, respget);
- printser("=====END ALERTS=====\r\n");
+ printser_P(PSTR("=====END ALERTS=====\r\n"));
+}
+
+
+prog_char sevs2ascii[] PROGMEM = {
+ " ~'...17_...j..]"
+ "........l...uvJ."
+ "`\".^............"
+ "|.......LC...GU0"
+ "-.......=#.....3"
+ "r./.....c..2o.d."
+ "....\\.4......5y9"
+ ".F.Ph.HAtE..b6.8"
+ };
+
+showinfdata() {
+ int ix;
+ sprintf( serbuf,"Disp: %c%c %02x %02x ", sevs2ascii[respget[5] & 0x7f], respget[5] & 0x80 ? 'o' : ' ', respget[5], respget[6] ^ respget[5]);
+ for (ix = 0; ix < 8; ix++)
+ sprintf( serbuf,"%c", (respget[7] >> ix) & 1 ? '*' : '.');
+
+ //bit 0-7: Laser, Ka, K, X, -, Front, Side, Rear
+ sprintf( serbuf," %02x %02x", respget[8], respget[9] ^ respget[8]);
+ //bit 0-7: Mute, TSHold, SysUp, DispOn, Euro, Custom, -, -
+ sprintf( serbuf," %02x\r\n", respget[10]);
}
/*========================================================================*/
@@ -921,7 +990,7 @@ void hwloop(void)
{
int ret;
- printser("V1MegaTool\r\n");
+ printser_P(PSTR("V1MegaTool\r\n"));
for (;;) { // get at least one inf packet
ret = readpkt(respget);
@@ -930,8 +999,9 @@ void hwloop(void)
if (respget[3] == INFDISPLAYDATA)
break;
}
-
- printser("A-alerts, I-infoscan, D-DefaultSweep, S-SetSweeps. T-transparent\r\n");
+ // should give Not Ready message if timeslice holdoff.
+
+ printser_P(PSTR("A-alerts, I-infoscan, D-DefaultSweep, S-SetSweeps. T-transparent\r\n"));
while (inhead == intail)
readpkt(respget);
@@ -965,89 +1035,25 @@ void hwloop(void)
}
- // should worry about timeslice holdoff.
-
- /*
-
- char sevs2ascii[] = {
- ' ', '~', '.', '.', '.', '.', '1', '7',
- '_', '.', '.', '.', 'j', '.', '.', ']',
- '.', '.', '.', '.', '.', '.', '.', '.',
- 'l', '.', '.', '.', 'u', 'v', 'J', '.',
-
- '.', '.', '.', '^', '.', '.', '.', '.',
- '.', '.', '.', '.', '.', '.', '.', '.',
- '|', '.', '.', '.', '.', '.', '.', '.',
- 'L', 'C', '.', '.', '.', 'G', 'U', '0',
-
- '-', '.', '.', '.', '.', '.', '.', '.',
- '=', '#', '.', '.', '.', '.', '.', '3',
- 'r', '.', '/', '.', '.', '.', '.', '.',
- 'c', '.', '.', '2', 'o', '.', 'd', '.',
-
- '.', '.', '.', '.', '\\', '.', '4', '.',
- '.', '.', '.', '.', '.', '5', 'y', '9',
- '.', 'F', '.', 'P', 'h', '.', 'H', 'A',
- 't', 'E', '.', '.', 'b', '6', '.', '8'
- };
- sprintf( serbuf,"Disp: %c%c %02x %02x ", sevs2ascii[respget[5] & 0x7f], respget[5] & 0x80 ? 'o' : ' ', respget[5], respget[6] ^ respget[5]);
- for (ix = 0; ix < 8; ix++)
- sprintf( serbuf,"%c", (respget[7] >> ix) & 1 ? '*' : '.');
-
- //bit 0-7: Laser, Ka, K, X, -, Front, Side, Rear
- sprintf( serbuf," %02x %02x", respget[8], respget[9] ^ respget[8]);
- //bit 0-7: Mute, TSHold, SysUp, DispOn, Euro, Custom, -, -
- sprintf( serbuf," %02x\r\n", respget[10]);
- break;
-
- */
-
/*-------------------------------------------------------------------------*/
void hwsetup(void)
{
- cli();
- v1state = inmsgstate = inmsglen = 0;
+ cli();
+ v1state = inmsgstate = inmsglen = polarity = bitcnt = 0;
- TIMSK0=TIMSK1=TIMSK2=TIMSK3=TIMSK4=TIMSK5=0;
- ADCSRA= 0;
-
// UART init
#include <util/setbaud.h>
- UBRR1H = UBRRH_VALUE;
- UBRR1L = UBRRL_VALUE;
-#if USE_2X
- UCSR1A |= (1 << U2X1);
-#else
- UCSR1A &= ~(1 << U2X1);
-#endif
-
- UCSR1C = _BV(UCSZ10) | _BV(UCSZ11); // 8N1
- // UCSR1B = _BV(RXEN1) | _BV(RXCIE1); // Enable Receive
-
- UBRR0H = UBRRH_VALUE;
- UBRR0L = UBRRL_VALUE;
-#if USE_2X
- UCSR0A |= (1 << U2X0);
-#else
- UCSR0A &= ~(1 << U2X0);
-#endif
- UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); // 8N1
- UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0); // Enable TX and RX
-
- UBRR2H = UBRRH_VALUE;
- UBRR2L = UBRRL_VALUE;
+ UBRR2H = UBRR1H = UBRR0H = UBRRH_VALUE;
+ UBRR2L = UBRR1L = UBRR0L = UBRRL_VALUE;
#if USE_2X
- UCSR2A |= (1 << U2X2);
-#else
- UCSR2A &= ~(1 << U2X2);
+ UCSR2A = UCSR1A = UCSR0A = _BV(U2X1);
#endif
- UCSR2C = _BV(UCSZ20) | _BV(UCSZ21); // 8N1
- UCSR2B = _BV(TXEN2) | _BV(RXEN2) | _BV(RXCIE2); // Enable TX and RX
+ UCSR2C = UCSR1C = UCSR0C = _BV(UCSZ10) | _BV(UCSZ11); // 8N1
+ UCSR2B = UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0); // Enable TX and RX
+ // for UART1, only TX is enabled, and only when sending in the right timeslice
// Timer init
GTCCR = 0; //_BV(PSR10); /* reset prescaler */
- TCNT4 = 0; /* reset counter value */
- polarity = bitcnt = 0;
// trigger on falling edge (default), noise cancel
// lower 3 bits is div, off,1,8,64,256,1024,extfall,extris ; CS12,11,10
@@ -1063,12 +1069,13 @@ void hwsetup(void)
}
#ifdef STANDALONE
int main()
+#else
+void init()
+#endif
{
hwsetup();
for (;;)
hwloop();
}
-#else
-void init() {}
-#endif
+

No commit comments for this range

Something went wrong with that request. Please try again.