mirror of
https://github.com/halleysfifthinc/Toyota-AVC-LAN
synced 2025-06-09 08:56:16 +00:00
More cleanly separate specific functionality into the relevant files
This commit is contained in:
parent
003c4c7f2f
commit
9581957eca
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
|
||||||
|
|
||||||
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;
|
|
@ -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 <avr/io.h>
|
|
||||||
|
|
||||||
#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_
|
|
@ -30,7 +30,6 @@
|
|||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
#include "avclandrv.h"
|
#include "avclandrv.h"
|
||||||
#include "com232.h"
|
#include "com232.h"
|
||||||
|
|
||||||
@ -59,6 +58,8 @@
|
|||||||
uint16_t CD_ID;
|
uint16_t CD_ID;
|
||||||
uint16_t HU_ID;
|
uint16_t HU_ID;
|
||||||
|
|
||||||
|
uint8_t printAllFrames;
|
||||||
|
|
||||||
uint8_t playMode;
|
uint8_t playMode;
|
||||||
|
|
||||||
uint8_t cd_Track;
|
uint8_t cd_Track;
|
||||||
@ -504,7 +505,7 @@ uint8_t AVCLAN_readframe() {
|
|||||||
|
|
||||||
STARTEvent;
|
STARTEvent;
|
||||||
|
|
||||||
if (showLog)
|
if (printAllFrames)
|
||||||
AVCLAN_printframe(&frame);
|
AVCLAN_printframe(&frame);
|
||||||
|
|
||||||
if (for_me) {
|
if (for_me) {
|
||||||
|
@ -30,7 +30,14 @@
|
|||||||
#ifndef __AVCLANDRV_H
|
#ifndef __AVCLANDRV_H
|
||||||
#define __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 \
|
#define STOPEvent \
|
||||||
cbi(RTC.PITINTCTRL, RTC_PI_bp); \
|
cbi(RTC.PITINTCTRL, RTC_PI_bp); \
|
||||||
@ -51,6 +58,8 @@ void AVC_ReleaseLine();
|
|||||||
extern uint16_t CD_ID; // CD Changer ID
|
extern uint16_t CD_ID; // CD Changer ID
|
||||||
extern uint16_t HU_ID; // Head-unit ID
|
extern uint16_t HU_ID; // Head-unit ID
|
||||||
|
|
||||||
|
extern uint8_t printAllFrames;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
cm_Null = 0,
|
cm_Null = 0,
|
||||||
cm_Status1 = 1,
|
cm_Status1 = 1,
|
||||||
@ -114,6 +123,8 @@ extern uint8_t cd_Time_Sec;
|
|||||||
|
|
||||||
extern uint8_t playMode;
|
extern uint8_t playMode;
|
||||||
|
|
||||||
|
extern uint8_t answerReq;
|
||||||
|
|
||||||
#ifdef SOFTWARE_DEBUG
|
#ifdef SOFTWARE_DEBUG
|
||||||
void AVCLan_Measure();
|
void AVCLan_Measure();
|
||||||
#endif
|
#endif
|
||||||
@ -121,6 +132,4 @@ void AVCLan_Measure();
|
|||||||
void SetHighLow();
|
void SetHighLow();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern uint8_t answerReq;
|
|
||||||
|
|
||||||
#endif // __AVCLANDRV_H
|
#endif // __AVCLANDRV_H
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef __COM232_H
|
#ifndef __COM232_H
|
||||||
#define __COM232_H
|
#define __COM232_H
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
#include <stdint.h>
|
||||||
|
|
||||||
extern uint8_t RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
extern uint8_t RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
||||||
extern uint8_t readkey;
|
extern uint8_t readkey;
|
||||||
|
@ -27,10 +27,14 @@
|
|||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
#include "avclandrv.h"
|
#include "avclandrv.h"
|
||||||
#include "com232.h"
|
#include "com232.h"
|
||||||
|
|
||||||
|
#define EV_NOTHING 0
|
||||||
|
#define EV_STATUS 4
|
||||||
|
|
||||||
|
uint8_t Event;
|
||||||
|
|
||||||
void Setup();
|
void Setup();
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@ -81,16 +85,16 @@ int main() {
|
|||||||
|
|
||||||
// Key handler
|
// Key handler
|
||||||
if (RS232_RxCharEnd) {
|
if (RS232_RxCharEnd) {
|
||||||
cbi(USART0.CTRLA, USART_RXCIE_bp); // disable RX complete interrupt
|
cli();
|
||||||
readkey = RS232_RxCharBuffer[RS232_RxCharBegin]; // read begin of received
|
readkey = RS232_RxCharBuffer[RS232_RxCharBegin]; // read begin of received
|
||||||
// Buffer
|
// Buffer
|
||||||
RS232_RxCharBegin++;
|
RS232_RxCharBegin++;
|
||||||
if (RS232_RxCharBegin == RS232_RxCharEnd) // if Buffer is empty
|
if (RS232_RxCharBegin == RS232_RxCharEnd) // if Buffer is empty
|
||||||
RS232_RxCharBegin = RS232_RxCharEnd = 0; // reset Buffer
|
RS232_RxCharBegin = RS232_RxCharEnd = 0; // reset Buffer
|
||||||
sbi(USART0.CTRLA, USART_RXCIE_bp); // enable RX complete interrupt
|
sei();
|
||||||
switch (readkey) {
|
switch (readkey) {
|
||||||
case 'S':
|
case 'S':
|
||||||
showLog = 0;
|
printAllFrames = 0;
|
||||||
RS232_Print("READ SEQUENCE > \n");
|
RS232_Print("READ SEQUENCE > \n");
|
||||||
readSeq = 1;
|
readSeq = 1;
|
||||||
s_len = 0;
|
s_len = 0;
|
||||||
@ -98,14 +102,14 @@ int main() {
|
|||||||
s_c[0] = s_c[1] = 0;
|
s_c[0] = s_c[1] = 0;
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
showLog = 1;
|
printAllFrames = 1;
|
||||||
readSeq = 0;
|
readSeq = 0;
|
||||||
msg.broadcast = UNICAST;
|
msg.broadcast = UNICAST;
|
||||||
msg.length = s_len;
|
msg.length = s_len;
|
||||||
AVCLAN_sendframe(&msg);
|
AVCLAN_sendframe(&msg);
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
showLog = 1;
|
printAllFrames = 1;
|
||||||
readSeq = 0;
|
readSeq = 0;
|
||||||
msg.broadcast = BROADCAST;
|
msg.broadcast = BROADCAST;
|
||||||
msg.length = s_len;
|
msg.length = s_len;
|
||||||
@ -123,19 +127,19 @@ int main() {
|
|||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
RS232_Print("Log OFF\n");
|
RS232_Print("Log OFF\n");
|
||||||
showLog = 0;
|
printAllFrames = 0;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
RS232_Print("Log ON\n");
|
RS232_Print("Log ON\n");
|
||||||
showLog = 1;
|
printAllFrames = 1;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
RS232_Print("str OFF\n");
|
RS232_Print("str OFF\n");
|
||||||
showLog2 = 0;
|
echoCharacters = 0;
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
RS232_Print("str ON\n");
|
RS232_Print("str ON\n");
|
||||||
showLog2 = 1;
|
echoCharacters = 1;
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
data_tmp[0] = 0x00;
|
data_tmp[0] = 0x00;
|
||||||
@ -189,7 +193,7 @@ int main() {
|
|||||||
s_dig = 0;
|
s_dig = 0;
|
||||||
s_c[0] = s_c[1] = 0;
|
s_c[0] = s_c[1] = 0;
|
||||||
}
|
}
|
||||||
if (showLog2) {
|
if (echoCharacters) {
|
||||||
RS232_Print("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]);
|
||||||
@ -208,8 +212,8 @@ void Setup() {
|
|||||||
CD_ID = 0x360;
|
CD_ID = 0x360;
|
||||||
HU_ID = 0x190;
|
HU_ID = 0x190;
|
||||||
|
|
||||||
showLog = 1;
|
printAllFrames = 1;
|
||||||
showLog2 = 1;
|
echoCharacters = 1;
|
||||||
|
|
||||||
// Handle unconnected pins PA3, PB3-5
|
// Handle unconnected pins PA3, PB3-5
|
||||||
// Set as inputs
|
// Set as inputs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user