Browse Source

Initial Commit

Allen Hill 6 years ago
commit
9091a232ab
16 changed files with 6320 additions and 0 deletions
  1. 967
    0
      AVCLanDriver.c
  2. 109
    0
      AVCLanDriver.h
  3. BIN
      AVCLanDriver.o
  4. BIN
      BigPcb.jpg
  5. BIN
      BigSchematic.jpg
  6. 50
    0
      GlobalDef.h
  7. 28
    0
      Makefile
  8. 144
    0
      ToyotaAuxEnabler.c
  9. BIN
      ToyotaAuxEnabler.elf
  10. 273
    0
      ToyotaAuxEnabler.hex
  11. BIN
      ToyotaAuxEnabler.o
  12. 144
    0
      USART.c
  13. 37
    0
      USART.h
  14. BIN
      USART.o
  15. 2990
    0
      log.txt
  16. 1578
    0
      screenlog.0

+ 967
- 0
AVCLanDriver.c View File

@@ -0,0 +1,967 @@
1
+/*--------------------------------------------------------------------------------------------------
2
+
3
+  Name         :  AVCLanDriver.c
4
+
5
+  Description  :  AVC Lan driver for Toyota devices.
6
+
7
+  Author       :  Louis Frigon
8
+
9
+  Copyright    :  (c) 2007 SigmaObjects
10
+
11
+----------------------------------------------------------------------------------------------------
12
+                                          AVC LAN Theory
13
+
14
+     The AVC bus is an implementation of the IEBus which is a differential line, floating on logical
15
+     level '1' and driving on logical '0'. Floating level shall be below 20 mV whereas driving level
16
+     shall be above 120 mV.
17
+
18
+     The diagram below represents how things work from a logical perspective on the bus.
19
+
20
+     A rising edge indicates a new bit. The duration of the high state tells whether it is a start
21
+     bit (~165 us), a bit '0' (~30 us) or a bit '1' (~20 us). A normal bit length is close to 40 us.
22
+
23
+                       |<---- Bit '0' ---->|<---- Bit '1' ---->|
24
+     Physical '1'      ,---------------,   ,---------,         ,---------
25
+                       ^               |   ^         |         ^
26
+     Physical '0' -----'               '---'         '---------'--------- Idle low
27
+                       |---- 32 us ----| 7 |- 20 us -|- 19 us -|
28
+
29
+     A bit '1' is typically 20 us high followed by 19 us low.
30
+
31
+     A bit '0' is typically 32 us high followed by 7 us low. A bit '0' is dominant i.e. it takes
32
+     precedence over a '1' by extending the pulse. This is why lower addresses win on arbitration.
33
+
34
+     A start bit is typically 165 us high followed by 30 us low.
35
+
36
+                                  AVC LAN Frame Format
37
+     Bits Description
38
+
39
+      1   Start bit
40
+      1   MSG_NORMAL
41
+      12  Master address
42
+      1   Parity
43
+      12  Slave address
44
+      1   Parity
45
+      1   * Acknowledge * (read below)
46
+      4   Control
47
+      1   Parity
48
+      1   * Acknowledge * (read below)
49
+      8   Payload length (n)
50
+      1   Parity
51
+      1   * Acknowledge * (read below)
52
+          8   Data
53
+          1   Parity
54
+          1   * Acknowledge * (read below)
55
+      repeat 'n' times
56
+
57
+     In point-to-point communication, sender issues an ack bit with value '1' (20 us). Receiver
58
+     upon acking will extend the bit until it looks like a '0' (32 us) on the bus. In broadcast
59
+     mode, receiver disregards the bit.
60
+
61
+     An acknowledge bit of value '0' means OK, '1' means no ack.
62
+
63
+--------------------------------------------------------------------------------------------------*/
64
+#include <avr/io.h>
65
+#include <avr/interrupt.h>
66
+#include <avr/wdt.h>
67
+#include <stdio.h>
68
+
69
+#include "GlobalDef.h"
70
+#include "USART.h"
71
+#include "AVCLanDriver.h"
72
+
73
+/*--------------------------------------------------------------------------------------------------
74
+                                      Local Functions
75
+--------------------------------------------------------------------------------------------------*/
76
+static void         SendStartBit ( void );
77
+static void         Send12BitWord ( word data );
78
+static void         Send8BitWord ( byte data );
79
+static void         Send4BitWord ( byte data );
80
+static void         Send1BitWord ( bool data );
81
+static bool         SendMessage ( void );
82
+
83
+static word         ReadBits ( byte nbBits );
84
+static bool         ReadAcknowledge ( void );
85
+
86
+static bool         HandleAcknowledge ( void );
87
+static bool         IsAvcBusFree ( void );
88
+
89
+static AvcActionID  GetActionID ( void );
90
+static void         LoadDataInGlogalRegisters ( AvcOutMessage * msg );
91
+
92
+/*--------------------------------------------------------------------------------------------------
93
+                                      Global Variables
94
+--------------------------------------------------------------------------------------------------*/
95
+// Message frame global registers
96
+static const char * Description;
97
+static bool         Broadcast;
98
+static word         MasterAddress;
99
+static word         SlaveAddress;
100
+static byte         Control;
101
+static byte         DataSize;
102
+static bool         ParityBit;
103
+static byte         Data[ 256 ];
104
+
105
+bool         AUX_Enabled     = FALSE;
106
+AvcActionID  DeviceEnabled   = ACT_NONE; //casting possibly unneccesary
107
+
108
+static AvcInMessage MessageTable [] PROGMEM =
109
+{
110
+/*--------------------------------------------------------------------------------------------------
111
+                                  Head Unit (HU) Messages
112
+    0x60 = Tuner ID
113
+    0x61 = Tape ID
114
+    0x62 = CD ID
115
+    0x63 = CD Changer ID (this is what we're emulating)
116
+--------------------------------------------------------------------------------------------------*/
117
+    { ACT_AUX_IN_USE,   4, {0x11, 0x01, 0x45, 0x01}, "AUX in use" },
118
+    { ACT_TUNER_IN_USE, 4, {0x11, 0x01, 0x45, 0x60}, "Tuner in use" },
119
+    { ACT_TAPE_IN_USE,  4, {0x11, 0x01, 0x45, 0x61}, "Tape in use" },
120
+    { ACT_CD_IN_USE,    4, {0x11, 0x01, 0x45, 0x62}, "CD in use" },
121
+
122
+    { ACT_NONE,         3, {0x11, 0x01, 0x46}, "No device in use" },
123
+    { ACT_NONE,         3, {0x11, 0x01, 0x20 /* xx */}, "Ping" }, // Get this once every minute in radio off mode. xx increments
124
+    { ACT_TUNER_INFO, 5, {0x60, 0x31, 0xF1, 0x01, 0x01 /* xx xx xx 0x00 0x00 0x00 0x00 */ /* 81 0 C9 = 107.9 or 107.7*/}, "Tuner Status"},
125
+    { ACT_EJECT_CD,    10, {0x62, 0x31, 0xF1, 0x00, 0x30, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80}, "Eject CD" },
126
+    { ACT_NO_CD,       10, {0x62, 0x31, 0xF1, 0x00, 0xF8, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80}, "No CD" },
127
+//    { ACT_CD_INFO,      6, {0x62, 0x31, 0xF1, 0x01, 0x10, 0x01 /* Track #, Min, Sec, 0x00, 0x80 */}, "CD Info: " },
128
+    {ACT_AUDIO_STATUS, 4, { 0x74, 0x31, 0xF1, 0x90 /* Volume, Balance, Fade, Bass, 0x10, Treble, 0x00, 0x0F, 0x00, 0x00 */ }, "Audio Status"},
129
+
130
+    { ACT_STATUS,       3, {0x00, 0x01, 0x0A}, "LAN Status" },
131
+    { ACT_REGISTER,     3, {0x11, 0x01, 0x00}, "LAN Register" },
132
+    { ACT_INIT,         3, {0x11, 0x01, 0x01}, "LAN Restart" },
133
+    { ACT_CHECK,        3, {0x11, 0x01, 0x20}, "LAN Check" },
134
+
135
+    { (AvcActionID)FALSE } //possibly should be ACT_NONE
136
+};
137
+
138
+const byte MessageTableSize = sizeof( MessageTable ) / sizeof( AvcInMessage );
139
+
140
+/*--------------------------------------------------------------------------------------------------
141
+                                    Our (CD) Commands
142
+--------------------------------------------------------------------------------------------------*/
143
+AvcOutMessage CmdReset    PROGMEM = { MSG_BCAST,  5, {0x00, 0x00, 0x00, 0x00, 0x00}, "Reset" }; // This causes HU to send ACT_REGISTER
144
+
145
+//AvcOutMessage CmdRegister PROGMEM = { MSG_NORMAL, 5, {0x00, 0x01, 0x11, 0x10, 0x63}, "Register" };
146
+//AvcOutMessage CmdRegister PROGMEM = { MSG_NORMAL, 5, {0x00, 0x01, 0x11, 0x54, 0x63}, "Toggle HU On/Off" };
147
+//AvcOutMessage CmdRegister PROGMEM = { MSG_NORMAL, 5, {0x00, 0x01, 0x11, 0x54, 0x63}, "Toggle HU On/Off" };
148
+AvcOutMessage CmdEnableAux  PROGMEM = { MSG_NORMAL, 5, {0x00, 0x01, 0x11, 0x50, 0x61}, "Enable AUX" };
149
+AvcOutMessage CmdDisableAux PROGMEM = { MSG_NORMAL, 5, {0x00, 0x01, 0x11, 0x51, 0x61}, "Disable AUX" };
150
+
151
+/*--------------------------------------------------------------------------------------------------
152
+
153
+  Name         :  AvcRegisterMe
154
+
155
+  Description  :  Sends registration message to master controller.
156
+
157
+  Argument(s)  :  None.
158
+
159
+  Return value :  (bool) -> TRUE if successful else FALSE.
160
+
161
+--------------------------------------------------------------------------------------------------*/
162
+bool AvcRegisterMe ( void )
163
+{
164
+    Broadcast     = MSG_NORMAL;
165
+    MasterAddress = MY_ADDRESS;
166
+    SlaveAddress  = HU_ADDRESS;
167
+    Control       = CONTROL_FLAGS;
168
+
169
+    AvcProcessActionID( ACT_REGISTER );
170
+
171
+    return TRUE;
172
+}
173
+
174
+/*--------------------------------------------------------------------------------------------------
175
+
176
+  Name         :  AvcReadMessage
177
+
178
+  Description  :  Read incoming messages on the AVC LAN bus.
179
+
180
+  Argument(s)  :  None.
181
+
182
+  Return value :  (AvcActionID) -> Action ID associated with this message.
183
+
184
+--------------------------------------------------------------------------------------------------*/
185
+AvcActionID AvcReadMessage ( void )
186
+{
187
+    ReadBits( 1 ); // Start bit.
188
+
189
+    LedOn();
190
+
191
+    Broadcast = ReadBits( 1 );
192
+
193
+    MasterAddress = ReadBits( 12 );
194
+    bool p = ParityBit;
195
+    if ( p != ReadBits( 1 ) )
196
+    {
197
+        UsartPutCStr( PSTR("AvcReadMessage: Parity error @ MasterAddress!\r\n") );
198
+        return (AvcActionID)FALSE;
199
+    }
200
+
201
+    SlaveAddress = ReadBits( 12 );
202
+    p = ParityBit;
203
+    if ( p != ReadBits( 1 ) )
204
+    {
205
+        UsartPutCStr( PSTR("AvcReadMessage: Parity error @ SlaveAddress!\r\n") );
206
+        return (AvcActionID)FALSE;
207
+    }
208
+
209
+    bool forMe = ( SlaveAddress == MY_ADDRESS );
210
+
211
+    // In point-to-point communication, sender issues an ack bit with value '1' (20us). Receiver
212
+    // upon acking will extend the bit until it looks like a '0' (32us) on the bus. In broadcast
213
+    // mode, receiver disregards the bit.
214
+
215
+    if ( forMe )
216
+    {
217
+        // Send ACK.
218
+        Send1BitWord( 0 );
219
+    }
220
+    else
221
+    {
222
+        ReadBits( 1 );
223
+    }
224
+
225
+    Control = ReadBits( 4 );
226
+    p = ParityBit;
227
+    if ( p != ReadBits( 1 ) )
228
+    {
229
+        UsartPutCStr( PSTR("AvcReadMessage: Parity error @ Control!\r\n") );
230
+        return (AvcActionID)FALSE;
231
+    }
232
+
233
+    if ( forMe )
234
+    {
235
+        // Send ACK.
236
+        Send1BitWord( 0 );
237
+    }
238
+    else
239
+    {
240
+        ReadBits( 1 );
241
+    }
242
+
243
+    DataSize = ReadBits( 8 );
244
+    p = ParityBit;
245
+    if ( p != ReadBits( 1 ) )
246
+    {
247
+        UsartPutCStr( PSTR("AvcReadMessage: Parity error @ DataSize!\r\n") );
248
+        return (AvcActionID)FALSE;
249
+    }
250
+
251
+    if ( forMe )
252
+    {
253
+        // Send ACK.
254
+        Send1BitWord( 0 );
255
+    }
256
+    else
257
+    {
258
+        ReadBits( 1 );
259
+    }
260
+
261
+    byte i;
262
+
263
+    for ( i = 0; i < DataSize; i++ )
264
+    {
265
+        Data[i] = ReadBits( 8 );
266
+        p = ParityBit;
267
+        if ( p != ReadBits( 1 ) )
268
+        {
269
+            sprintf( UsartMsgBuffer, "AvcReadMessage: Parity error @ Data[%d]\r\n", i );
270
+            UsartPutStr( UsartMsgBuffer );
271
+            return (AvcActionID)FALSE;
272
+        }
273
+
274
+        if ( forMe )
275
+        {
276
+            // Send ACK.
277
+            Send1BitWord( 0 );
278
+        }
279
+        else
280
+        {
281
+            ReadBits( 1 );
282
+        }
283
+    }
284
+
285
+    // Dump message on terminal.
286
+    if ( forMe ) UsartPutCStr( PSTR("AvcReadMessage: This message is for me!\r\n") );
287
+
288
+    AvcActionID actionID = GetActionID();
289
+
290
+    // switch ( actionID ) {
291
+    //   case /* value */:
292
+    // }
293
+    DumpRawMessage( FALSE );
294
+
295
+    LedOff();
296
+
297
+    return actionID;
298
+}
299
+
300
+/*--------------------------------------------------------------------------------------------------
301
+
302
+  Name         :  AvcProcessActionID
303
+
304
+  Description  :  Perform processing for given action ID.
305
+
306
+  Argument(s)  :  actionID (AvcActionID) -> Action ID to process.
307
+
308
+  Return value :  (bool) -> TRUE if action performed.
309
+
310
+--------------------------------------------------------------------------------------------------*/
311
+bool AvcProcessActionID ( AvcActionID actionID )
312
+{
313
+    // This function relies on the last received message still being loaded in global registers.
314
+
315
+    switch ( actionID )
316
+    {
317
+    case ACT_AUX_IN_USE:
318
+
319
+        AUX_Enabled = TRUE;
320
+        return FALSE;
321
+
322
+    case ACT_TUNER_IN_USE:
323
+    case ACT_TAPE_IN_USE:
324
+//    case ACT_AUDIO_STATUS: This is where we should print interpretted data (Volume, Balance, etc.)
325
+//    case ACT_TUNER_INFO:  Same here
326
+    case ACT_CD_IN_USE:
327
+
328
+        DeviceEnabled = actionID;
329
+        AUX_Enabled = FALSE;
330
+        return FALSE;
331
+
332
+//    case ACT_NO_CD:
333
+
334
+    case ACT_EJECT_CD:
335
+
336
+        // Normal CD eject command.
337
+        if ( DeviceEnabled == ACT_CD_IN_USE ) return FALSE;
338
+
339
+        if ( AUX_Enabled )
340
+        {
341
+            LoadDataInGlogalRegisters ( &CmdDisableAux );
342
+            AUX_Enabled = FALSE;
343
+        }
344
+        else
345
+        {
346
+            LoadDataInGlogalRegisters ( &CmdEnableAux );
347
+            AUX_Enabled = TRUE;
348
+        }
349
+
350
+        return SendMessage();
351
+        break;
352
+
353
+    default:
354
+
355
+        // No success!
356
+        UsartPutCStr( PSTR("AvcProcessActionID: Unknown action ID!\r\n") );
357
+        //POssibly dumpmsgbuffer here for sebuggimng
358
+        return FALSE;
359
+    }
360
+
361
+    // Nothing to do!
362
+    return FALSE;
363
+}
364
+
365
+/*--------------------------------------------------------------------------------------------------
366
+
367
+  Name         :  LoadDataInGlogalRegisters
368
+
369
+  Description  :  Loads message data in global registers for given mesage ID.
370
+
371
+  Argument(s)  :  msg (AvcOutMessage *) -> Message to load.
372
+
373
+  Return value :  None.
374
+
375
+--------------------------------------------------------------------------------------------------*/
376
+void LoadDataInGlogalRegisters ( AvcOutMessage * msg )
377
+{
378
+    Description = msg->Description;
379
+
380
+    Broadcast = pgm_read_byte_near( &msg->Mode );
381
+
382
+    MasterAddress = MY_ADDRESS;
383
+
384
+    if ( Broadcast == MSG_BCAST )
385
+        SlaveAddress = BROADCAST_ADDRESS;
386
+    else
387
+        SlaveAddress = HU_ADDRESS;
388
+
389
+    DataSize = pgm_read_byte_near( &msg->DataSize );
390
+
391
+    for ( byte i = 0; i < DataSize; i++ )
392
+    {
393
+        Data[i] = pgm_read_byte_near( &msg->Data[i] );
394
+    }
395
+}
396
+
397
+/*--------------------------------------------------------------------------------------------------
398
+
399
+  Name         :  GetActionID
400
+
401
+  Description  :  Use the last received message to determine the corresponding action ID.
402
+
403
+  Argument(s)  :  None.
404
+
405
+  Return value :  (AvcActionID) -> Action ID corresponding to current message.
406
+
407
+--------------------------------------------------------------------------------------------------*/
408
+AvcActionID GetActionID ( void )
409
+{
410
+    Description = PSTR("Unknown message!");
411
+
412
+    // Iterate through all HU messages in table.
413
+    for ( byte msg = 0; msg < MessageTableSize; msg++ )
414
+    {
415
+        bool found = TRUE;
416
+
417
+        // Identify current message from it's payload data.
418
+        for ( byte i = 0; i < pgm_read_byte_near( &MessageTable[msg].DataSize ); i++ )
419
+        {
420
+            if ( Data[i] != pgm_read_byte_near( &MessageTable[msg].Data[i] ) )
421
+            {
422
+                found = FALSE;
423
+                break;
424
+            }
425
+        }
426
+
427
+        if ( found )
428
+        {
429
+            Description = MessageTable[msg].Description;
430
+
431
+            // Fetch action corresponding to the message.
432
+            AvcActionID actionID = pgm_read_byte_near( &MessageTable[msg].ActionID );
433
+
434
+            return actionID;
435
+        }
436
+    }
437
+
438
+    return ACT_NONE;
439
+}
440
+
441
+/*--------------------------------------------------------------------------------------------------
442
+
443
+  Name         :  Send12BitWord
444
+
445
+  Description  :  Writes a 12 bit word on the AVC LAN bus.
446
+
447
+  Argument(s)  :  data (word) -> Data to write.
448
+
449
+  Return value :  None.
450
+
451
+--------------------------------------------------------------------------------------------------*/
452
+void Send12BitWord ( word data )
453
+{
454
+    ParityBit = 0;
455
+
456
+    // Most significant bit out first.
457
+    for ( char nbBits = 0; nbBits < 12; nbBits++ )
458
+    {
459
+        // Reset timer to measure bit length.
460
+        TCNT0 = 0;
461
+
462
+        // Drive output to signal high.
463
+        DDRD |= _BV(PD2) | _BV(PD3);
464
+
465
+        if ( data & 0x0800 )
466
+        {
467
+            // Adjust parity.
468
+            ParityBit = ! ParityBit;
469
+
470
+            while ( TCNT0 < BIT_1_HOLD_ON_LENGTH );
471
+        }
472
+        else
473
+        {
474
+            while ( TCNT0 < BIT_0_HOLD_ON_LENGTH );
475
+        }
476
+
477
+        // Release output.
478
+        DDRD &= ~( _BV(PD2) | _BV(PD3) );
479
+
480
+        // Hold output low until end of bit.
481
+        while ( TCNT0 < NORMAL_BIT_LENGTH );
482
+
483
+        // Fetch next bit.
484
+        data <<= 1;
485
+    }
486
+}
487
+
488
+/*--------------------------------------------------------------------------------------------------
489
+
490
+  Name         :  Send8BitWord
491
+
492
+  Description  :  Writes an 8 bit word on the AVC LAN bus.
493
+
494
+  Argument(s)  :  data (byte) -> Data to write.
495
+
496
+  Return value :  None.
497
+
498
+--------------------------------------------------------------------------------------------------*/
499
+void Send8BitWord ( byte data )
500
+{
501
+    ParityBit = 0;
502
+
503
+    // Most significant bit out first.
504
+    for ( char nbBits = 0; nbBits < 8; nbBits++ )
505
+    {
506
+        // Reset timer to measure bit length.
507
+        TCNT0 = 0;
508
+
509
+        // Drive output to signal high.
510
+        DDRD |= _BV(PD2) | _BV(PD3);
511
+
512
+        if ( data & 0x80 )
513
+        {
514
+            // Adjust parity.
515
+            ParityBit = ! ParityBit;
516
+
517
+            while ( TCNT0 < BIT_1_HOLD_ON_LENGTH );
518
+        }
519
+        else
520
+        {
521
+            while ( TCNT0 < BIT_0_HOLD_ON_LENGTH );
522
+        }
523
+
524
+        // Release output.
525
+        DDRD &= ~( _BV(PD2) | _BV(PD3) );
526
+
527
+        // Hold output low until end of bit.
528
+        while ( TCNT0 < NORMAL_BIT_LENGTH );
529
+
530
+        // Fetch next bit.
531
+        data <<= 1;
532
+    }
533
+}
534
+
535
+/*--------------------------------------------------------------------------------------------------
536
+
537
+  Name         :  Send4BitWord
538
+
539
+  Description  :  Writes a 4 bit word on the AVC LAN bus.
540
+
541
+  Argument(s)  :  data (byte) -> Data to write.
542
+
543
+  Return value :  None.
544
+
545
+--------------------------------------------------------------------------------------------------*/
546
+void Send4BitWord ( byte data )
547
+{
548
+    ParityBit = 0;
549
+
550
+    // Most significant bit out first.
551
+    for ( char nbBits = 0; nbBits < 4; nbBits++ )
552
+    {
553
+        // Reset timer to measure bit length.
554
+        TCNT0 = 0;
555
+
556
+        // Drive output to signal high.
557
+        DDRD |= _BV(PD2) | _BV(PD3);
558
+
559
+        if ( data & 0x8 )
560
+        {
561
+            // Adjust parity.
562
+            ParityBit = ! ParityBit;
563
+
564
+            while ( TCNT0 < BIT_1_HOLD_ON_LENGTH );
565
+        }
566
+        else
567
+        {
568
+            while ( TCNT0 < BIT_0_HOLD_ON_LENGTH );
569
+        }
570
+
571
+        // Release output.
572
+        DDRD &= ~( _BV(PD2) | _BV(PD3) );
573
+
574
+        // Hold output low until end of bit.
575
+        while ( TCNT0 < NORMAL_BIT_LENGTH );
576
+
577
+        // Fetch next bit.
578
+        data <<= 1;
579
+    }
580
+}
581
+
582
+/*--------------------------------------------------------------------------------------------------
583
+
584
+  Name         :  Send1BitWord
585
+
586
+  Description  :  Writes a 1 bit word on the AVC LAN bus.
587
+
588
+  Argument(s)  :  data (bool) -> Data to write.
589
+
590
+  Return value :  None.
591
+
592
+--------------------------------------------------------------------------------------------------*/
593
+void Send1BitWord ( bool data )
594
+{
595
+    // Reset timer to measure bit length.
596
+    TCNT0 = 0;
597
+
598
+    // Drive output to signal high.
599
+    DDRD |= _BV(PD2) | _BV(PD3);
600
+
601
+    if ( data )
602
+    {
603
+        while ( TCNT0 < BIT_1_HOLD_ON_LENGTH );
604
+    }
605
+    else
606
+    {
607
+        while ( TCNT0 < BIT_0_HOLD_ON_LENGTH );
608
+    }
609
+
610
+    // Release output.
611
+    DDRD &= ~( _BV(PD2) | _BV(PD3) );
612
+
613
+    // Pulse level low duration until 40 us.
614
+    while ( TCNT0 <  NORMAL_BIT_LENGTH );
615
+}
616
+
617
+/*--------------------------------------------------------------------------------------------------
618
+
619
+  Name         :  SendStartBit
620
+
621
+  Description  :  Writes a start bit on the AVC LAN bus.
622
+
623
+  Argument(s)  :  None.
624
+
625
+  Return value :  None.
626
+
627
+--------------------------------------------------------------------------------------------------*/
628
+void SendStartBit ( void )
629
+{
630
+    // Reset timer to measure bit length.
631
+    TCNT0 = 0;
632
+
633
+    // Drive output to signal high.
634
+    DDRD |= _BV(PD2) | _BV(PD3);
635
+
636
+    // Pulse level high duration.
637
+    while ( TCNT0 < START_BIT_HOLD_ON_LENGTH );
638
+
639
+    // Release output.
640
+    DDRD &= ~( _BV(PD2) | _BV(PD3) );
641
+
642
+    // Pulse level low duration until ~185 us.
643
+    while ( TCNT0 < START_BIT_LENGTH );
644
+}
645
+
646
+/*--------------------------------------------------------------------------------------------------
647
+
648
+  Name         :  ReadBits
649
+
650
+  Description  :  Reads specified number of bits from the AVC LAN bus.
651
+
652
+  Argument(s)  :  nbBits (byte) -> Number of bits to read.
653
+
654
+  Return value :  (word) -> Data value read.
655
+
656
+                       |<---- Bit '0' ---->|<---- Bit '1' ---->|
657
+     Physical '1'      ,---------------,   ,---------,         ,---------
658
+                       ^               |   ^         |         ^
659
+     Physical '0' -----'               '---'         '---------'--------- Idle low
660
+                       |---- 32 us ----| 7 |- 20 us -|- 19 us -|
661
+
662
+--------------------------------------------------------------------------------------------------*/
663
+word ReadBits ( byte nbBits )
664
+{
665
+    word data = 0;
666
+
667
+    ParityBit = 0;
668
+
669
+    while ( nbBits-- > 0 )
670
+    {
671
+        // Insert new bit
672
+        data <<= 1;
673
+
674
+        // Wait until rising edge of new bit.
675
+        while ( INPUT_IS_CLEAR )
676
+        {
677
+            // Reset watchdog.
678
+            wdt_reset();
679
+        }
680
+
681
+        // Reset timer to measure bit length.
682
+        TCNT0 = 0;
683
+
684
+        // Wait until falling edge.
685
+        while ( INPUT_IS_SET );
686
+
687
+        // Compare half way between a '1' (20 us) and a '0' (32 us ): 32 - (32 - 20) /2 = 26 us
688
+        if ( TCNT0 < BIT_0_HOLD_ON_LENGTH - (BIT_0_HOLD_ON_LENGTH - BIT_1_HOLD_ON_LENGTH) / 2 )
689
+        {
690
+            // Set new bit.
691
+            data |= 0x0001;
692
+
693
+            // Adjust parity.
694
+            ParityBit = ! ParityBit;
695
+        }
696
+    }
697
+
698
+    return data;
699
+}
700
+
701
+/*--------------------------------------------------------------------------------------------------
702
+
703
+  Name         :  SendMessage
704
+
705
+  Description  :  Sends the message in global registers on the AVC LAN bus.
706
+
707
+  Argument(s)  :  None.
708
+
709
+  Return value :  (bool) -> TRUE if successful else FALSE.
710
+
711
+--------------------------------------------------------------------------------------------------*/
712
+bool SendMessage ( void )
713
+{
714
+    while ( ! IsAvcBusFree() );
715
+
716
+    // At this point we know the bus is available.
717
+
718
+    LedOn();
719
+
720
+    // Send start bit.
721
+    SendStartBit();
722
+
723
+    // Broadcast bit.
724
+    Send1BitWord( Broadcast );
725
+
726
+    // Master address = me.
727
+    Send12BitWord( MasterAddress );
728
+    Send1BitWord( ParityBit );
729
+
730
+    // Slave address = head unit (HU).
731
+    Send12BitWord( SlaveAddress );
732
+    Send1BitWord( ParityBit );
733
+
734
+    if ( ! HandleAcknowledge() )
735
+    {
736
+        DumpRawMessage( TRUE );
737
+        UsartPutStr( (char*)"SendMessage: No Ack @ Slave address\r\n" );
738
+        return FALSE;
739
+    }
740
+
741
+    // Control flag + parity.
742
+    Send4BitWord( Control );
743
+    Send1BitWord( ParityBit );
744
+
745
+    if ( ! HandleAcknowledge() )
746
+    {
747
+        DumpRawMessage( TRUE );
748
+        UsartPutStr( (char*)"SendMessage: No Ack @ Control\r\n" );
749
+        return FALSE;
750
+    }
751
+
752
+    // Data length + parity.
753
+    Send8BitWord( DataSize );
754
+    Send1BitWord( ParityBit );
755
+
756
+    if ( ! HandleAcknowledge() )
757
+    {
758
+        DumpRawMessage( TRUE );
759
+        UsartPutStr( (char*)"SendMessage: No Ack @ DataSize\r\n" );
760
+        return FALSE;
761
+    }
762
+
763
+    for ( byte i = 0; i < DataSize; i++ )
764
+    {
765
+        Send8BitWord( Data[i] );
766
+        Send1BitWord( ParityBit );
767
+
768
+        if ( ! HandleAcknowledge() )
769
+        {
770
+            DumpRawMessage( TRUE );
771
+            sprintf( UsartMsgBuffer, "SendMessage: No Ack @ Data[%d]\r\n", i );
772
+            UsartPutStr( UsartMsgBuffer );
773
+            return FALSE;
774
+        }
775
+    }
776
+
777
+    DumpRawMessage( TRUE );
778
+
779
+    LedOff();
780
+
781
+    return TRUE;
782
+}
783
+
784
+/*--------------------------------------------------------------------------------------------------
785
+
786
+  Name         :  ReadAcknowledge
787
+
788
+  Description  :  Reads the acknowledge bit the AVC LAN bus.
789
+
790
+  Argument(s)  :  None.
791
+
792
+  Return value :  (bool) -> TRUE if ack detected else FALSE.
793
+
794
+--------------------------------------------------------------------------------------------------*/
795
+inline bool ReadAcknowledge ( void )
796
+{
797
+    // The acknowledge pattern is very tricky: the sender shall drive the bus for the equivalent
798
+    // of a bit '1' (20 us) then release the bus and listen. At this point the target shall have
799
+    // taken over the bus maintaining the pulse until the equivalent of a bit '0' (32 us) is formed.
800
+
801
+    // Reset timer to measure bit length.
802
+    TCNT0 = 0;
803
+
804
+    // Drive output to signal high.
805
+    DDRD |= _BV(PD2) | _BV(PD3);
806
+
807
+    // Generate bit '0'.
808
+    while ( TCNT0 < BIT_1_HOLD_ON_LENGTH );
809
+
810
+    // Release output.
811
+    DDRD &= ~( _BV(PD2) | _BV(PD3) );
812
+
813
+    // Measure final resulting bit.
814
+    while ( INPUT_IS_SET );
815
+
816
+    // Sample half-way through bit '0' (26 us) to detect whether the target is acknowledging.
817
+    if ( TCNT0 > BIT_0_HOLD_ON_LENGTH - (BIT_0_HOLD_ON_LENGTH - BIT_1_HOLD_ON_LENGTH) / 2 )
818
+    {
819
+        // Slave is acknowledging (ack = 0). Wait until end of ack bit.
820
+        while ( INPUT_IS_SET );
821
+        return TRUE;
822
+    }
823
+
824
+    // No sign of life on the bus.
825
+    return FALSE;
826
+}
827
+
828
+/*--------------------------------------------------------------------------------------------------
829
+
830
+  Name         :  HandleAcknowledge
831
+
832
+  Description  :  Sends ack bit if I am broadcasting otherwise wait and return received ack bit.
833
+
834
+  Argument(s)  :  None.
835
+
836
+  Return value :  (bool) -> FALSE if ack bit not detected.
837
+
838
+--------------------------------------------------------------------------------------------------*/
839
+bool HandleAcknowledge ( void )
840
+{
841
+    if ( Broadcast == MSG_BCAST )
842
+    {
843
+        // Acknowledge.
844
+        Send1BitWord( 0 );
845
+        return TRUE;
846
+    }
847
+
848
+    // Return acknowledge bit.
849
+    return ReadAcknowledge();
850
+}
851
+
852
+/*--------------------------------------------------------------------------------------------------
853
+
854
+  Name         :  IsAvcBusFree
855
+
856
+  Description  :  Determine whether the bus is free (no tx/rx).
857
+
858
+  Argument(s)  :  None.
859
+
860
+  Return value :  (bool) -> TRUE is bus is free.
861
+
862
+--------------------------------------------------------------------------------------------------*/
863
+bool IsAvcBusFree ( void )
864
+{
865
+    // Reset timer.
866
+    TCNT0 = 0;
867
+
868
+    while ( INPUT_IS_CLEAR )
869
+    {
870
+        // We assume the bus is free if anything happens for the length of 1 bit.
871
+        if ( TCNT0 > NORMAL_BIT_LENGTH )
872
+        {
873
+            return TRUE;
874
+        }
875
+    }
876
+
877
+    return FALSE;
878
+}
879
+
880
+/*--------------------------------------------------------------------------------------------------
881
+
882
+  Name         :  DumpRawMessage
883
+
884
+  Description  :  Dumps raw content of message registers on the terminal.
885
+
886
+  Argument(s)  :  incoming (bool) -> TRUE means incoming data, FALSE means outgoing.
887
+
888
+  Return value :  None.
889
+
890
+--------------------------------------------------------------------------------------------------*/
891
+void DumpRawMessage ( bool incoming )
892
+{
893
+    // Dump message on terminal.
894
+
895
+    if ( incoming )
896
+        UsartPutCStr( PSTR("\r\nAUX Enabler <<--- HU\r\n") );
897
+    else
898
+        UsartPutCStr( PSTR("\r\nAUX Enabler --->> HU\r\n") );
899
+
900
+    UsartPutCStr( PSTR("   Description:    ") );
901
+    UsartPutCStr( Description );
902
+    UsartPutCStr( PSTR("\r\n") );
903
+
904
+    sprintf( UsartMsgBuffer, "   Broadcast:      %d \r\n", Broadcast );
905
+    UsartPutStr( UsartMsgBuffer );
906
+
907
+    sprintf( UsartMsgBuffer, "   Master address: 0x%X \r\n", MasterAddress );
908
+    UsartPutStr( UsartMsgBuffer );
909
+
910
+    sprintf( UsartMsgBuffer, "   Slave address:  0x%X \r\n", SlaveAddress );
911
+    UsartPutStr( UsartMsgBuffer );
912
+
913
+    sprintf( UsartMsgBuffer, "   Control:        0x%X \r\n", Control );
914
+    UsartPutStr( UsartMsgBuffer );
915
+
916
+    sprintf( UsartMsgBuffer, "   Data size:      %d \r\n", DataSize );
917
+    UsartPutStr( UsartMsgBuffer );
918
+
919
+    sprintf( UsartMsgBuffer, "   Data:           " );
920
+    UsartPutStr( UsartMsgBuffer );
921
+
922
+    for ( byte i = 0; i < DataSize; i++ )
923
+    {
924
+        sprintf( UsartMsgBuffer, "%X ", Data[i] );
925
+        UsartPutStr( UsartMsgBuffer );
926
+    }
927
+
928
+    UsartPutStr( (char*)"\r\n-----\r\n" );
929
+}
930
+
931
+/*--------------------------------------------------------------------------------------------------
932
+
933
+  Name         :  LedOn
934
+
935
+  Description  :  Turn LED on (active low signal).
936
+
937
+  Argument(s)  :  None.
938
+
939
+  Return value :  None.
940
+
941
+--------------------------------------------------------------------------------------------------*/
942
+inline void LedOn ( void )
943
+{
944
+    LED_PORT &= ~LEDOUT;
945
+}
946
+
947
+/*--------------------------------------------------------------------------------------------------
948
+
949
+  Name         :  LedOff
950
+
951
+  Description  :  Turn LED off (active low signal).
952
+
953
+  Argument(s)  :  None.
954
+
955
+  Return value :  None.
956
+
957
+--------------------------------------------------------------------------------------------------*/
958
+inline void LedOff ( void )
959
+{
960
+    LED_PORT |= LEDOUT;
961
+}
962
+
963
+
964
+
965
+/*--------------------------------------------------------------------------------------------------
966
+                                         End of file.
967
+--------------------------------------------------------------------------------------------------*/

+ 109
- 0
AVCLanDriver.h View File

@@ -0,0 +1,109 @@
1
+/*--------------------------------------------------------------------------------------------------
2
+
3
+  Name         :  AvcLanDriver.h
4
+
5
+  Description  :  AVC Lan driver for Toyota devices
6
+
7
+--------------------------------------------------------------------------------------------------*/
8
+#ifndef _AVCLANDRV_H_
9
+#define _AVCLANDRV_H_
10
+
11
+#include "GlobalDef.h"
12
+
13
+#define HU_ADDRESS                  0x190       // But possibly 0x160, known to be both
14
+
15
+#define MY_ADDRESS                  0x360       // CD Changer #1
16
+
17
+#define BROADCAST_ADDRESS           0x01FF      // All audio devices
18
+
19
+#define CONTROL_FLAGS               0xF
20
+
21
+/*--------------------------------------------------------------------------------------------------
22
+
23
+                       |<---- Bit '0' ---->|<---- Bit '1' ---->|
24
+     Physical '1'      ,---------------,   ,---------,         ,---------
25
+                       ^               |   ^         |         ^
26
+     Physical '0' -----'               '---'         '---------'--------- Idle low
27
+                       |---- 33 us ----| 7 |- 20 us -|- 20 us -|
28
+
29
+     A bit '0' is typically 33 us high followed by 7 us low.
30
+     A bit '1' is typically 20 us high followed by 20 us low.
31
+     A start bit is typically 165 us high followed by 30 us low.
32
+
33
+--------------------------------------------------------------------------------------------------*/
34
+
35
+// Following multipliers result of Timer 0 prescaler having 2 counts/us
36
+#define NORMAL_BIT_LENGTH           74 //37*2
37
+
38
+#define BIT_1_HOLD_ON_LENGTH        40 //20*2
39
+#define BIT_0_HOLD_ON_LENGTH        64 //33*2
40
+
41
+#define START_BIT_LENGTH            372 //186*2
42
+#define START_BIT_HOLD_ON_LENGTH    336 //168*2
43
+
44
+typedef enum
45
+{   // No this is not a mistake, broadcast = 0!
46
+    MSG_NORMAL      = 1,
47
+    MSG_BCAST       = 0
48
+
49
+} AvcTransmissionMode;
50
+
51
+typedef enum
52
+{
53
+    ACT_NONE,
54
+
55
+    ACT_AUX_IN_USE,
56
+    ACT_TUNER_IN_USE,
57
+    ACT_TAPE_IN_USE,
58
+    ACT_CD_IN_USE,
59
+
60
+    ACT_EJECT_CD,
61
+    ACT_NO_CD,
62
+    ACT_TUNER_INFO,
63
+    ACT_AUDIO_STATUS,
64
+//    ACT_CD_INFO,
65
+
66
+    ACT_STATUS,
67
+    ACT_REGISTER,
68
+    ACT_INIT,
69
+    ACT_CHECK
70
+
71
+} AvcActionID;
72
+
73
+typedef struct
74
+{
75
+    AvcActionID         ActionID;           // Action to perform after receiving this message.
76
+    byte                DataSize;           // Payload data size (bytes).
77
+    byte                Data[ 11 ];         // Payload data.
78
+    char                Description[ 17 ];  // ASCII description of the command for terminal dump.
79
+
80
+} AvcIncomingMessageStruct;
81
+
82
+typedef const AvcIncomingMessageStruct AvcInMessage;
83
+
84
+typedef struct
85
+{
86
+    AvcTransmissionMode Mode;               // Transmission mode: normal (1) or broadcast (0).
87
+    byte                DataSize;           // Payload data size (bytes).
88
+    byte                Data[ 11 ];         // Payload data.
89
+    char                Description[ 17 ];  // ASCII description of the command for terminal dump.
90
+
91
+} AvcOutgoingMessageStruct;
92
+
93
+typedef const AvcOutgoingMessageStruct AvcOutMessage;
94
+
95
+/*--------------------------------------------------------------------------------------------------
96
+                                         Prototypes
97
+--------------------------------------------------------------------------------------------------*/
98
+AvcActionID     AvcReadMessage ( void );
99
+
100
+bool            AvcProcessActionID ( AvcActionID actionID );
101
+void            AvcUpdateStatus ( void );
102
+
103
+void            DumpRawMessage ( bool incoming );
104
+
105
+#endif // _AVCLANDRV_H_
106
+
107
+/*--------------------------------------------------------------------------------------------------
108
+                                         End of file.
109
+--------------------------------------------------------------------------------------------------*/

BIN
AVCLanDriver.o View File


BIN
BigPcb.jpg View File


BIN
BigSchematic.jpg View File


+ 50
- 0
GlobalDef.h View File

@@ -0,0 +1,50 @@
1
+/*--------------------------------------------------------------------------------------------------
2
+
3
+  Name         :  GlobalDef.h
4
+
5
+  Description  :  Global definitions.
6
+
7
+  History      :  2004/04/06 - Created by Louis Frigon.
8
+
9
+--------------------------------------------------------------------------------------------------*/
10
+#ifndef _GLOBALDEF_H_
11
+#define _GLOBALDEF_H_
12
+
13
+#include <avr/io.h>
14
+
15
+/*--------------------------------------------------------------------------------------------------
16
+                                          Constants
17
+--------------------------------------------------------------------------------------------------*/
18
+#define FALSE                   0
19
+#define TRUE                    (!FALSE)
20
+
21
+// AVC LAN bus directly connected to internal analog comparator (PD6/7)
22
+// PD6 AIN0 +
23
+// PD7 AIN1 -
24
+#define DATAIN_PIN              ACSR
25
+#define DATAIN                  ACO
26
+
27
+#define INPUT_IS_SET            ( bit_is_set( DATAIN_PIN, DATAIN ) )
28
+#define INPUT_IS_CLEAR          ( bit_is_clear( DATAIN_PIN, DATAIN ) )
29
+
30
+#define LED_DDR                 DDRB
31
+#define LED_PORT                PORTB
32
+#define LEDOUT                  _BV(PORT5)
33
+
34
+/*--------------------------------------------------------------------------------------------------
35
+                                       Type definitions
36
+--------------------------------------------------------------------------------------------------*/
37
+typedef unsigned char           byte;
38
+typedef unsigned int            word;
39
+
40
+/*--------------------------------------------------------------------------------------------------
41
+                                         Prototypes
42
+--------------------------------------------------------------------------------------------------*/
43
+inline void LedOff( void );
44
+inline void LedOn( void );
45
+
46
+#endif   //  _GLOBALDEF_H_
47
+
48
+/*--------------------------------------------------------------------------------------------------
49
+                                         End of file.
50
+--------------------------------------------------------------------------------------------------*/

+ 28
- 0
Makefile View File

@@ -0,0 +1,28 @@
1
+CC=avr-g++
2
+CFLAGS=-c -g -Os -Wall -fno-exceptions -fpermissive -ffunction-sections -fdata-sections -fno-threadsafe-statics -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR
3
+LFLAGS=-g -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR
4
+
5
+all: ToyotaAuxEnabler.hex
6
+
7
+ToyotaAuxEnabler.hex: ToyotaAuxEnabler.elf
8
+	avr-objcopy -j .text -j .data -O ihex ToyotaAuxEnabler.elf ToyotaAuxEnabler.hex
9
+
10
+ToyotaAuxEnabler.elf: ToyotaAuxEnabler.o USART.o AVCLanDriver.o
11
+	$(CC) $(LFLAGS) -o ToyotaAuxEnabler.elf ToyotaAuxEnabler.o USART.o AVCLanDriver.o
12
+
13
+ToyotaAuxEnabler.o: ToyotaAuxEnabler.c GlobalDef.h USART.h AVCLanDriver.h
14
+	$(CC) $(CFLAGS) ToyotaAuxEnabler.c
15
+
16
+USART.o: USART.c USART.h GlobalDef.h
17
+	$(CC) $(CFLAGS) USART.c
18
+
19
+AVCLanDriver.o: AVCLanDriver.c GlobalDef.h USART.h AVCLanDriver.h
20
+	$(CC) $(CFLAGS) AVCLanDriver.c
21
+
22
+clean:
23
+	rm *.o *.hex *.elf
24
+
25
+upload: ToyotaAuxEnabler.hex
26
+	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:ToyotaAuxEnabler.hex:i
27
+
28
+.PHONY: upload

+ 144
- 0
ToyotaAuxEnabler.c View File

@@ -0,0 +1,144 @@
1
+/*--------------------------------------------------------------------------------------------------
2
+
3
+  Name         :  ToyotaAuxEnabler.c
4
+
5
+  Description  :  This program enables the AUX audio input on old Toyota radios with CD. Pressing
6
+                  CD Eject button while no CD is loaded will toggle the AUX input.
7
+
8
+  MCU          :  ATmega328P @ 16 MHz.
9
+
10
+  Author       :  2007-01-27 - Louis Frigon
11
+
12
+  Copyright    :  (c) 2007 SigmaObjects
13
+
14
+  History      :  2007-01-27 - v0.1 Prototyping draft inspired from Marcin Slonicki's code.
15
+                  2007-02-24 - v1.0 Production release.
16
+
17
+--------------------------------------------------------------------------------------------------*/
18
+#include <avr/io.h>
19
+#include <avr/interrupt.h>
20
+#include <avr/wdt.h>
21
+#include <stdio.h>
22
+
23
+#include "GlobalDef.h"
24
+#include "USART.h"
25
+#include "AVCLanDriver.h"
26
+
27
+#define FIRMWARE_VERSION    "v1.0"
28
+#define FIRMWARE_DATE       __DATE__
29
+
30
+/*--------------------------------------------------------------------------------------------------
31
+                                         Prototypes
32
+--------------------------------------------------------------------------------------------------*/
33
+void InitMCU ( void );
34
+
35
+/*--------------------------------------------------------------------------------------------------
36
+                                      Global Variables
37
+--------------------------------------------------------------------------------------------------*/
38
+volatile bool   SecondsTick = FALSE;
39
+
40
+char            UsartMsgBuffer[ USART_BUFFER_SIZE ];
41
+
42
+/*--------------------------------------------------------------------------------------------------
43
+
44
+  Name         :  InitMCU
45
+
46
+  Description  :  Performs MCU initialization.
47
+
48
+  Argument(s)  :  None.
49
+
50
+  Return value :  None.
51
+
52
+--------------------------------------------------------------------------------------------------*/
53
+void InitMCU ( void )
54
+{
55
+    // Init LED port pin
56
+    LED_DDR |= LEDOUT;
57
+    LedOff();
58
+
59
+    // OLD: TCCR0A = _BV(CS01);
60
+    // Correction: TCCR0B has the CS0n bits, not TCCR0A, prescaler should be at 8 or less to have 1 or more counts/us
61
+    // Timer 0 prescaler = 8 ( 2 count / us )
62
+    TCCR0B = _BV(CS01);
63
+
64
+    InitUSART();
65
+
66
+    // Preset AVC bus driver output pins but leave pins tri-stated until we need to use them.
67
+    PORTD |= _BV(PD3);   // PD3 (+) high.
68
+    PORTD &= ~_BV(PD2);  // PD2 (-) low.
69
+
70
+    //  Enable watchdog @ ~2 sec.
71
+    // Likely this too, after research probably not, but maybe
72
+    wdt_enable( WDTO_2S );
73
+}
74
+
75
+/*--------------------------------------------------------------------------------------------------
76
+
77
+  Name         :  LedOn
78
+
79
+  Description  :  Turn LED on (active low signal).
80
+
81
+  Argument(s)  :  None.
82
+
83
+  Return value :  None.
84
+
85
+--------------------------------------------------------------------------------------------------*/
86
+inline void LedOn ( void )
87
+{
88
+    LED_PORT &= ~LEDOUT;
89
+}
90
+
91
+/*--------------------------------------------------------------------------------------------------
92
+
93
+  Name         :  LedOff
94
+
95
+  Description  :  Turn LED off (active low signal).
96
+
97
+  Argument(s)  :  None.
98
+
99
+  Return value :  None.
100
+
101
+--------------------------------------------------------------------------------------------------*/
102
+inline void LedOff ( void )
103
+{
104
+    LED_PORT |= LEDOUT;
105
+}
106
+
107
+/*--------------------------------------------------------------------------------------------------
108
+
109
+  Name         :  main
110
+
111
+  Description  :  Program's main function.
112
+
113
+  Argument(s)  :  None.
114
+
115
+  Return value :  None.
116
+
117
+--------------------------------------------------------------------------------------------------*/
118
+int main ( void )
119
+{
120
+    InitMCU();
121
+
122
+    UsartPutCStr( PSTR("\r\n\t\t     Toyota AVC-Lan AUX Enabler\r\n") );
123
+    UsartPutCStr( PSTR("\t\tCopyright (C) 2007, SigmaObjects Inc.\r\n") );
124
+
125
+    sprintf( UsartMsgBuffer, "\t\t     Firmware %s, %s\r\n\r\n", FIRMWARE_VERSION, FIRMWARE_DATE );
126
+    UsartPutStr( UsartMsgBuffer );
127
+
128
+    while ( 1 )
129
+    {
130
+        // Reset watchdog.
131
+        wdt_reset();
132
+
133
+        AvcActionID actionID = AvcReadMessage();
134
+
135
+        if ( actionID != ACT_NONE )
136
+        {
137
+            AvcProcessActionID( actionID );
138
+        }
139
+    }
140
+}
141
+
142
+/*--------------------------------------------------------------------------------------------------
143
+                                         End of file.
144
+--------------------------------------------------------------------------------------------------*/

BIN
ToyotaAuxEnabler.elf View File


+ 273
- 0
ToyotaAuxEnabler.hex View File

@@ -0,0 +1,273 @@
1
+:100000000C9414020C9431020C9431020C943102C1
2
+:100010000C9431020C9431020C9431020C94310294
3
+:100020000C9431020C9431020C9431020C94310284
4
+:100030000C9431020C9431020C9431020C94310274
5
+:100040000C9431020C9431020C9431020C94310264
6
+:100050000C9431020C9431020C9431020C94310254
7
+:100060000C9431020C9431020909436F7079726962
8
+:100070006768742028432920323030372C20536998
9
+:10008000676D614F626A6563747320496E632E0DFC
10
+:100090000A000D0A09092020202020546F796F746E
11
+:1000A00061204156432D4C616E2041555820456ECC
12
+:1000B00061626C65720D0A000D0A00202020446503
13
+:1000C000736372697074696F6E3A20202020000D8E
14
+:1000D0000A41555820456E61626C6572202D2D2DA8
15
+:1000E0003E3E2048550D0A000D0A41555820456EE8
16
+:1000F00061626C6572203C3C2D2D2D2048550D0A07
17
+:100100000041766350726F63657373416374696F06
18
+:100110006E49443A20556E6B6E6F776E2061637442
19
+:10012000696F6E204944210D0A00556E6B6E6F7722
20
+:100130006E206D657373616765210041766352655A
21
+:1001400061644D6573736167653A20546869732013
22
+:100150006D65737361676520697320666F72206DCA
23
+:1001600065210D0A00417663526561644D657373C4
24
+:100170006167653A20506172697479206572726FA7
25
+:10018000722040204461746153697A65210D0A0030
26
+:10019000417663526561644D6573736167653A20AA
27
+:1001A000506172697479206572726F7220402043C9
28
+:1001B0006F6E74726F6C210D0A0041766352656137
29
+:1001C000644D6573736167653A2050617269747933
30
+:1001D000206572726F72204020536C6176654164B5
31
+:1001E0006472657373210D0A004176635265616420
32
+:1001F0004D6573736167653A205061726974792047
33
+:100200006572726F722040204D6173746572416433
34
+:100210006472657373210D0A00010005000111511C
35
+:100220006100000000000044697361626C65204158
36
+:100230005558000000000000010005000111506148
37
+:10024000000000000000456E61626C652041555859
38
+:100250000000000000000001000411014501000041
39
+:10026000000000000041555820696E20757365003C
40
+:1002700000000000000002000411014560000000C1
41
+:100280000000000054756E657220696E20757365FC
42
+:10029000000000000003000411014561000000009F
43
+:1002A0000000005461706520696E20757365000060
44
+:1002B000000000000400041101456200000000007D
45
+:1002C0000000434420696E20757365000000000043
46
+:1002D00000000000000311014600000000000000C3
47
+:1002E000004E6F2064657669636520696E207573C2
48
+:1002F0006500000003110120000000000000000064
49
+:1003000050696E670000000000000000000000005F
50
+:10031000000700056031F1010100000000000054F9
51
+:10032000756E65722053746174757300000000006F
52
+:1003300005000A6231F10030010100000080456AC9
53
+:1003400065637420434400000000000000000006C4
54
+:10035000000A6231F100F80101000000804E6F20B8
55
+:1003600043440000000000000000000000000800FE
56
+:10037000047431F1900000000000000041756469D0
57
+:100380006F2053746174757300000000000900034E
58
+:1003900000010A00000000000000004C414E205304
59
+:1003A0007461747573000000000000000A000311FE
60
+:1003B000010000000000000000004C414E2052658A
61
+:1003C00067697374657200000000000B000311017F
62
+:1003D0000100000000000000004C414E20526573F7
63
+:1003E000746172740000000000000C000311012011
64
+:1003F00000000000000000004C414E20436865638F
65
+:100400006B00000000000000000000000000000081
66
+:1004100000000000000000000000000000000000DC
67
+:10042000000000000000000011241FBECFEFD8E044
68
+:10043000DEBFCDBF11E0A0E0B1E0E0E0F0E102C03E
69
+:1004400005900D92AC3FB107D9F723E0ACEFB1E0D6
70
+:1004500001C01D92AA35B207E1F70E9447020C9431
71
+:10046000FE070C940000259A2D9A82E085BD0E941B
72
+:1004700077025B9A5A982FE088E190E00FB6F894E3
73
+:10048000A895809360000FBE2093600008950E949D
74
+:10049000330282E990E00E94A60288E690E00E9482
75
+:1004A000A60280E091E09F938F938CE091E09F9370
76
+:1004B0008F9381E191E09F938F938CEF91E09F93D5
77
+:1004C0008F930E942D058CEF91E00E949A028DB7C8
78
+:1004D0009EB708960FB6F8949EBF0FBE8DBFA89525
79
+:1004E0000E9415040097D9F30E941303F8CFE1ECA2
80
+:1004F000F0E010821092C00086E88093C20087E688
81
+:100500008093C400589A88E1808308958091C00048
82
+:10051000881F8827881F08958091C00087FFFCCF1F
83
+:100520008091C60008959091C00095FFFCCF809304
84
+:10053000C6000895CF93DF93EC018991882319F0C9
85
+:100540000E949302FACFDF91CF910895CF93DF936A
86
+:10055000FC018491EF012196882321F00E949302EF
87
+:10056000FE01F7CFDF91CF9108959C01225F3F4FAD
88
+:100570003093590320935803FC01249141E0211149
89
+:1005800001C040E04093570320E633E03093560328
90
+:1005900020935503411103C02FEF31E002C020E941
91
+:1005A00031E03093540320935303FC01329644917D
92
+:1005B00040935103319620E532E0D9015A2F521B66
93
+:1005C000541720F454915D933196F8CF0895282F55
94
+:1005D0001092500380E090E041E02150A8F0880F95
95
+:1005E000991F00B605FC02C0A895FBCF16BC00B64B
96
+:1005F00005FCFDCF36B5343380F781603091500370
97
+:10060000342730935003E9CF089516BC8AB18C602B
98
+:100610008AB986B58034E8F38AB1837F8AB986B512
99
+:100620008A34E8F30895853091054CF482309105C1
100
+:100630004CF40197A1F581E080934F0234C00597F7
101
+:1006400041F02DC090934E0280934D0210924F02C4
102
+:100650002AC080914D0290914E02049721F1809121
103
+:100660004F02882339F089E192E00E94B50210928E
104
+:100670004F0207C088E392E00E94B50281E08093B8
105
+:100680004F0216BC00B605FCFCCF86B58B34D0F308
106
+:100690002D9816BC8AB18C608AB986B5FECF81E0F0
107
+:1006A00091E00E94A60280E0089581E080935703C4
108
+:1006B00080E693E0909356038093550380E991E0A0
109
+:1006C00090935403809353038FE0809352038AE006
110
+:1006D00090E00E94130381E00895FF920F931F930F
111
+:1006E000CF93DF93882319F088EE90E002C08FEC5F
112
+:1006F00090E00E94A6028BEB90E00E94A6028091FF
113
+:100700005803909159030E94A60288EB90E00E9442
114
+:10071000A602809157031F928F938CE291E09F93E2
115
+:100720008F93CCEFD1E0DF93CF930E942D05CE01C4
116
+:100730000E949A02809156038F93809155038F9364
117
+:1007400085E491E09F938F93DF93CF930E942D05D3
118
+:10075000CE010E949A02809154038F93809153039B
119
+:100760008F9380E691E09F938F93DF93CF930E94C6
120
+:100770002D05CE010E949A02809152031F928F9301
121
+:100780008BE791E09F938F93DF93CF930E942D058A
122
+:10079000CE010E949A02809151031F928F9386E9A5
123
+:1007A00091E09F938F93DF93CF930E942D05CE010D
124
+:1007B0000E949A026FEA71E0CE010E942605CE01E6
125
+:1007C0000E949A028DB79EB74E960FB6F8949EBFC0
126
+:1007D0000FBE8DBFF12CC3ECD1E00CEF11E0809186
127
+:1007E0005103F816C8F4EF2DF0E0E05BFD4F808177
128
+:1007F0001F928F93DF93CF931F930F930E942D052A
129
+:100800008CEF91E00E949A02F3940F900F900F905A
130
+:100810000F900F900F90E3CF87EC91E0DF91CF9195
131
+:100820001F910F91FF900C949A02AF92BF92CF92BA
132
+:10083000DF92EF92FF920F931F93CF93DF9381E0AC
133
+:100840000E94E7022D9881E00E94E70221E0892BB7
134
+:1008500009F420E0209357038CE00E94E702909374
135
+:10086000560380935503C0915003D0E081E00E946D
136
+:10087000E702C817D90719F089EE91E04AC08CE069
137
+:100880000E94E702EC01909354038093530300917C
138
+:10089000500310E081E00E94E7020817190719F0E1
139
+:1008A0008AEB91E036C0BB24B394C036D34029F024
140
+:1008B000B12C81E00E94E70202C00E94050384E09F
141
+:1008C0000E94E70280935203C0915003D0E081E080
142
+:1008D0000E94E702C817D90719F080E991E019C012
143
+:1008E000BB2019F00E94050303C081E00E94E702CB
144
+:1008F00088E00E94E702A82E80935103C091500324
145
+:10090000D0E081E00E94E702C817D90729F085E608
146
+:1009100091E00E94A6023CC0BB2019F00E94050392
147
+:1009200003C081E00E94E70240E5E42E42E0F42E9D
148
+:10093000E70104C0BB2079F10E9405038C2F8E19BA
149
+:100940008A1568F58E010055124088E00E94E70282
150
+:100950008993C0905003D12C81E00E94E702C81611
151
+:10096000D90641F31F930F9381ED91E09F938F93ED
152
+:100970008CEF91E09F938F930E942D058CEF91E077
153
+:100980000E949A020F900F900F900F900F900F906F
154
+:10099000C0E0D0E04FC081E00E94E702CFCFBB2093
155
+:1009A00021F08BE391E00E94A6028AE291E090930D
156
+:1009B00059038093580329E532E080E090E0BFE1DD
157
+:1009C000A0E0B89FB001B99F700D1124F9014491C6
158
+:1009D000A417E8F44A2F50E0FA01E60FF71FE65A91
159
+:1009E000FD4FE491EA01C05BDD4F48814E1302C028
160
+:1009F000AF5FECCF0196215E3F4F8F30910501F73D
161
+:100A0000C0E0D0E080E00E946D032D9A13C02FE17A
162
+:100A1000289FF001299FF00D1124CF018B599D4F84
163
+:100A20009093590380935803E95AFD4FE491CE2FD8
164
+:100A3000D0E0E8CFCE01DF91CF911F910F91FF90D1
165
+:100A4000EF90DF90CF90BF90AF900895FB01DC0155
166
+:100A500001900D920020E1F70895AEE0B0E0E3E3ED
167
+:100A6000F5E00C94D5070D891E8986E08C831A83E6
168
+:100A700009838FEF9FE79E838D83AE01475E5F4FB3
169
+:100A80006F89788DCE0101960E944F05EF81F88520
170
+:100A9000E00FF11F10822E96E4E00C94F107ACE019
171
+:100AA000B0E0E5E5F5E00C94C7077C016B018A0135
172
+:100AB000FC0117821682838181FFBDC1CE010196A0
173
+:100AC0004C01F7019381F60193FD859193FF81918C
174
+:100AD0006F01882309F4ABC1853239F493FD859108
175
+:100AE00093FF81916F01853229F4B70190E00E9454
176
+:100AF0003707E7CF512C312C20E02032A0F48B3285
177
+:100B000069F030F4803259F0833269F420612CC0EE
178
+:100B10008D3239F0803339F4216026C022602460A0
179
+:100B200023C0286021C027FD27C030ED380F3A30A0
180
+:100B300078F426FF06C0FAE05F9E300D1124532E94
181
+:100B400013C08AE0389E300D1124332E20620CC071
182
+:100B50008E3221F426FD6BC1206406C08C3611F460
183
+:100B6000206802C0883641F4F60193FD859193FF19
184
+:100B700081916F018111C1CF982F9F7D9554933042
185
+:100B800028F40C5F1F4FFFE3F9830DC0833631F06B
186
+:100B9000833771F0833509F05BC022C0F801808192
187
+:100BA00089830E5F1F4F44244394512C540115C078
188
+:100BB0003801F2E06F0E711CF801A080B18026FFB1
189
+:100BC00003C0652D70E002C06FEF7FEFC5012C8779
190
+:100BD0000E942C072C0183012C852F77222E17C011
191
+:100BE0003801F2E06F0E711CF801A080B18026FF81
192
+:100BF00003C0652D70E002C06FEF7FEFC5012C8749
193
+:100C00000E9421072C012C852068222E830123FCC1
194
+:100C10001BC0832D90E048165906B0F4B70180E25E
195
+:100C200090E00E9437073A94F4CFF50127FC8591B4
196
+:100C300027FE81915F01B70190E00E9437073110D4
197
+:100C40003A94F1E04F1A51084114510471F7E5C08C
198
+:100C5000843611F0893639F5F80127FF07C0608125
199
+:100C60007181828193810C5F1F4F08C06081718107
200
+:100C7000882777FD8095982F0E5F1F4F2F76B22E15
201
+:100C800097FF09C090958095709561957F4F8F4F24
202
+:100C90009F4F2068B22E2AE030E0A4010E9469072D
203
+:100CA000A82EA81844C0853729F42F7EB22E2AE03A
204
+:100CB00030E025C0F22FF97FBF2E8F36C1F018F437
205
+:100CC000883579F0B4C0803719F0883721F0AFC08B
206
+:100CD0002F2F2061B22EB4FE0DC08B2D8460B82E54
207
+:100CE00009C024FF0AC09F2F9660B92E06C028E0D5
208
+:100CF00030E005C020E130E002C020E132E0F80140
209
+:100D0000B7FE07C060817181828193810C5F1F4FA4
210
+:100D100006C06081718180E090E00E5F1F4FA401EA
211
+:100D20000E946907A82EA818FB2DFF77BF2EB6FEDC
212
+:100D30000BC02B2D2E7FA51450F4B4FE0AC0B2FCBC
213
+:100D400008C02B2D2E7E05C07A2C2B2D03C07A2CAB
214
+:100D500001C0752C24FF0DC0FE01EA0DF11D80813C
215
+:100D6000803311F4297E09C022FF06C07394739466
216
+:100D700004C0822F867809F0739423FD13C020FFEE
217
+:100D800006C05A2C731418F4530C5718732C731490
218
+:100D900068F4B70180E290E02C870E9437077394D3
219
+:100DA0002C85F5CF731410F4371801C0312C24FFB3
220
+:100DB00012C0B70180E390E02C870E9437072C8592
221
+:100DC00022FF17C021FF03C088E590E002C088E73A
222
+:100DD00090E0B7010CC0822F867859F021FD02C047
223
+:100DE00080E201C08BE227FD8DE2B70190E00E9416
224
+:100DF0003707A51438F4B70180E390E00E94370765
225
+:100E00005A94F7CFAA94F401EA0DF11D8081B7013D
226
+:100E100090E00E943707A110F5CF332009F451CE9E
227
+:100E2000B70180E290E00E9437073A94F6CFF701CD
228
+:100E30008681978102C08FEF9FEF2C96E2E10C94A0
229
+:100E4000E307FC010590615070400110D8F78095D0
230
+:100E500090958E0F9F1F0895FC0161507040019086
231
+:100E60000110D8F7809590958E0F9F1F08950F93CE
232
+:100E70001F93CF93DF93182F092FEB018B8181FDF7
233
+:100E800003C08FEF9FEF20C082FF10C04E815F81B3
234
+:100E90002C813D81421753077CF4E881F9819F0141
235
+:100EA0002F5F3F4F39832883108306C0E885F9857B
236
+:100EB000812F0995892B29F72E813F812F5F3F4F85
237
+:100EC0003F832E83812F902FDF91CF911F910F9120
238
+:100ED0000895FA01AA27283051F1203181F1E894D0
239
+:100EE0006F936E7F6E5F7F4F8F4F9F4FAF4FB1E01D
240
+:100EF0003ED0B4E03CD0670F781F891F9A1FA11D18
241
+:100F0000680F791F8A1F911DA11D6A0F711D811D18
242
+:100F1000911DA11D20D009F468943F912AE0269FDD
243
+:100F200011243019305D3193DEF6CF010895462F3C
244
+:100F30004770405D4193B3E00FD0C9F7F6CF462F1D
245
+:100F40004F70405D4A3318F0495D31FD4052419386
246
+:100F500002D0A9F7EACFB4E0A69597958795779543
247
+:100F60006795BA95C9F700976105710508959B01CA
248
+:100F7000AC010A2E06945795479537952795BA9553
249
+:100F8000C9F7620F731F841F951FA01D08952F922C
250
+:100F90003F924F925F926F927F928F929F92AF9209
251
+:100FA000BF92CF92DF92EF92FF920F931F93CF9356
252
+:100FB000DF93CDB7DEB7CA1BDB0B0FB6F894DEBFED
253
+:100FC0000FBECDBF09942A88398848885F846E8413
254
+:100FD0007D848C849B84AA84B984C884DF80EE805D
255
+:100FE000FD800C811B81AA81B981CE0FD11D0FB666
256
+:100FF000F894DEBF0FBECDBFED010895F894FFCF8A
257
+:101000004A756C20313820323031350076312E303F
258
+:1010100000090920202020204669726D77617265E1
259
+:101020002025732C2025730D0A0D0A002020204254
260
+:10103000726F6164636173743A2020202020202540
261
+:1010400064200D0A002020204D61737465722061B8
262
+:101050006464726573733A2030782558200D0A0055
263
+:10106000202020536C61766520616464726573731F
264
+:101070003A202030782558200D0A00202020436F88
265
+:101080006E74726F6C3A202020202020202030784F
266
+:101090002558200D0A0020202044617461207369C6
267
+:1010A0007A653A2020202020202564200D0A002087
268
+:1010B0002020446174613A2020202020202020201C
269
+:1010C000202000255820000D0A2D2D2D2D2D0D0A34
270
+:1010D00000417663526561644D6573736167653A7B
271
+:1010E00020506172697479206572726F722040209D
272
+:0C10F000446174615B25645D0D0A000022
273
+:00000001FF

BIN
ToyotaAuxEnabler.o View File


+ 144
- 0
USART.c View File

@@ -0,0 +1,144 @@
1
+/*--------------------------------------------------------------------------------------------------
2
+
3
+  Name         :  USART.c
4
+
5
+  Description  :  Utility functions for ATmega8 USART.
6
+
7
+  Author       :  2004-10-22 - Louis Frigon
8
+
9
+  History      :  2004-10-22 - First release (v0.1).
10
+
11
+--------------------------------------------------------------------------------------------------*/
12
+#include <avr/io.h>
13
+#include <avr/interrupt.h>
14
+#include <avr/pgmspace.h>
15
+#include <stdio.h>
16
+
17
+#include "USART.h"
18
+
19
+/*--------------------------------------------------------------------------------------------------
20
+
21
+  Name         :  InitUSART
22
+
23
+  Description  :  Performs USART initialization: 9600,N,8,1.
24
+
25
+  Argument(s)  :  None.
26
+
27
+  Return value :  None.
28
+
29
+--------------------------------------------------------------------------------------------------*/
30
+void InitUSART ( void )
31
+{
32
+    //  Disable USART while setting baud rate.
33
+    UCSR0B = 0x00;
34
+    UCSR0A = 0x00;
35
+
36
+    //  8 data bit, 1 stop, no parity.
37
+    UCSR0C = _BV(EEAR7) | _BV(UCSZ01) | _BV(UCSZ00);
38
+
39
+    //  Set USART baud rate @ 9600. Divider is 103 @ 16 MHz.
40
+    UBRR0L = 103;
41
+
42
+    //  Enable internal pull-up on Rx pin.
43
+    PORTD |= _BV(PD0);
44
+
45
+    //  Enable Tx & Rx.
46
+    UCSR0B = _BV(RXEN0) | _BV(TXEN0);
47
+}
48
+
49
+/*--------------------------------------------------------------------------------------------------
50
+
51
+  Name         :  UsartIsChr
52
+
53
+  Description  :  Return status of USART Rx buffer.
54
+
55
+  Argument(s)  :  None.
56
+
57
+  Return value :  0 if Rx buffer empty.
58
+
59
+--------------------------------------------------------------------------------------------------*/
60
+bool UsartIsChr ( void )
61
+{
62
+    return UCSR0A & _BV(RXC0);
63
+}
64
+
65
+/*--------------------------------------------------------------------------------------------------
66
+
67
+  Name         :  UsartGetChr
68
+
69
+  Description  :  Return character USART Rx buffer. Blocking until Rx buffer not empty.
70
+
71
+  Argument(s)  :  None.
72
+
73
+  Return value :  Character in Rx buffer.
74
+
75
+--------------------------------------------------------------------------------------------------*/
76
+char UsartGetChr ( void )
77
+{
78
+    while ( !UsartIsChr() );
79
+
80
+    return UDR0;
81
+}
82
+
83
+/*--------------------------------------------------------------------------------------------------
84
+
85
+  Name         :  UsartPutChr
86
+
87
+  Description  :  Send a character through the USART.
88
+
89
+  Argument(s)  :  c -> char to send.
90
+
91
+  Return value :  None.
92
+
93
+--------------------------------------------------------------------------------------------------*/
94
+void UsartPutChr ( char c )
95
+{
96
+    //  Wait for transmit register to be empty.
97
+    while ( !(UCSR0A & _BV(UDRE0)) );
98
+
99
+    UDR0 = c;
100
+}
101
+
102
+/*--------------------------------------------------------------------------------------------------
103
+
104
+  Name         :  UsartPutStr
105
+
106
+  Description  :  Transmit a string on the serial port.
107
+
108
+  Argument(s)  :  str -> pointer to string to send.
109
+
110
+  Return value :  None.
111
+
112
+--------------------------------------------------------------------------------------------------*/
113
+void UsartPutStr ( char *str )
114
+{
115
+    while ( *str )
116
+    {
117
+        UsartPutChr( *str++ );
118
+    }
119
+}
120
+
121
+/*--------------------------------------------------------------------------------------------------
122
+
123
+  Name         :  UsartPutCStr
124
+
125
+  Description  :  Transmit a string on the serial port.
126
+
127
+  Argument(s)  :  str -> pointer to constant string to send (strings in Flash).
128
+
129
+  Return value :  None.
130
+
131
+--------------------------------------------------------------------------------------------------*/
132
+void UsartPutCStr ( const char *str )
133
+{
134
+    char c;
135
+
136
+    while ( (c = pgm_read_byte_near( str++ )) )
137
+    {
138
+        UsartPutChr( c );
139
+    }
140
+}
141
+
142
+/*--------------------------------------------------------------------------------------------------
143
+                                         End of file.
144
+--------------------------------------------------------------------------------------------------*/

+ 37
- 0
USART.h View File

@@ -0,0 +1,37 @@
1
+/*--------------------------------------------------------------------------------------------------
2
+
3
+  Name         :  USART.h
4
+
5
+  Description  :  Header file for USART functions.
6
+
7
+  History      :  2004-10-22 - Created by Louis Frigon.
8
+
9
+--------------------------------------------------------------------------------------------------*/
10
+#ifndef _USART_H_
11
+#define _USART_H_
12
+
13
+#include <avr/pgmspace.h>
14
+
15
+#include "GlobalDef.h"
16
+
17
+#define USART_BUFFER_SIZE       80
18
+
19
+extern char          UsartMsgBuffer[ USART_BUFFER_SIZE ];
20
+
21
+/*--------------------------------------------------------------------------------------------------
22
+                                    Function prototypes
23
+--------------------------------------------------------------------------------------------------*/
24
+//  Function prototypes are mandatory otherwise the compiler generates unreliable code.
25
+
26
+void InitUSART               ( void );
27
+bool UsartIsChr              ( void );
28
+char UsartGetChr             ( void );
29
+void UsartPutChr             ( char c );
30
+void UsartPutStr             ( char *str );
31
+void UsartPutCStr            ( const char *str );
32
+
33
+
34
+#endif   //  _USART_H_
35
+/*--------------------------------------------------------------------------------------------------
36
+                                         End of file.
37
+--------------------------------------------------------------------------------------------------*/

BIN
USART.o View File


+ 2990
- 0
log.txt
File diff suppressed because it is too large
View File


+ 1578
- 0
screenlog.0
File diff suppressed because it is too large
View File