mirror of
https://github.com/halleysfifthinc/Toyota-AVC-LAN
synced 2025-06-07 16:06:12 +00:00
Uncommitted changes from 8 years ago
This commit is contained in:
parent
1b66ecf306
commit
49ceb1e5e8
9
Makefile
9
Makefile
@ -10,7 +10,7 @@ sniffer.hex: sniffer.elf
|
|||||||
avr-objcopy -j .text -j .data -O ihex sniffer.elf sniffer.hex
|
avr-objcopy -j .text -j .data -O ihex sniffer.elf sniffer.hex
|
||||||
|
|
||||||
sniffer.elf: sniffer.o com232.o avclandrv.o GlobalDef.o
|
sniffer.elf: sniffer.o com232.o avclandrv.o GlobalDef.o
|
||||||
$(CC) $(LFLAGS) $(DEFS) -o sniffer.elf sniffer.o com232.o avclandrv.o GlobalDef.o
|
$(CC) $(LFLAGS) -o sniffer.elf sniffer.o com232.o avclandrv.o GlobalDef.o
|
||||||
|
|
||||||
sniffer.o: sniffer.c GlobalDef.h com232.h avclandrv.h
|
sniffer.o: sniffer.c GlobalDef.h com232.h avclandrv.h
|
||||||
$(CC) $(CFLAGS) $(DEFS) sniffer.c
|
$(CC) $(CFLAGS) $(DEFS) sniffer.c
|
||||||
@ -29,8 +29,11 @@ clean::
|
|||||||
|
|
||||||
.PHONY: upload connect size
|
.PHONY: upload connect size
|
||||||
|
|
||||||
upload: sniffer.hex
|
upload-final: sniffer.hex
|
||||||
avrdude -C/home/allen/Programs/arduino-1.6.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/arduino -b57600 -D -Uflash:w:sniffer.hex:i
|
avrdude -C/home/allen/Programs/arduino-1.6.5/hardware/tools/avr/etc/avrdude.conf -patmega328p -cstk500v1 -P/dev/arduino -b19200 -D -U flash:w:sniffer.hex:i
|
||||||
|
|
||||||
|
upload-arduino: sniffer.hex
|
||||||
|
avrdude -C/home/allen/Programs/arduino-1.6.5/hardware/tools/avr/etc/avrdude.conf -patmega328p -carduino -P/dev/arduino -b57600 -D -U flash:w:sniffer.hex:i
|
||||||
|
|
||||||
connect:
|
connect:
|
||||||
@picocom --nolock -b 115200 /dev/arduino ||:
|
@picocom --nolock -b 115200 /dev/arduino ||:
|
||||||
|
2034
avclandrv.c
2034
avclandrv.c
File diff suppressed because it is too large
Load Diff
277
avclandrv.h
277
avclandrv.h
@ -1,136 +1,141 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>.
|
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>.
|
||||||
|
|
||||||
Portions of the following source code are:
|
Portions of the following source code are:
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; either version 2
|
as published by the Free Software Foundation; either version 2
|
||||||
of the License, or (at your option) any later version.
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
this file is a part of the TOYOTA Corolla MP3 Player Project
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
http://www.softservice.com.pl/corolla/avc
|
http://www.softservice.com.pl/corolla/avc
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
May 28 / 2009 - version 2
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __AVCLANDRV_H
|
#ifndef __AVCLANDRV_H
|
||||||
#define __AVCLANDRV_H
|
#define __AVCLANDRV_H
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include "GlobalDef.h"
|
#include "GlobalDef.h"
|
||||||
|
|
||||||
#define STOPEvent cbi(TIMSK1, TOIE1); cbi(UCSR0B, RXCIE0);
|
#define STOPEvent cbi(TIMSK1, TOIE1); cbi(UCSR0B, RXCIE0);
|
||||||
#define STARTEvent sbi(TIMSK1, TOIE1); sbi(UCSR0B, RXCIE0);
|
#define STARTEvent sbi(TIMSK1, TOIE1); sbi(UCSR0B, RXCIE0);
|
||||||
|
|
||||||
|
|
||||||
#define CHECK_AVC_LINE if (INPUT_IS_SET) AVCLan_Read_Message();
|
#define CHECK_AVC_LINE if (INPUT_IS_SET) AVCLan_Read_Message();
|
||||||
|
|
||||||
void AVC_HoldLine();
|
void AVC_HoldLine();
|
||||||
void AVC_ReleaseLine();
|
void AVC_ReleaseLine();
|
||||||
|
|
||||||
#define MAXMSGLEN 32
|
#define MAXMSGLEN 32
|
||||||
|
|
||||||
// Head Unid ID
|
// Head Unid ID
|
||||||
extern byte HU_ID_1; // 0x01
|
extern byte HU_ID_1; // 0x01
|
||||||
extern byte HU_ID_2; // 0x40
|
extern byte HU_ID_2; // 0x40
|
||||||
|
|
||||||
extern byte CD_ID_1; // 0x03
|
extern byte CD_ID_1; // 0x03
|
||||||
extern byte CD_ID_2; // 0x60
|
extern byte CD_ID_2; // 0x60
|
||||||
|
|
||||||
|
|
||||||
// DVD CHANGER
|
// DVD CHANGER
|
||||||
//#define CD_ID_1 0x02
|
//#define CD_ID_1 0x02
|
||||||
//#define CD_ID_2 0x50
|
//#define CD_ID_2 0x50
|
||||||
|
|
||||||
#define cmNull 0
|
#define cmNull 0
|
||||||
#define cmStatus1 1
|
#define cmStatus1 1
|
||||||
#define cmStatus2 2
|
#define cmStatus2 2
|
||||||
#define cmStatus3 3
|
#define cmStatus3 3
|
||||||
#define cmStatus4 4
|
#define cmStatus4 4
|
||||||
|
|
||||||
|
|
||||||
#define cmRegister 100
|
#define cmRegister 100
|
||||||
#define cmInit 101
|
#define cmInit 101
|
||||||
#define cmCheck 102
|
#define cmCheck 102
|
||||||
#define cmPlayIt 103
|
#define cmPlayIt 103
|
||||||
#define cmBeep 110
|
#define cmBeep 110
|
||||||
|
|
||||||
#define cmNextTrack 120
|
#define cmNextTrack 120
|
||||||
#define cmPrevTrack 121
|
#define cmPrevTrack 121
|
||||||
#define cmNextDisc 122
|
#define cmNextDisc 122
|
||||||
#define cmPrevDisc 123
|
#define cmPrevDisc 123
|
||||||
|
|
||||||
#define cmScanModeOn 130
|
#define cmScanModeOn 130
|
||||||
#define cmScanModeOff 131
|
#define cmScanModeOff 131
|
||||||
|
|
||||||
#define cmPlayReq1 5
|
#define cmPlayReq1 5
|
||||||
#define cmPlayReq2 6
|
#define cmPlayReq2 6
|
||||||
#define cmPlayReq3 7
|
#define cmPlayReq3 7
|
||||||
#define cmStopReq 8
|
#define cmStopReq 8
|
||||||
#define cmStopReq2 9
|
#define cmStopReq2 9
|
||||||
|
|
||||||
typedef enum { stStop=0, stPlay=1 } cd_modes;
|
typedef enum { stStop=0, stPlay=1 } cd_modes;
|
||||||
extern cd_modes CD_Mode;
|
extern cd_modes CD_Mode;
|
||||||
|
|
||||||
|
|
||||||
extern byte broadcast;
|
extern byte broadcast;
|
||||||
extern byte master1;
|
extern byte master1;
|
||||||
extern byte master2;
|
extern byte master2;
|
||||||
extern byte slave1;
|
extern byte slave1;
|
||||||
extern byte slave2;
|
extern byte slave2;
|
||||||
extern byte message_len;
|
extern byte message_len;
|
||||||
extern byte message[MAXMSGLEN];
|
extern byte message[MAXMSGLEN];
|
||||||
|
|
||||||
extern byte data_control;
|
extern byte data_control;
|
||||||
extern byte data_len;
|
extern byte data_len;
|
||||||
extern byte data[MAXMSGLEN];
|
extern byte data[MAXMSGLEN];
|
||||||
|
|
||||||
byte AVCLan_Read_Message();
|
byte AVCLan_Read_Message();
|
||||||
void AVCLan_Send_Status();
|
void AVCLan_Send_Status();
|
||||||
|
|
||||||
void AVCLan_Init();
|
void AVCLan_Init();
|
||||||
void AVCLan_Register();
|
void AVCLan_Register();
|
||||||
byte AVCLan_SendData();
|
byte AVCLan_SendData();
|
||||||
byte AVCLan_SendAnswer();
|
byte AVCLan_SendAnswer();
|
||||||
byte AVCLan_SendDataBroadcast();
|
byte AVCLan_SendDataBroadcast();
|
||||||
byte AVCLan_Command(byte command);
|
byte AVCLan_Command(byte command);
|
||||||
|
|
||||||
byte HexInc(byte data);
|
byte HexInc(byte data);
|
||||||
byte HexDec(byte data);
|
byte HexDec(byte data);
|
||||||
byte Dec2Toy(byte data);
|
byte Dec2Toy(byte data);
|
||||||
|
|
||||||
extern byte check_timeout;
|
extern byte check_timeout;
|
||||||
|
|
||||||
extern byte cd_Disc;
|
extern byte cd_Disc;
|
||||||
extern byte cd_Track;
|
extern byte cd_Track;
|
||||||
extern byte cd_Time_Min;
|
extern byte cd_Time_Min;
|
||||||
extern byte cd_Time_Sec;
|
extern byte cd_Time_Sec;
|
||||||
|
|
||||||
extern byte playMode;
|
extern byte playMode;
|
||||||
|
|
||||||
byte AVCLan_SendMyData(byte *data_tmp, byte s_len);
|
byte AVCLan_SendMyData(byte *data_tmp, byte s_len);
|
||||||
byte AVCLan_SendMyDataBroadcast(byte *data_tmp, byte s_len);
|
byte AVCLan_SendMyDataBroadcast(byte *data_tmp, byte s_len);
|
||||||
|
|
||||||
void ShowInMessage();
|
void ShowInMessage();
|
||||||
void ShowOutMessage();
|
void ShowOutMessage();
|
||||||
|
|
||||||
void AVCLan_Measure();
|
#ifdef SOFTWARE_DEBUG
|
||||||
|
void AVCLan_Measure();
|
||||||
//------------------------------------------------------------------------------
|
#endif
|
||||||
extern byte answerReq;
|
#ifdef HARDWARE_DEBUG
|
||||||
//------------------------------------------------------------------------------
|
void SetHighLow();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
extern byte answerReq;
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
#endif
|
||||||
|
124
capture.md
Normal file
124
capture.md
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
``` c
|
||||||
|
HU < (bro) 190| FFF| 11 01 00 // lan_reg
|
||||||
|
out > 00 01 11 10 63 // CMD_REGISTER
|
||||||
|
HU < (bro) 190| FFF| 11 01 45 60 // Tuner in use
|
||||||
|
HU < (bro) 190| FFF| 11 01 01 // lan_init
|
||||||
|
out > 63 31 F1 00 80 FF FF FF FF 00 80 // /*
|
||||||
|
out > 63 31 F3 00 3F 00 00 00 00 02
|
||||||
|
out > 63 31 F3 00 3F 00 01 00 01 02
|
||||||
|
out > 63 31 F3 00 3D 00 01 00 01 02
|
||||||
|
out > 63 31 F3 00 39 00 01 00 01 02 // Registration gobbledygook
|
||||||
|
out > 63 31 F3 00 31 00 01 00 01 02 // probably not all necessary
|
||||||
|
out > 63 31 F3 00 21 00 01 00 01 02
|
||||||
|
out > 63 31 F1 00 90 01 FF FF FF 00 80
|
||||||
|
out > 63 31 F3 00 01 00 01 00 01 02
|
||||||
|
out > 63 31 F1 00 30 01 FF FF FF 00 80 // */
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0 // Similar to play_req1
|
||||||
|
// Logic device ID 31 => Me (63)
|
||||||
|
// Command E0
|
||||||
|
// What is logic device 31???
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 25 63 E4 // Also similar to play_req1
|
||||||
|
|
||||||
|
HU < (bro) 190| FFF| 01 01 59 39 // Nothing heard?
|
||||||
|
HU < (bro) 190| FFF| 01 01 59 39 // What is logic device 59???
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0 // Try again?
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (bro) 190| FFF| 11 01 00
|
||||||
|
out > 00 01 11 10 63
|
||||||
|
HU < (bro) 190| FFF| 11 01 45 60 // Tuner in use
|
||||||
|
HU < (bro) 190| FFF| 11 01 01
|
||||||
|
out > 63 31 F1 00 80 FF FF FF FF 00 80
|
||||||
|
out > 63 31 F3 00 3F 00 00 00 00 02
|
||||||
|
out > 63 31 F3 00 3F 00 01 00 01 02
|
||||||
|
out > 63 31 F3 00 3D 00 01 00 01 02
|
||||||
|
out > 63 31 F3 00 39 00 01 00 01 02
|
||||||
|
out > 63 31 F3 00 31 00 01 00 01 02
|
||||||
|
out > 63 31 F3 00 21 00 01 00 01 02
|
||||||
|
out > 63 31 F1 00 90 01 FF FF FF 00 80
|
||||||
|
out > 63 31 F3 00 01 00 01 00 01 02
|
||||||
|
out > 63 31 F1 00 30 01 FF FF FF 00 80
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 25 63 E4
|
||||||
|
|
||||||
|
HU < (bro) 190| FFF| 01 01 59 39
|
||||||
|
HU < (bro) 190| FFF| 01 01 59 39
|
||||||
|
HU < (bro) 190| FFF| 11 01 45 60 // Tuner in use
|
||||||
|
HU < (bro) 190| FFF| 01 01 59 39
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E0
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 31 63 E2
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80 // play_req1
|
||||||
|
out > 00 63 11 50 01 // CMD_PLAY_OK1
|
||||||
|
HU < (dir) 190| 360| 00 11 63 43 01 // stop_req
|
||||||
|
out > 00 63 11 53 01 // CMD_STOP1
|
||||||
|
out > 63 31 F1 00 30 01 01 00 00 00 80 // Player Status
|
||||||
|
HU < (bro) 190| FFF| 11 01 45 60 // Tuner in use
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80 // play_req1
|
||||||
|
out > 00 63 11 50 01 // CMD_PLAY_OK1
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41 // play_req3 but without ending 00
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41 // Trying again?
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 11 63 43 01
|
||||||
|
out > 00 63 11 53 01
|
||||||
|
out > 63 31 F1 00 30 01 01 00 00 00 80
|
||||||
|
HU < (bro) 190| FFF| 11 01 45 60 // Tuner in use
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 11 63 43 01
|
||||||
|
out > 00 63 11 53 01
|
||||||
|
out > 63 31 F1 00 30 01 01 00 00 00 80
|
||||||
|
HU < (bro) 190| FFF| 11 01 45 60 // Tuner in use
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 25 63 80
|
||||||
|
out > 00 63 11 50 01
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 11 63 42 41
|
||||||
|
HU < (dir) 190| 360| 00 11 63 43 01
|
||||||
|
out > 00 63 11 53 01
|
||||||
|
out > 63 31 F1 00 30 01 01 00 00 00 80
|
||||||
|
|
||||||
|
```
|
278
com232.c
278
com232.c
@ -1,129 +1,149 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; either version 2
|
as published by the Free Software Foundation; either version 2
|
||||||
of the License, or (at your option) any later version.
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
this file is a part of the TOYOTA Corolla MP3 Player Project
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
http://www.softservice.com.pl/corolla/avc
|
http://www.softservice.com.pl/corolla/avc
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
May 28 / 2009 - version 2
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "com232.h"
|
#include "com232.h"
|
||||||
|
|
||||||
byte RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
byte RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
||||||
byte readkey;
|
byte readkey;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void RS232_Init(void)
|
void RS232_Init(void)
|
||||||
{
|
{
|
||||||
// init LED
|
// init LED
|
||||||
sbi(DDRB, 5);
|
sbi(DDRB, 5);
|
||||||
cbi(PORTB, 5);
|
cbi(PORTB, 5);
|
||||||
|
|
||||||
RS232_RxCharBegin = RS232_RxCharEnd = 0;
|
RS232_RxCharBegin = RS232_RxCharEnd = 0;
|
||||||
|
|
||||||
UCSR0A = 0;
|
UCSR0A = 0;
|
||||||
UCSR0B = ((1<<RXCIE0) | (1<<RXEN0) | (1<<TXEN0)); // enable RxD/TxD and interrupts
|
UCSR0B = ((1<<RXCIE0) | (1<<RXEN0) | (1<<TXEN0)); // enable RxD/TxD and interrupts
|
||||||
UCSR0C = ((1<<UCSZ01)|(1<<UCSZ00)); // 8N1
|
UCSR0C = ((1<<UCSZ01)|(1<<UCSZ00)); // 8N1
|
||||||
UBRR0L = 8; // Baud Rate 9600 (3 for 250000)
|
UBRR0L = 8; // Baud Rate 9600 (3 for 250000)
|
||||||
// 103 => 9600
|
// 103 => 9600
|
||||||
// 51 => 19200
|
// 51 => 19200
|
||||||
// 25 => 38400
|
// 25 => 38400
|
||||||
// 8 => 115200
|
// 8 => 115200
|
||||||
// 3 => 250000
|
// 3 => 250000
|
||||||
|
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
ISR(USART_RX_vect)
|
ISR(USART_RX_vect)
|
||||||
{
|
{
|
||||||
RS232_RxCharBuffer[RS232_RxCharEnd] = UDR0; // Store received character to the End of Buffer
|
RS232_RxCharBuffer[RS232_RxCharEnd] = UDR0; // Store received character to the End of Buffer
|
||||||
RS232_RxCharEnd++;
|
RS232_RxCharEnd++;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void RS232_SendByte(byte Data)
|
void RS232_SendByte(byte Data)
|
||||||
{
|
{
|
||||||
while ((UCSR0A & _BV(UDRE0)) != _BV(UDRE0)); // wait for UART to become available
|
while ((UCSR0A & _BV(UDRE0)) != _BV(UDRE0)); // wait for UART to become available
|
||||||
UDR0 = Data; // send character
|
UDR0 = Data; // send character
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void RS232_Print_P(const char * str_addr)
|
void RS232_Print_P(const char * str_addr)
|
||||||
{
|
{
|
||||||
register byte c;
|
register byte c;
|
||||||
while ( (c = pgm_read_byte(str_addr++) ) )
|
while ( (c = pgm_read_byte(str_addr++) ) )
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
RS232_SendByte('\r');
|
RS232_SendByte('\r');
|
||||||
RS232_SendByte(c);
|
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++))
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
RS232_SendByte('\r');
|
RS232_SendByte('\r');
|
||||||
RS232_SendByte(c);
|
RS232_SendByte(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void RS232_PrintHex4(byte Data)
|
void RS232_PrintHex4(byte Data)
|
||||||
{
|
{
|
||||||
byte Character = Data & 0x0f;
|
byte Character = Data & 0x0f;
|
||||||
Character += '0';
|
Character += '0';
|
||||||
if (Character > '9')
|
if (Character > '9')
|
||||||
Character += 'A' - '0' - 10;
|
Character += 'A' - '0' - 10;
|
||||||
RS232_SendByte(Character);
|
RS232_SendByte(Character);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void RS232_PrintHex8(byte Data)
|
void RS232_PrintHex8(byte Data)
|
||||||
{
|
{
|
||||||
RS232_PrintHex4(Data >> 4);
|
RS232_PrintHex4(Data >> 4);
|
||||||
RS232_PrintHex4(Data);
|
RS232_PrintHex4(Data);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void RS232_PrintDec(byte Data)
|
void RS232_PrintDec(byte Data)
|
||||||
{
|
{
|
||||||
if (Data>99) {
|
if (Data>99) {
|
||||||
RS232_SendByte('*');
|
RS232_SendByte('*');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Data<10) {
|
if (Data<10) {
|
||||||
RS232_SendByte('0'+Data);
|
RS232_SendByte('0'+Data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
byte c;
|
byte c;
|
||||||
unsigned short v,v1;
|
unsigned short v,v1;
|
||||||
v = Data;
|
v = Data;
|
||||||
v1 = v/10;
|
v1 = v/10;
|
||||||
c = '0' + (v-v1*10);
|
c = '0' + (v-v1*10);
|
||||||
RS232_SendByte('0'+v1);
|
RS232_SendByte('0'+v1);
|
||||||
RS232_SendByte(c);
|
RS232_SendByte(c);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void RS232_PrintDec2(byte Data)
|
void RS232_PrintDec2(byte Data)
|
||||||
{
|
{
|
||||||
if (Data<10) RS232_SendByte('0');
|
if (Data<10) RS232_SendByte('0');
|
||||||
RS232_PrintDec(Data);
|
RS232_PrintDec(Data);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
char* itoa(int i, char b[]){
|
||||||
|
char const digit[] = "0123456789";
|
||||||
|
char* p = b;
|
||||||
|
if(i<0){
|
||||||
|
*p++ = '-';
|
||||||
|
i *= -1;
|
||||||
|
}
|
||||||
|
int shifter = i;
|
||||||
|
do{ //Move to where representation ends
|
||||||
|
++p;
|
||||||
|
shifter = shifter/10;
|
||||||
|
}while(shifter);
|
||||||
|
*p = '\0';
|
||||||
|
do{ //Move back, inserting digits as u go
|
||||||
|
*--p = digit[i%10];
|
||||||
|
i = i/10;
|
||||||
|
}while(i);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
1
com232.h
1
com232.h
@ -44,6 +44,7 @@ extern void RS232_PrintHex4(byte Data);
|
|||||||
extern void RS232_PrintHex8(byte Data);
|
extern void RS232_PrintHex8(byte Data);
|
||||||
extern void RS232_PrintDec(byte Data);
|
extern void RS232_PrintDec(byte Data);
|
||||||
extern void RS232_PrintDec2(byte Data);
|
extern void RS232_PrintDec2(byte Data);
|
||||||
|
extern char* itoa(int i, char b[]);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// LED
|
// LED
|
||||||
|
565
sniffer.c
565
sniffer.c
@ -1,298 +1,267 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; either version 2
|
as published by the Free Software Foundation; either version 2
|
||||||
of the License, or (at your option) any later version.
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
this file is a part of the TOYOTA Corolla MP3 Player Project
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
http://www.softservice.com.pl/corolla/avc
|
http://www.softservice.com.pl/corolla/avc
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
May 28 / 2009 - version 2
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
#include "GlobalDef.h"
|
||||||
#include "com232.h"
|
#include "com232.h"
|
||||||
#include "avclandrv.h"
|
#include "avclandrv.h"
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
void Setup();
|
void Setup();
|
||||||
|
|
||||||
byte rcv_command[5];
|
byte rcv_command[5];
|
||||||
byte rcv_pos = 0;
|
byte rcv_pos = 0;
|
||||||
byte rcv_time_clr = 0;
|
byte rcv_time_clr = 0;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// MAIN PROGRAM
|
// MAIN PROGRAM
|
||||||
//
|
//
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// byte h;
|
|
||||||
|
byte readSeq = 0;
|
||||||
|
byte s_len = 0;
|
||||||
byte readSeq = 0;
|
byte s_dig = 0;
|
||||||
byte s_len = 0;
|
byte s_c[2];
|
||||||
byte s_dig = 0;
|
byte i;
|
||||||
byte s_c[2];
|
byte data_tmp[32];
|
||||||
byte i;
|
|
||||||
byte data_tmp[32];
|
Setup();
|
||||||
|
|
||||||
Setup();
|
RS232_Print("AVCLan reader 1.00\nReady\n\n");
|
||||||
TCNT0 = 0;
|
LED_OFF();
|
||||||
while( TCNT0 < 250 );
|
RS232_Print_P(PSTR("\nS - read sequence\nW - send command\nQ - send broadcast\nL/l - log on/off\nK/k - seq. echo on/off\n"));
|
||||||
TCNT0 = 0;
|
RS232_Print_P(PSTR("R/r - register device\nB - Beep\n"));
|
||||||
while( TCNT0 < 250 );
|
#ifdef HARDWARE_DEBUG
|
||||||
TCNT0 = 0;
|
RS232_Print_P(PSTR("1 - Hold High/low\nE - Print line status\n"));
|
||||||
while( TCNT0 < 250 );
|
#endif
|
||||||
|
#ifdef SOFTWARE_DEBUG
|
||||||
|
RS232_Print_P(PSTR("M - Measure high and low lengths\n"));
|
||||||
|
#endif
|
||||||
RS232_Print("AVCLan reader 1.00\nReady\n\n");
|
|
||||||
LED_OFF();
|
while (1) {
|
||||||
RS232_Print_P(PSTR("D - device id\nH - HU id\nS - read sequence\nW - send command\nQ - send broadcast\nL/l - log on/off\nK/k - seq. echo on/off\nR/r - register device\nB - Beep\nT - Measure interval\n"));
|
|
||||||
|
if (INPUT_IS_SET) { // if message from some device on AVCLan begin
|
||||||
|
LED_ON();
|
||||||
|
AVCLan_Read_Message();
|
||||||
while (1) {
|
// show message
|
||||||
|
} else {
|
||||||
if (INPUT_IS_SET) { // if message from some device on AVCLan begin
|
LED_OFF();
|
||||||
LED_ON();
|
// check command from HU
|
||||||
AVCLan_Read_Message();
|
if (answerReq != 0) AVCLan_SendAnswer();
|
||||||
// show message
|
}
|
||||||
} else {
|
|
||||||
LED_OFF();
|
// HandleEvent
|
||||||
// check command from HU
|
switch (Event) {
|
||||||
if (answerReq != 0) AVCLan_SendAnswer();
|
case EV_STATUS: Event &= ~EV_STATUS;
|
||||||
}
|
AVCLan_Send_Status();
|
||||||
|
break;
|
||||||
// HandleEvent
|
}
|
||||||
switch (Event) {
|
|
||||||
case EV_STATUS: Event &= ~EV_STATUS;
|
|
||||||
AVCLan_Send_Status();
|
// Key handler
|
||||||
break;
|
if (RS232_RxCharEnd) {
|
||||||
}
|
cbi(UCSR0B, RXCIE0); // disable RX complete interrupt
|
||||||
|
readkey = RS232_RxCharBuffer[RS232_RxCharBegin];// read begin of received Buffer
|
||||||
|
RS232_RxCharBegin++;
|
||||||
// Key handler
|
if (RS232_RxCharBegin == RS232_RxCharEnd) // if Buffer is empty
|
||||||
if (RS232_RxCharEnd) {
|
RS232_RxCharBegin = RS232_RxCharEnd = 0; // do reset Buffer
|
||||||
cbi(UCSR0B, RXCIE0); // disable RX complete interrupt
|
sbi(UCSR0B, RXCIE0); // enable RX complete interrupt
|
||||||
readkey = RS232_RxCharBuffer[RS232_RxCharBegin];// read begin of received Buffer
|
switch (readkey) {
|
||||||
RS232_RxCharBegin++;
|
case 'S': showLog = 0;
|
||||||
if (RS232_RxCharBegin == RS232_RxCharEnd) // if Buffer is empty
|
RS232_Print_P(PSTR("READ SEQUENCE > \n"));
|
||||||
RS232_RxCharBegin = RS232_RxCharEnd = 0; // do reset Buffer
|
readSeq = 1;
|
||||||
sbi(UCSR0B, RXCIE0); // enable RX complete interrupt
|
s_len=0;
|
||||||
switch (readkey) {
|
s_dig=0;
|
||||||
case 'D': if (readSeq) {
|
s_c[0]=s_c[1]=0;
|
||||||
CD_ID_1 = data_tmp[0];
|
break;
|
||||||
CD_ID_2 = data_tmp[1];
|
case 'W' : showLog = 1;
|
||||||
RS232_Print_P(PSTR("DEV ID SET: 0x"));
|
readSeq=0;
|
||||||
RS232_PrintHex8(CD_ID_1);
|
AVCLan_SendMyData(data_tmp, s_len);
|
||||||
RS232_PrintHex8(CD_ID_2);
|
break;
|
||||||
RS232_Print_P(PSTR("\n"));
|
case 'Q' : showLog = 1;
|
||||||
showLog = 1;
|
readSeq=0;
|
||||||
readSeq=0;
|
AVCLan_SendMyDataBroadcast(data_tmp, s_len);
|
||||||
} else {
|
break;
|
||||||
showLog = 0;
|
case 'R': RS232_Print_P(PSTR("REGIST:\n"));
|
||||||
RS232_Print_P(PSTR("DEV ID > \n"));
|
AVCLan_Command( cmRegister );
|
||||||
readSeq = 1;
|
TCNT0 = 0;
|
||||||
s_len=0;
|
while( TCNT0 < 135 );
|
||||||
s_dig=0;
|
CHECK_AVC_LINE;
|
||||||
s_c[0]=s_c[1]=0;
|
break;
|
||||||
}
|
case 'r': AVCLan_Register();
|
||||||
break;
|
break;
|
||||||
|
case 'l': RS232_Print_P(PSTR("Log OFF\n"));
|
||||||
case 'H': if (readSeq) {
|
showLog = 0;
|
||||||
HU_ID_1 = data_tmp[0];
|
break;
|
||||||
HU_ID_2 = data_tmp[1];
|
case 'L': RS232_Print_P(PSTR("Log ON\n"));
|
||||||
RS232_Print_P(PSTR("HU ID SET: 0x"));
|
showLog = 1;
|
||||||
RS232_PrintHex8(HU_ID_1);
|
break;
|
||||||
RS232_PrintHex8(HU_ID_2);
|
case 'k': RS232_Print_P(PSTR("str OFF\n"));
|
||||||
RS232_Print_P(PSTR("\n"));
|
showLog2 = 0;
|
||||||
showLog = 1;
|
break;
|
||||||
readSeq=0;
|
case 'K': RS232_Print_P(PSTR("str ON\n"));
|
||||||
} else {
|
showLog2 = 1;
|
||||||
showLog = 0;
|
break;
|
||||||
RS232_Print_P(PSTR("HU ID > \n"));
|
case 'B':
|
||||||
readSeq = 1;
|
data_tmp[0] = 0x00;
|
||||||
s_len=0;
|
data_tmp[1] = 0x5E;
|
||||||
s_dig=0;
|
data_tmp[2] = 0x29;
|
||||||
s_c[0]=s_c[1]=0;
|
data_tmp[3] = 0x60;
|
||||||
}
|
data_tmp[4] = 0x01;
|
||||||
break;
|
s_len = 5;
|
||||||
|
AVCLan_SendMyData(data_tmp, s_len);
|
||||||
case 'S': showLog = 0;
|
break;
|
||||||
RS232_Print_P(PSTR("READ SEQUENCE > \n"));
|
|
||||||
readSeq = 1;
|
#ifdef HARDWARE_DEBUG
|
||||||
s_len=0;
|
case '1':
|
||||||
s_dig=0;
|
SetHighLow();
|
||||||
s_c[0]=s_c[1]=0;
|
break;
|
||||||
break;
|
case 'E':
|
||||||
case 'W' : showLog = 1;
|
if(INPUT_IS_SET) {
|
||||||
readSeq=0;
|
RS232_Print_P(PSTR("Set/High/1\n"));
|
||||||
AVCLan_SendMyData(data_tmp, s_len);
|
} else if (INPUT_IS_CLEAR) {
|
||||||
break;
|
RS232_Print_P(PSTR("Unset/Low/0\n"));
|
||||||
case 'Q' : showLog = 1;
|
} else {
|
||||||
readSeq=0;
|
RS232_Print_P(PSTR("WTF?\n"));
|
||||||
AVCLan_SendMyDataBroadcast(data_tmp, s_len);
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef SOFTWARE_DEBUG
|
||||||
case 'R': RS232_Print_P(PSTR("REGIST:\n"));
|
case 'M':
|
||||||
AVCLan_Command( cmRegister );
|
AVCLan_Measure();
|
||||||
TCNT0 = 0;
|
break;
|
||||||
while( TCNT0 < 135 );
|
#endif
|
||||||
CHECK_AVC_LINE;
|
|
||||||
break;
|
default :
|
||||||
case 'r': AVCLan_Register();
|
if (readSeq==1) {
|
||||||
break;
|
s_c[s_dig]=readkey;
|
||||||
|
|
||||||
|
s_dig++;
|
||||||
case 'l': RS232_Print_P(PSTR("Log OFF\n"));
|
if (s_dig==2) {
|
||||||
showLog = 0;
|
if (s_c[0]<':') s_c[0] -= 48;
|
||||||
break;
|
else s_c[0] -= 55;
|
||||||
case 'L': RS232_Print_P(PSTR("Log ON\n"));
|
data_tmp[s_len] = 16 * s_c[0];
|
||||||
showLog = 1;
|
if (s_c[1]<':') s_c[1] -= 48;
|
||||||
break;
|
else s_c[1] -= 55;
|
||||||
|
data_tmp[s_len] += s_c[1];
|
||||||
case 'k': RS232_Print_P(PSTR("str OFF\n"));
|
s_len++;
|
||||||
showLog2 = 0;
|
s_dig=0;
|
||||||
break;
|
s_c[0]=s_c[1]=0;
|
||||||
case 'K': RS232_Print_P(PSTR("str ON\n"));
|
}
|
||||||
showLog2 = 1;
|
if (showLog2) {
|
||||||
break;
|
RS232_Print_P(PSTR("CURRENT SEQUENCE > "));
|
||||||
case 'B':
|
for (i=0; i<s_len; i++) {
|
||||||
data_tmp[0] = 0x00;
|
RS232_PrintHex8(data_tmp[i]);
|
||||||
data_tmp[0] = 0x5E;
|
RS232_SendByte(' ');
|
||||||
data_tmp[0] = 0x29;
|
}
|
||||||
data_tmp[0] = 0x60;
|
RS232_Print_P(PSTR("\n"));
|
||||||
data_tmp[0] = 0x01;
|
}
|
||||||
s_len = 5;
|
}
|
||||||
AVCLan_SendMyData(data_tmp, s_len);
|
} // switch (readkey)
|
||||||
break;
|
|
||||||
case 'T':
|
}// if (RS232_RxCharEnd)
|
||||||
AVCLan_Measure();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
if (readSeq==1) {
|
}
|
||||||
s_c[s_dig]=readkey;
|
return 0;
|
||||||
|
}
|
||||||
s_dig++;
|
// -------------------------------------------------------------------------------------
|
||||||
if (s_dig==2) {
|
|
||||||
if (s_c[0]<':') s_c[0] -= 48;
|
|
||||||
else s_c[0] -= 55;
|
// -------------------------------------------------------------------------------------
|
||||||
data_tmp[s_len] = 16 * s_c[0];
|
// Setup - uP: ATMega328p
|
||||||
if (s_c[1]<':') s_c[1] -= 48;
|
//
|
||||||
else s_c[1] -= 55;
|
void Setup()
|
||||||
data_tmp[s_len] += s_c[1];
|
{
|
||||||
s_len++;
|
// GIMSK = 0; // (GICR ?) disable external interupts
|
||||||
s_dig=0;
|
|
||||||
s_c[0]=s_c[1]=0;
|
CD_ID_1 = 0x03;
|
||||||
}
|
CD_ID_2 = 0x60;
|
||||||
if (showLog2) {
|
|
||||||
RS232_Print_P(PSTR("CURRENT SEQUENCE > "));
|
HU_ID_1 = 0x01;
|
||||||
for (i=0; i<s_len; i++) {
|
HU_ID_2 = 0x90;
|
||||||
RS232_PrintHex8(data_tmp[i]);
|
|
||||||
RS232_SendByte(' ');
|
showLog = 1;
|
||||||
}
|
showLog2 = 1;
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
}
|
MCUCR = 0;
|
||||||
}
|
|
||||||
} // switch (readkey)
|
// Timer 1
|
||||||
|
TIMSK1 = 0;
|
||||||
}// if (RS232_RxCharEnd)
|
sbi(TIMSK1, OCIE1A); // Enable timer1 compare interrupt
|
||||||
|
TCCR1A = 0;
|
||||||
|
TCCR1B |= (1 << WGM12)|(1 << CS12); // Set CTC, prescaler at 256
|
||||||
|
OCR1A = 62499; // Compare match at 1sec intervals
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
RS232_Init();
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
AVCLan_Init();
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
Event = EV_NOTHING;
|
||||||
// Setup - uP: ATMega328p
|
sei();
|
||||||
//
|
|
||||||
void Setup()
|
|
||||||
{
|
}
|
||||||
// GIMSK = 0; // (GICR ?) disable external interupts
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
CD_ID_1 = 0x03;
|
|
||||||
CD_ID_2 = 0x60;
|
byte s1=0;
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
HU_ID_1 = 0x01;
|
ISR(TIMER1_COMPA_vect) // Timer1 compare match every 1Sec
|
||||||
HU_ID_2 = 0x90;
|
{
|
||||||
|
s1++;
|
||||||
showLog = 1;
|
if (s1==2) {
|
||||||
showLog2 = 1;
|
s1=0;
|
||||||
|
if (CD_Mode==stPlay) {
|
||||||
MCUCR = 0;
|
cd_Time_Sec=HexInc(cd_Time_Sec);
|
||||||
|
if (cd_Time_Sec==0x60) {
|
||||||
// Timer 1
|
cd_Time_Sec = 0;
|
||||||
TIMSK1 = 0;
|
cd_Time_Min=HexInc(cd_Time_Min);
|
||||||
sbi(TIMSK1, OCIE1A); // Enable timer1 compare interrupt
|
if (cd_Time_Min==0xA0) {
|
||||||
TCCR1A = 0;
|
cd_Time_Min=0x0;
|
||||||
TCCR1B |= (1 << WGM12)|(1 << CS12); // Set CTC, prescaler at 256
|
}
|
||||||
OCR1A = 62499; // Compare match at 1sec intervals
|
}
|
||||||
|
Event |= EV_STATUS;
|
||||||
|
}
|
||||||
RS232_Init();
|
}
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
AVCLan_Init();
|
|
||||||
|
|
||||||
Event = EV_NOTHING;
|
|
||||||
sei();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
byte s1=0;
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
ISR(TIMER1_COMPA_vect) // Timer1 compare match every 1Sec
|
|
||||||
{
|
|
||||||
s1++;
|
|
||||||
if (s1==2) {
|
|
||||||
s1=0;
|
|
||||||
if (CD_Mode==stPlay) {
|
|
||||||
cd_Time_Sec=HexInc(cd_Time_Sec);
|
|
||||||
if (cd_Time_Sec==0x60) {
|
|
||||||
cd_Time_Sec = 0;
|
|
||||||
cd_Time_Min=HexInc(cd_Time_Min);
|
|
||||||
if (cd_Time_Min==0xA0) {
|
|
||||||
cd_Time_Min=0x0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Event |= EV_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user