diff --git a/src/GlobalDef.c b/src/GlobalDef.c deleted file mode 100644 index 1657d75..0000000 --- a/src/GlobalDef.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2006 Marcin Slonicki . - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - ----------------------------------------------------------------------- - this file is a part of the TOYOTA Corolla MP3 Player Project - ----------------------------------------------------------------------- - http://www.softservice.com.pl/corolla/avc - - May 28 / 2009 - version 2 - -*/ - -#include "GlobalDef.h" - -// max 10 events in fifo -// uint8_t EventCount; -// uint8_t EventCmd[10]; -uint8_t Event; - -uint8_t showLog; -uint8_t showLog2; diff --git a/src/GlobalDef.h b/src/GlobalDef.h deleted file mode 100644 index 9135724..0000000 --- a/src/GlobalDef.h +++ /dev/null @@ -1,50 +0,0 @@ -/*-------------------------------------------------------------------------------------------------- - - Name : GlobalDef.h - - Description : Global definitions. - - History : 2004/04/06 - Created by Louis Frigon. - ---------------------------------------------------------------------------------------------------*/ -#ifndef _GLOBALDEF_H_ -#define _GLOBALDEF_H_ - -#include - -#define FALSE 0 -#define TRUE (!FALSE) - -// AVC LAN bus on AC2 (PA6/7) -// PA6 AINP0 + -// PA7 AINN1 - -#define INPUT_IS_SET (bit_is_set(AC2_STATUS, AC_STATE_bp)) -#define INPUT_IS_CLEAR (bit_is_clear(AC2_STATUS, AC_STATE_bp)) - -#define sbi(port, bit) (port) |= (1 << (bit)) // Set bit (i.e. to 1) -#define cbi(port, bit) (port) &= ~(1 << (bit)) // Clear bit (i.e. set bit to 0) - -// // max 10 events in fifo -// extern uint8_t EventCount; -// extern uint8_t EventCmd[10]; -extern uint8_t Event; - -#define EV_NOTHING 0 -#define EV_DISPLAY 1 -#define EV_STATUS 4 - -// // const -// #define smYear 1 -// #define smMonth 2 -// #define smDay 3 -// #define smHour 4 -// #define smMin 5 -// #define smWDay 6 - -// #define STOPEvent cbi(TIMSK, TOIE1); cbi(UCSRB, RXCIE); -// #define STARTEvent sbi(TIMSK, TOIE1); sbi(UCSRB, RXCIE); - -extern uint8_t showLog; -extern uint8_t showLog2; - -#endif // _GLOBALDEF_H_ diff --git a/src/avclandrv.c b/src/avclandrv.c index 27b98d9..372d0f5 100644 --- a/src/avclandrv.c +++ b/src/avclandrv.c @@ -30,7 +30,6 @@ #include #include -#include "GlobalDef.h" #include "avclandrv.h" #include "com232.h" @@ -59,6 +58,8 @@ uint16_t CD_ID; uint16_t HU_ID; +uint8_t printAllFrames; + uint8_t playMode; uint8_t cd_Track; @@ -504,7 +505,7 @@ uint8_t AVCLAN_readframe() { STARTEvent; - if (showLog) + if (printAllFrames) AVCLAN_printframe(&frame); if (for_me) { diff --git a/src/avclandrv.h b/src/avclandrv.h index cca062e..b6b1bcf 100644 --- a/src/avclandrv.h +++ b/src/avclandrv.h @@ -30,7 +30,14 @@ #ifndef __AVCLANDRV_H #define __AVCLANDRV_H -#include "GlobalDef.h" +// AVC LAN bus on AC2 (PA6/7) +// PA6 AINP0 + +// PA7 AINN1 - +#define INPUT_IS_SET (bit_is_set(AC2_STATUS, AC_STATE_bp)) +#define INPUT_IS_CLEAR (bit_is_clear(AC2_STATUS, AC_STATE_bp)) + +#define sbi(port, bit) (port) |= (1 << (bit)) // Set bit (i.e. to 1) +#define cbi(port, bit) (port) &= ~(1 << (bit)) // Clear bit (i.e. set bit to 0) #define STOPEvent \ cbi(RTC.PITINTCTRL, RTC_PI_bp); \ @@ -51,6 +58,8 @@ void AVC_ReleaseLine(); extern uint16_t CD_ID; // CD Changer ID extern uint16_t HU_ID; // Head-unit ID +extern uint8_t printAllFrames; + typedef enum { cm_Null = 0, cm_Status1 = 1, @@ -114,6 +123,8 @@ extern uint8_t cd_Time_Sec; extern uint8_t playMode; +extern uint8_t answerReq; + #ifdef SOFTWARE_DEBUG void AVCLan_Measure(); #endif @@ -121,6 +132,4 @@ void AVCLan_Measure(); void SetHighLow(); #endif -extern uint8_t answerReq; - #endif // __AVCLANDRV_H diff --git a/src/com232.h b/src/com232.h index c902c71..c4135d6 100644 --- a/src/com232.h +++ b/src/com232.h @@ -27,7 +27,7 @@ #ifndef __COM232_H #define __COM232_H -#include "GlobalDef.h" +#include extern uint8_t RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd; extern uint8_t readkey; diff --git a/src/sniffer.c b/src/sniffer.c index 0af20c1..6203cc0 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -27,10 +27,14 @@ #include #include -#include "GlobalDef.h" #include "avclandrv.h" #include "com232.h" +#define EV_NOTHING 0 +#define EV_STATUS 4 + +uint8_t Event; + void Setup(); int main() { @@ -81,16 +85,16 @@ int main() { // Key handler if (RS232_RxCharEnd) { - cbi(USART0.CTRLA, USART_RXCIE_bp); // disable RX complete interrupt + cli(); readkey = RS232_RxCharBuffer[RS232_RxCharBegin]; // read begin of received // Buffer RS232_RxCharBegin++; if (RS232_RxCharBegin == RS232_RxCharEnd) // if Buffer is empty RS232_RxCharBegin = RS232_RxCharEnd = 0; // reset Buffer - sbi(USART0.CTRLA, USART_RXCIE_bp); // enable RX complete interrupt + sei(); switch (readkey) { case 'S': - showLog = 0; + printAllFrames = 0; RS232_Print("READ SEQUENCE > \n"); readSeq = 1; s_len = 0; @@ -98,14 +102,14 @@ int main() { s_c[0] = s_c[1] = 0; break; case 'W': - showLog = 1; + printAllFrames = 1; readSeq = 0; msg.broadcast = UNICAST; msg.length = s_len; AVCLAN_sendframe(&msg); break; case 'Q': - showLog = 1; + printAllFrames = 1; readSeq = 0; msg.broadcast = BROADCAST; msg.length = s_len; @@ -123,19 +127,19 @@ int main() { break; case 'l': RS232_Print("Log OFF\n"); - showLog = 0; + printAllFrames = 0; break; case 'L': RS232_Print("Log ON\n"); - showLog = 1; + printAllFrames = 1; break; case 'k': RS232_Print("str OFF\n"); - showLog2 = 0; + echoCharacters = 0; break; case 'K': RS232_Print("str ON\n"); - showLog2 = 1; + echoCharacters = 1; break; case 'B': data_tmp[0] = 0x00; @@ -189,7 +193,7 @@ int main() { s_dig = 0; s_c[0] = s_c[1] = 0; } - if (showLog2) { + if (echoCharacters) { RS232_Print("CURRENT SEQUENCE > "); for (i = 0; i < s_len; i++) { RS232_PrintHex8(data_tmp[i]); @@ -208,8 +212,8 @@ void Setup() { CD_ID = 0x360; HU_ID = 0x190; - showLog = 1; - showLog2 = 1; + printAllFrames = 1; + echoCharacters = 1; // Handle unconnected pins PA3, PB3-5 // Set as inputs