mirror of
https://github.com/halleysfifthinc/Toyota-AVC-LAN
synced 2025-06-07 16:06:12 +00:00
Removed old files
This commit is contained in:
parent
b6923559d1
commit
04077c8801
1055
AVCLanDriver.c
1055
AVCLanDriver.c
File diff suppressed because it is too large
Load Diff
116
AVCLanDriver.h
116
AVCLanDriver.h
@ -1,116 +0,0 @@
|
|||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : AvcLanDriver.h
|
|
||||||
|
|
||||||
Description : AVC Lan driver for Toyota devices
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
#ifndef _AVCLANDRV_H_
|
|
||||||
#define _AVCLANDRV_H_
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
|
|
||||||
#define HU_ADDRESS 0x190 // But possibly 0x160, known to be both
|
|
||||||
|
|
||||||
#define MY_ADDRESS 0x360 // CD Changer #1
|
|
||||||
|
|
||||||
#define BROADCAST_ADDRESS 0x01FF // All audio devices
|
|
||||||
|
|
||||||
#define CONTROL_FLAGS 0xF
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|<---- Bit '0' ---->|<---- Bit '1' ---->|
|
|
||||||
Physical '1' ,---------------, ,---------, ,---------
|
|
||||||
^ | ^ | ^
|
|
||||||
Physical '0' -----' '---' '---------'--------- Idle low
|
|
||||||
|---- 33 us ----| 7 |- 20 us -|- 20 us -|
|
|
||||||
|
|
||||||
A bit '0' is typically 33 us high followed by 7 us low.
|
|
||||||
A bit '1' is typically 20 us high followed by 20 us low.
|
|
||||||
A start bit is typically 165 us high followed by 30 us low.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
// Following multipliers result of Timer 0 prescaler having 2 counts/us
|
|
||||||
#define NORMAL_BIT_LENGTH 74 //37*2
|
|
||||||
|
|
||||||
#define BIT_1_HOLD_ON_LENGTH 40 //20*2
|
|
||||||
#define BIT_0_HOLD_ON_LENGTH 64 //33*2
|
|
||||||
|
|
||||||
#define START_BIT_LENGTH 372 //186*2
|
|
||||||
#define START_BIT_HOLD_ON_LENGTH 336 //168*2
|
|
||||||
|
|
||||||
#define AVC_OUT_EN() sbi(PORTD, 6); sbi(DDRD, 6); sbi(DDRD, 7); sbi(ACSR, ACD); // Output mode
|
|
||||||
#define AVC_OUT_DIS() cbi(PORTD, 6); cbi(DDRD, 6); cbi(DDRD, 7); cbi(ACSR, ACD); // Read mode
|
|
||||||
#define AVC_SET_1() sbi(PORTD, 6);
|
|
||||||
#define AVC_SET_0() cbi(PORTD, 6);
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{ // No this is not a mistake, broadcast = 0!
|
|
||||||
MSG_NORMAL = 1,
|
|
||||||
MSG_BCAST = 0
|
|
||||||
|
|
||||||
} AvcTransmissionMode;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
ACT_NONE,
|
|
||||||
|
|
||||||
ACT_AUX_IN_USE,
|
|
||||||
ACT_TUNER_IN_USE,
|
|
||||||
ACT_TAPE_IN_USE,
|
|
||||||
ACT_CD_IN_USE,
|
|
||||||
|
|
||||||
ACT_EJECT_CD,
|
|
||||||
ACT_NO_CD,
|
|
||||||
ACT_TUNER_INFO,
|
|
||||||
ACT_FM_AUDIO_STATUS,
|
|
||||||
ACT_AM_AUDIO_STATUS,
|
|
||||||
// ACT_CD_INFO,
|
|
||||||
|
|
||||||
ACT_STATUS,
|
|
||||||
ACT_REGISTER,
|
|
||||||
ACT_INIT,
|
|
||||||
ACT_CHECK
|
|
||||||
|
|
||||||
} AvcActionID;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
AvcActionID ActionID; // Action to perform after receiving this message.
|
|
||||||
byte DataSize; // Payload data size (bytes).
|
|
||||||
byte Data[ 11 ]; // Payload data.
|
|
||||||
char Description[ 17 ]; // ASCII description of the command for terminal dump.
|
|
||||||
|
|
||||||
} AvcIncomingMessageStruct;
|
|
||||||
|
|
||||||
typedef const AvcIncomingMessageStruct AvcInMessage;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
AvcTransmissionMode Mode; // Transmission mode: normal (1) or broadcast (0).
|
|
||||||
byte DataSize; // Payload data size (bytes).
|
|
||||||
byte Data[ 11 ]; // Payload data.
|
|
||||||
char Description[ 17 ]; // ASCII description of the command for terminal dump.
|
|
||||||
|
|
||||||
} AvcOutgoingMessageStruct;
|
|
||||||
|
|
||||||
typedef const AvcOutgoingMessageStruct AvcOutMessage;
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
Prototypes
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
AvcActionID AvcReadMessage ( void );
|
|
||||||
|
|
||||||
bool AvcProcessActionID ( AvcActionID actionID );
|
|
||||||
void AvcUpdateStatus ( void );
|
|
||||||
bool AvcRegisterMe ( void );
|
|
||||||
|
|
||||||
void DumpRawMessage ( bool incoming );
|
|
||||||
|
|
||||||
#endif // _AVCLANDRV_H_
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
End of file.
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
@ -1,144 +0,0 @@
|
|||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : ToyotaAuxEnabler.c
|
|
||||||
|
|
||||||
Description : This program enables the AUX audio input on old Toyota radios with CD. Pressing
|
|
||||||
CD Eject button while no CD is loaded will toggle the AUX input.
|
|
||||||
|
|
||||||
MCU : ATmega328P @ 16 MHz.
|
|
||||||
|
|
||||||
Author : 2007-01-27 - Louis Frigon
|
|
||||||
|
|
||||||
Copyright : (c) 2007 SigmaObjects
|
|
||||||
|
|
||||||
History : 2007-01-27 - v0.1 Prototyping draft inspired from Marcin Slonicki's code.
|
|
||||||
2007-02-24 - v1.0 Production release.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/wdt.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
#include "USART.h"
|
|
||||||
#include "AVCLanDriver.h"
|
|
||||||
|
|
||||||
#define FIRMWARE_VERSION "v1.0"
|
|
||||||
#define FIRMWARE_DATE __DATE__
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
Prototypes
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
void InitMCU ( void );
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
Global Variables
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
volatile bool SecondsTick = FALSE;
|
|
||||||
|
|
||||||
char UsartMsgBuffer[ USART_BUFFER_SIZE ];
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : InitMCU
|
|
||||||
|
|
||||||
Description : Performs MCU initialization.
|
|
||||||
|
|
||||||
Argument(s) : None.
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
void InitMCU ( void )
|
|
||||||
{
|
|
||||||
// Init LED port pin
|
|
||||||
LED_DDR |= LEDOUT;
|
|
||||||
LedOff();
|
|
||||||
|
|
||||||
// OLD: TCCR0A = _BV(CS01);
|
|
||||||
// Correction: TCCR0B has the CS0n bits, not TCCR0A, prescaler should be at 8 or less to have 1 or more counts/us
|
|
||||||
// Timer 0 prescaler = 8 ( 2 count / us )
|
|
||||||
TCCR0B = _BV(CS01);
|
|
||||||
|
|
||||||
InitUSART();
|
|
||||||
|
|
||||||
// Preset AVC bus driver output pins but leave pins tri-stated until we need to use them.
|
|
||||||
PORTD |= _BV(PD3); // PD3 (+) high.
|
|
||||||
PORTD &= ~_BV(PD2); // PD2 (-) low.
|
|
||||||
|
|
||||||
// Enable watchdog @ ~2 sec.
|
|
||||||
// Likely this too, after research probably not, but maybe
|
|
||||||
wdt_enable( WDTO_2S );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : LedOn
|
|
||||||
|
|
||||||
Description : Turn LED on (active low signal).
|
|
||||||
|
|
||||||
Argument(s) : None.
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
inline void LedOn ( void )
|
|
||||||
{
|
|
||||||
LED_PORT &= ~LEDOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : LedOff
|
|
||||||
|
|
||||||
Description : Turn LED off (active low signal).
|
|
||||||
|
|
||||||
Argument(s) : None.
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
inline void LedOff ( void )
|
|
||||||
{
|
|
||||||
LED_PORT |= LEDOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : main
|
|
||||||
|
|
||||||
Description : Program's main function.
|
|
||||||
|
|
||||||
Argument(s) : None.
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
int main ( void )
|
|
||||||
{
|
|
||||||
InitMCU();
|
|
||||||
|
|
||||||
UsartPutCStr( PSTR("\r\n\t\t Toyota AVC-Lan AUX Enabler\r\n") );
|
|
||||||
UsartPutCStr( PSTR("\t\tCopyright (C) 2007, SigmaObjects Inc.\r\n") );
|
|
||||||
|
|
||||||
sprintf( UsartMsgBuffer, "\t\t Firmware %s, %s\r\n\r\n", FIRMWARE_VERSION, FIRMWARE_DATE );
|
|
||||||
UsartPutStr( UsartMsgBuffer );
|
|
||||||
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
// Reset watchdog.
|
|
||||||
wdt_reset();
|
|
||||||
|
|
||||||
AvcActionID actionID = AvcReadMessage();
|
|
||||||
|
|
||||||
if ( actionID != ACT_NONE )
|
|
||||||
{
|
|
||||||
AvcProcessActionID( actionID );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
End of file.
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
144
USART.c
144
USART.c
@ -1,144 +0,0 @@
|
|||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : USART.c
|
|
||||||
|
|
||||||
Description : Utility functions for ATmega8 USART.
|
|
||||||
|
|
||||||
Author : 2004-10-22 - Louis Frigon
|
|
||||||
|
|
||||||
History : 2004-10-22 - First release (v0.1).
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "USART.h"
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : InitUSART
|
|
||||||
|
|
||||||
Description : Performs USART initialization: 9600,N,8,1.
|
|
||||||
|
|
||||||
Argument(s) : None.
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
void InitUSART ( void )
|
|
||||||
{
|
|
||||||
// Disable USART while setting baud rate.
|
|
||||||
UCSR0B = 0x00;
|
|
||||||
UCSR0A = 0x00;
|
|
||||||
|
|
||||||
// 8 data bit, 1 stop, no parity.
|
|
||||||
UCSR0C = _BV(EEAR7) | _BV(UCSZ01) | _BV(UCSZ00);
|
|
||||||
|
|
||||||
// Set USART baud rate @ 9600. Divider is 103 @ 16 MHz.
|
|
||||||
UBRR0L = 103;
|
|
||||||
|
|
||||||
// Enable internal pull-up on Rx pin.
|
|
||||||
PORTD |= _BV(PD0);
|
|
||||||
|
|
||||||
// Enable Tx & Rx.
|
|
||||||
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : UsartIsChr
|
|
||||||
|
|
||||||
Description : Return status of USART Rx buffer.
|
|
||||||
|
|
||||||
Argument(s) : None.
|
|
||||||
|
|
||||||
Return value : 0 if Rx buffer empty.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
bool UsartIsChr ( void )
|
|
||||||
{
|
|
||||||
return UCSR0A & _BV(RXC0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : UsartGetChr
|
|
||||||
|
|
||||||
Description : Return character USART Rx buffer. Blocking until Rx buffer not empty.
|
|
||||||
|
|
||||||
Argument(s) : None.
|
|
||||||
|
|
||||||
Return value : Character in Rx buffer.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
char UsartGetChr ( void )
|
|
||||||
{
|
|
||||||
while ( !UsartIsChr() );
|
|
||||||
|
|
||||||
return UDR0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : UsartPutChr
|
|
||||||
|
|
||||||
Description : Send a character through the USART.
|
|
||||||
|
|
||||||
Argument(s) : c -> char to send.
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
void UsartPutChr ( char c )
|
|
||||||
{
|
|
||||||
// Wait for transmit register to be empty.
|
|
||||||
while ( !(UCSR0A & _BV(UDRE0)) );
|
|
||||||
|
|
||||||
UDR0 = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : UsartPutStr
|
|
||||||
|
|
||||||
Description : Transmit a string on the serial port.
|
|
||||||
|
|
||||||
Argument(s) : str -> pointer to string to send.
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
void UsartPutStr ( char *str )
|
|
||||||
{
|
|
||||||
while ( *str )
|
|
||||||
{
|
|
||||||
UsartPutChr( *str++ );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : UsartPutCStr
|
|
||||||
|
|
||||||
Description : Transmit a string on the serial port.
|
|
||||||
|
|
||||||
Argument(s) : str -> pointer to constant string to send (strings in Flash).
|
|
||||||
|
|
||||||
Return value : None.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
void UsartPutCStr ( const char *str )
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
|
|
||||||
while ( (c = pgm_read_byte_near( str++ )) )
|
|
||||||
{
|
|
||||||
UsartPutChr( c );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
End of file.
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
37
USART.h
37
USART.h
@ -1,37 +0,0 @@
|
|||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : USART.h
|
|
||||||
|
|
||||||
Description : Header file for USART functions.
|
|
||||||
|
|
||||||
History : 2004-10-22 - Created by Louis Frigon.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
#ifndef _USART_H_
|
|
||||||
#define _USART_H_
|
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
|
|
||||||
#define USART_BUFFER_SIZE 80
|
|
||||||
|
|
||||||
extern char UsartMsgBuffer[ USART_BUFFER_SIZE ];
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
Function prototypes
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
// Function prototypes are mandatory otherwise the compiler generates unreliable code.
|
|
||||||
|
|
||||||
void InitUSART ( void );
|
|
||||||
bool UsartIsChr ( void );
|
|
||||||
char UsartGetChr ( void );
|
|
||||||
void UsartPutChr ( char c );
|
|
||||||
void UsartPutStr ( char *str );
|
|
||||||
void UsartPutCStr ( const char *str );
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _USART_H_
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
End of file.
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
Loading…
x
Reference in New Issue
Block a user