mirror of
https://github.com/halleysfifthinc/Toyota-AVC-LAN
synced 2025-06-07 16:06:12 +00:00
Switch PROGMEM related uses to regular flash (flat address space in avrxmega3)
This commit is contained in:
parent
98e371b529
commit
c07083423f
69
avclandrv.c
69
avclandrv.c
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
#include "GlobalDef.h"
|
||||||
#include "avclandrv.h"
|
#include "avclandrv.h"
|
||||||
@ -302,7 +301,7 @@ byte AVCLan_Send_Byte(byte bite, byte len) {
|
|||||||
}
|
}
|
||||||
len--;
|
len--;
|
||||||
if (!len) {
|
if (!len) {
|
||||||
// if (INPUT_IS_SET) RS232_Print_P(PSTR("SBER\n")); // Send Bit ERror
|
// if (INPUT_IS_SET) RS232_Print("SBER\n"); // Send Bit ERror
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
b = b << 1;
|
b = b << 1;
|
||||||
@ -342,7 +341,7 @@ byte AVCLan_Read_Message() {
|
|||||||
byte i;
|
byte i;
|
||||||
byte for_me = 0;
|
byte for_me = 0;
|
||||||
|
|
||||||
// RS232_Print_P(PSTR("$ "));
|
// RS232_Print("$ ");
|
||||||
// TCCR1B |= (1 << CS11)|(1 << CS10); // Timer1 prescaler at 64
|
// TCCR1B |= (1 << CS11)|(1 << CS10); // Timer1 prescaler at 64
|
||||||
// TCNT1 = 0;
|
// TCNT1 = 0;
|
||||||
// TCNT0 = 0;
|
// TCNT0 = 0;
|
||||||
@ -351,7 +350,7 @@ byte AVCLan_Read_Message() {
|
|||||||
// // TCCR1B = 0;
|
// // TCCR1B = 0;
|
||||||
// // TCCR1B |= (1 << WGM12)|(1 << CS12); // Set CTC, prescaler at 256
|
// // TCCR1B |= (1 << WGM12)|(1 << CS12); // Set CTC, prescaler at 256
|
||||||
// STARTEvent;
|
// STARTEvent;
|
||||||
// RS232_Print_P(PSTR("LAN>T1\n"));
|
// RS232_Print("LAN>T1\n");
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@ -360,7 +359,7 @@ byte AVCLan_Read_Message() {
|
|||||||
// // TCCR1B = 0;
|
// // TCCR1B = 0;
|
||||||
// // TCCR1B |= (1 << WGM12)|(1 << CS12);
|
// // TCCR1B |= (1 << WGM12)|(1 << CS12);
|
||||||
// STARTEvent;
|
// STARTEvent;
|
||||||
// RS232_Print_P(PSTR("LAN>T2\n"));
|
// RS232_Print("LAN>T2\n");
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
AVCLan_Read_Byte(1);
|
AVCLan_Read_Byte(1);
|
||||||
@ -415,7 +414,7 @@ byte AVCLan_Read_Message() {
|
|||||||
AVCLan_Read_Byte(1);
|
AVCLan_Read_Byte(1);
|
||||||
|
|
||||||
if (message_len > MAXMSGLEN) {
|
if (message_len > MAXMSGLEN) {
|
||||||
// RS232_Print_P(PSTR("LAN> Command error"));
|
// RS232_Print("LAN> Command error");
|
||||||
STARTEvent;
|
STARTEvent;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -545,7 +544,7 @@ byte AVCLan_SendData() {
|
|||||||
if (AVCLan_Read_ACK()) {
|
if (AVCLan_Read_ACK()) {
|
||||||
AVC_OUT_DIS();
|
AVC_OUT_DIS();
|
||||||
STARTEvent;
|
STARTEvent;
|
||||||
RS232_Print_P(PSTR("Error ACK 1 (Transmission ACK)\n"));
|
RS232_Print("Error ACK 1 (Transmission ACK)\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,7 +553,7 @@ byte AVCLan_SendData() {
|
|||||||
if (AVCLan_Read_ACK()) {
|
if (AVCLan_Read_ACK()) {
|
||||||
AVC_OUT_DIS();
|
AVC_OUT_DIS();
|
||||||
STARTEvent;
|
STARTEvent;
|
||||||
RS232_Print_P(PSTR("Error ACK 2 (COMMMAND WRITE)\n"));
|
RS232_Print("Error ACK 2 (COMMMAND WRITE)\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,7 +562,7 @@ byte AVCLan_SendData() {
|
|||||||
if (AVCLan_Read_ACK()) {
|
if (AVCLan_Read_ACK()) {
|
||||||
AVC_OUT_DIS();
|
AVC_OUT_DIS();
|
||||||
STARTEvent;
|
STARTEvent;
|
||||||
RS232_Print_P(PSTR("Error ACK 3 (Data Length)\n"));
|
RS232_Print("Error ACK 3 (Data Length)\n");
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,9 +572,9 @@ byte AVCLan_SendData() {
|
|||||||
if (AVCLan_Read_ACK()) {
|
if (AVCLan_Read_ACK()) {
|
||||||
AVC_OUT_DIS();
|
AVC_OUT_DIS();
|
||||||
STARTEvent;
|
STARTEvent;
|
||||||
RS232_Print_P(PSTR("Error ACK 4 (Data Byte: "));
|
RS232_Print("Error ACK 4 (Data Byte: ");
|
||||||
RS232_PrintDec(i);
|
RS232_PrintDec(i);
|
||||||
RS232_Print_P(PSTR(")\n"));
|
RS232_Print(")\n");
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -775,14 +774,14 @@ byte AVCLan_SendAnswer() {
|
|||||||
case cmRegister:
|
case cmRegister:
|
||||||
r = AVCLan_SendAnswerFrame((byte *)CMD_REGISTER);
|
r = AVCLan_SendAnswerFrame((byte *)CMD_REGISTER);
|
||||||
break;
|
break;
|
||||||
case cmInit: // RS232_Print_P(PSTR("INIT\n"));
|
case cmInit: // RS232_Print("INIT\n");
|
||||||
r = AVCLan_SendInitCommands();
|
r = AVCLan_SendInitCommands();
|
||||||
break;
|
break;
|
||||||
case cmCheck:
|
case cmCheck:
|
||||||
r = AVCLan_SendAnswerFrame((byte *)CMD_CHECK);
|
r = AVCLan_SendAnswerFrame((byte *)CMD_CHECK);
|
||||||
check_timeout = 0;
|
check_timeout = 0;
|
||||||
CMD_CHECK[6]++;
|
CMD_CHECK[6]++;
|
||||||
RS232_Print_P(PSTR("AVCCHK\n"));
|
RS232_Print("AVCCHK\n");
|
||||||
break;
|
break;
|
||||||
case cmPlayReq1:
|
case cmPlayReq1:
|
||||||
playMode = 0;
|
playMode = 0;
|
||||||
@ -798,7 +797,7 @@ byte AVCLan_SendAnswer() {
|
|||||||
break;
|
break;
|
||||||
case cmPlayIt:
|
case cmPlayIt:
|
||||||
playMode = 1;
|
playMode = 1;
|
||||||
RS232_Print_P(PSTR("PLAY\n"));
|
RS232_Print("PLAY\n");
|
||||||
CMD_PLAY_OK4[7] = cd_Disc;
|
CMD_PLAY_OK4[7] = cd_Disc;
|
||||||
CMD_PLAY_OK4[8] = cd_Track;
|
CMD_PLAY_OK4[8] = cd_Track;
|
||||||
CMD_PLAY_OK4[9] = cd_Time_Min;
|
CMD_PLAY_OK4[9] = cd_Time_Min;
|
||||||
@ -830,9 +829,9 @@ byte AVCLan_SendAnswer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AVCLan_Register() {
|
void AVCLan_Register() {
|
||||||
RS232_Print_P(PSTR("REG_ST\n"));
|
RS232_Print("REG_ST\n");
|
||||||
AVCLan_SendAnswerFrame((byte *)CMD_REGISTER);
|
AVCLan_SendAnswerFrame((byte *)CMD_REGISTER);
|
||||||
RS232_Print_P(PSTR("REG_END\n"));
|
RS232_Print("REG_END\n");
|
||||||
// AVCLan_Command( cmRegister );
|
// AVCLan_Command( cmRegister );
|
||||||
AVCLan_Command(cmInit);
|
AVCLan_Command(cmInit);
|
||||||
}
|
}
|
||||||
@ -843,9 +842,9 @@ byte AVCLan_Command(byte command) {
|
|||||||
answerReq = command;
|
answerReq = command;
|
||||||
r = AVCLan_SendAnswer();
|
r = AVCLan_SendAnswer();
|
||||||
/*
|
/*
|
||||||
RS232_Print_P(PSTR("ret="));
|
RS232_Print("ret=");
|
||||||
RS232_PrintHex8(r);
|
RS232_PrintHex8(r);
|
||||||
RS232_Print_P(PSTR("\n"));
|
RS232_Print("\n");
|
||||||
*/
|
*/
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -865,26 +864,26 @@ void ShowInMessage() {
|
|||||||
|
|
||||||
AVC_HoldLine();
|
AVC_HoldLine();
|
||||||
|
|
||||||
RS232_Print_P(PSTR("HU < ("));
|
RS232_Print("HU < (");
|
||||||
|
|
||||||
if (broadcast == 0)
|
if (broadcast == 0)
|
||||||
RS232_Print_P(PSTR("bro) "));
|
RS232_Print("bro) ");
|
||||||
else
|
else
|
||||||
RS232_Print_P(PSTR("dir) "));
|
RS232_Print("dir) ");
|
||||||
|
|
||||||
RS232_PrintHex4(master1);
|
RS232_PrintHex4(master1);
|
||||||
RS232_PrintHex8(master2);
|
RS232_PrintHex8(master2);
|
||||||
RS232_Print_P(PSTR("| "));
|
RS232_Print("| ");
|
||||||
RS232_PrintHex4(slave1);
|
RS232_PrintHex4(slave1);
|
||||||
RS232_PrintHex8(slave2);
|
RS232_PrintHex8(slave2);
|
||||||
RS232_Print_P(PSTR("| "));
|
RS232_Print("| ");
|
||||||
|
|
||||||
byte i;
|
byte i;
|
||||||
for (i = 0; i < message_len; i++) {
|
for (i = 0; i < message_len; i++) {
|
||||||
RS232_PrintHex8(message[i]);
|
RS232_PrintHex8(message[i]);
|
||||||
RS232_Print_P(PSTR(" "));
|
RS232_Print(" ");
|
||||||
}
|
}
|
||||||
RS232_Print_P(PSTR("\n"));
|
RS232_Print("\n");
|
||||||
|
|
||||||
AVC_ReleaseLine();
|
AVC_ReleaseLine();
|
||||||
}
|
}
|
||||||
@ -894,12 +893,12 @@ void ShowOutMessage() {
|
|||||||
|
|
||||||
AVC_HoldLine();
|
AVC_HoldLine();
|
||||||
|
|
||||||
RS232_Print_P(PSTR(" out > "));
|
RS232_Print(" out > ");
|
||||||
for (i = 0; i < data_len; i++) {
|
for (i = 0; i < data_len; i++) {
|
||||||
RS232_PrintHex8(data[i]);
|
RS232_PrintHex8(data[i]);
|
||||||
RS232_SendByte(' ');
|
RS232_SendByte(' ');
|
||||||
}
|
}
|
||||||
RS232_Print_P(PSTR("\n"));
|
RS232_Print("\n");
|
||||||
|
|
||||||
AVC_ReleaseLine();
|
AVC_ReleaseLine();
|
||||||
}
|
}
|
||||||
@ -952,27 +951,27 @@ void AVCLan_Measure() {
|
|||||||
// bit0 = tmp1-tmp;
|
// bit0 = tmp1-tmp;
|
||||||
// bit1 = tmp2-tmp1;
|
// bit1 = tmp2-tmp1;
|
||||||
//
|
//
|
||||||
// RS232_Print_P(PSTR("1,"));
|
// RS232_Print("1,");
|
||||||
// RS232_PrintDec(bit1);
|
// RS232_PrintDec(bit1);
|
||||||
// RS232_Print_P(PSTR("\n"));
|
// RS232_Print("\n");
|
||||||
//
|
//
|
||||||
// RS232_Print_P(PSTR("0,"));
|
// RS232_Print("0,");
|
||||||
// RS232_PrintDec(bit0);
|
// RS232_PrintDec(bit0);
|
||||||
// RS232_Print_P(PSTR("\n"));
|
// RS232_Print("\n");
|
||||||
n += 10;
|
n += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (byte i = 0; i < 100; i++) {
|
for (byte i = 0; i < 100; i++) {
|
||||||
itoa(temp_b[i], str);
|
itoa(temp_b[i], str);
|
||||||
if (i & 1) {
|
if (i & 1) {
|
||||||
RS232_Print_P(PSTR("High,"));
|
RS232_Print("High,");
|
||||||
} else {
|
} else {
|
||||||
RS232_Print_P(PSTR("Low,"));
|
RS232_Print("Low,");
|
||||||
}
|
}
|
||||||
RS232_Print(str);
|
RS232_Print(str);
|
||||||
RS232_Print_P(PSTR("\n"));
|
RS232_Print("\n");
|
||||||
}
|
}
|
||||||
RS232_Print_P(PSTR("\nDone.\n"));
|
RS232_Print("\nDone.\n");
|
||||||
|
|
||||||
cbi(TCCR1B, CS10);
|
cbi(TCCR1B, CS10);
|
||||||
TCCR1B = _BV(CS12);
|
TCCR1B = _BV(CS12);
|
||||||
|
10
com232.c
10
com232.c
@ -27,7 +27,6 @@
|
|||||||
#include "com232.h"
|
#include "com232.h"
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
byte RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
byte RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
||||||
byte readkey;
|
byte readkey;
|
||||||
@ -58,15 +57,6 @@ void RS232_SendByte(byte Data) {
|
|||||||
USART0_TXDATAL = Data; // send character
|
USART0_TXDATAL = Data; // send character
|
||||||
}
|
}
|
||||||
|
|
||||||
void RS232_Print_P(const char *str_addr) {
|
|
||||||
register byte c;
|
|
||||||
while ((c = pgm_read_byte(str_addr++))) {
|
|
||||||
if (c == '\n')
|
|
||||||
RS232_SendByte('\r');
|
|
||||||
RS232_SendByte(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RS232_Print(const char *pBuf) {
|
void RS232_Print(const char *pBuf) {
|
||||||
register byte c;
|
register byte c;
|
||||||
while ((c = *pBuf++)) {
|
while ((c = *pBuf++)) {
|
||||||
|
33
sniffer.c
33
sniffer.c
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
#include "GlobalDef.h"
|
||||||
#include "avclandrv.h"
|
#include "avclandrv.h"
|
||||||
@ -49,14 +48,14 @@ int main() {
|
|||||||
Setup();
|
Setup();
|
||||||
|
|
||||||
RS232_Print("AVCLan reader 1.00\nReady\n\n");
|
RS232_Print("AVCLan reader 1.00\nReady\n\n");
|
||||||
RS232_Print_P(PSTR("\nS - read sequence\nW - send command\nQ - send "
|
RS232_Print("\nS - read sequence\nW - send command\nQ - send "
|
||||||
"broadcast\nL/l - log on/off\nK/k - seq. echo on/off\n"));
|
"broadcast\nL/l - log on/off\nK/k - seq. echo on/off\n");
|
||||||
RS232_Print_P(PSTR("R/r - register device\nB - Beep\n"));
|
RS232_Print("R/r - register device\nB - Beep\n");
|
||||||
#ifdef HARDWARE_DEBUG
|
#ifdef HARDWARE_DEBUG
|
||||||
RS232_Print_P(PSTR("1 - Hold High/low\nE - Print line status\n"));
|
RS232_Print("1 - Hold High/low\nE - Print line status\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef SOFTWARE_DEBUG
|
#ifdef SOFTWARE_DEBUG
|
||||||
RS232_Print_P(PSTR("M - Measure high and low lengths\n"));
|
RS232_Print("M - Measure high and low lengths\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -90,7 +89,7 @@ int main() {
|
|||||||
switch (readkey) {
|
switch (readkey) {
|
||||||
case 'S':
|
case 'S':
|
||||||
showLog = 0;
|
showLog = 0;
|
||||||
RS232_Print_P(PSTR("READ SEQUENCE > \n"));
|
RS232_Print("READ SEQUENCE > \n");
|
||||||
readSeq = 1;
|
readSeq = 1;
|
||||||
s_len = 0;
|
s_len = 0;
|
||||||
s_dig = 0;
|
s_dig = 0;
|
||||||
@ -107,7 +106,7 @@ int main() {
|
|||||||
AVCLan_SendMyDataBroadcast(data_tmp, s_len);
|
AVCLan_SendMyDataBroadcast(data_tmp, s_len);
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
RS232_Print_P(PSTR("REGIST:\n"));
|
RS232_Print("REGIST:\n");
|
||||||
AVCLan_Command(cmRegister);
|
AVCLan_Command(cmRegister);
|
||||||
TCB1.CNT = 0;
|
TCB1.CNT = 0;
|
||||||
while (TCB1.CNT < 540) {}
|
while (TCB1.CNT < 540) {}
|
||||||
@ -117,19 +116,19 @@ int main() {
|
|||||||
AVCLan_Register();
|
AVCLan_Register();
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
RS232_Print_P(PSTR("Log OFF\n"));
|
RS232_Print("Log OFF\n");
|
||||||
showLog = 0;
|
showLog = 0;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
RS232_Print_P(PSTR("Log ON\n"));
|
RS232_Print("Log ON\n");
|
||||||
showLog = 1;
|
showLog = 1;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
RS232_Print_P(PSTR("str OFF\n"));
|
RS232_Print("str OFF\n");
|
||||||
showLog2 = 0;
|
showLog2 = 0;
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
RS232_Print_P(PSTR("str ON\n"));
|
RS232_Print("str ON\n");
|
||||||
showLog2 = 1;
|
showLog2 = 1;
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
@ -148,11 +147,11 @@ int main() {
|
|||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
if (INPUT_IS_SET) {
|
if (INPUT_IS_SET) {
|
||||||
RS232_Print_P(PSTR("Set/High/1\n"));
|
RS232_Print("Set/High/1\n");
|
||||||
} else if (INPUT_IS_CLEAR) {
|
} else if (INPUT_IS_CLEAR) {
|
||||||
RS232_Print_P(PSTR("Unset/Low/0\n"));
|
RS232_Print("Unset/Low/0\n");
|
||||||
} else {
|
} else {
|
||||||
RS232_Print_P(PSTR("WTF?\n"));
|
RS232_Print("WTF?\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -183,12 +182,12 @@ int main() {
|
|||||||
s_c[0] = s_c[1] = 0;
|
s_c[0] = s_c[1] = 0;
|
||||||
}
|
}
|
||||||
if (showLog2) {
|
if (showLog2) {
|
||||||
RS232_Print_P(PSTR("CURRENT SEQUENCE > "));
|
RS232_Print("CURRENT SEQUENCE > ");
|
||||||
for (i = 0; i < s_len; i++) {
|
for (i = 0; i < s_len; i++) {
|
||||||
RS232_PrintHex8(data_tmp[i]);
|
RS232_PrintHex8(data_tmp[i]);
|
||||||
RS232_SendByte(' ');
|
RS232_SendByte(' ');
|
||||||
}
|
}
|
||||||
RS232_Print_P(PSTR("\n"));
|
RS232_Print("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // switch (readkey)
|
} // switch (readkey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user