ZZottel hat folgendes geschrieben: |
@W201:
Ohne das "Navi plus" wirst du keine Navipfeile im FIS mehr haben, weil dein CarPC vermutlich weder 3-Leiter-Bus noch CAN-Bus hat. |
ZZottel hat folgendes geschrieben: |
@W201:
Ich hatte dich so verstanden, dass du das "Navi plus" durch einen CarPC ersetzen willst. Bisher sendet das "Navi plus" die Abbiegepfeile an das FIS-Display. |
Code: |
/* * Program: avr_to_fis * Target: ATMega32 @ 11.0592 MHz * IDE: WinAVR-20100110 * Compiler: avr-gcc (WinAVR 20100110) 4.3.3 * Author: Stefan Bieger * Website: www.fis-control.de * Date: 2015-07-26 */ #include <avr> #include <avr> #include <avr> #include <util> #include <string> #define CLK 0x20 // Portd.5 #define DAT 0x10 // Portd.4 #define ENA 0x08 // Portd.3 char string[17] = {0}; uint8_t update = 0; void init_gpio(void) { PORTD = CLK | DAT; DDRD = CLK | DAT | ENA; // ENA is really unidirectional in radio mode (not like the 3LB for nav) } void init_timer(void) { TCCR1B = (1<<WGM01) | (1<<CS10); // CTC mode, no prescaler TIMSK = (1<<OCIE1A); // enable CTC interrupt OCR1A = 0xFFFF; // initialize to some value } uint8_t calc_checksum(const uint8_t* const data) { uint8_t i; uint8_t checksum = 0xFF; for (i=0; i<17; i++) { checksum -= data[i]; } return (checksum); } void write_to_fis(const char* const text) { update = 0; strncpy(string, text, 16); update = 1; } int main(void) { wdt_disable(); init_gpio(); init_timer(); sei(); while (1) { write_to_fis("12345678ABCDEFGH"); _delay_ms(1000); write_to_fis("HALLO WELT"); _delay_ms(1000); } } ISR(TIMER1_COMPA_vect) { static uint8_t state = 0; static uint8_t byte = 0; static uint8_t bit = 0; static uint8_t array[18] = {0}; switch (state) { case 0: if (update) { update = 0; array[0] = 0xF0; memset(&array[1], 0x20, 16); // fill with blanks memcpy(&array[1], string, strlen(string)); array[17] = calc_checksum(array); } if (array[0] == 0xF0) { PORTD = CLK | DAT | ENA; // ENA high TCCR1B = (1<<WGM01) | (1<<CS10); // CTC mode, no prescaler OCR1A = 1106 - 1; // next interrupt in 100 us byte = 0; bit = 7; state = 1; } break; case 1: PORTD &= ~ENA; // ENA low state = 2; break; case 2: PORTD |= ENA; OCR1A = 553 - 1; // next interrupt in 50 us state = 3; break; case 3: if (array[byte] & (1<<bit)) { PORTD &= ~DAT; } else { PORTD |= DAT; } OCR1A = 365 - 1; // next interrupt in 33 us state = 4; break; case 4: PORTD &= ~CLK; OCR1A = 730 - 1; // next interrupt in 66 us state = 5; break; case 5: PORTD |= CLK; OCR1A = 365 - 1; // next interrupt in 33 us if (bit) { bit--; state = 3; } else if (byte < 17) { bit = 7; byte++; state = 3; } else { state = 6; } break; case 6: PORTD |= DAT; OCR1A = 166 - 1; // next interrupt in 15 us state = 7; break; case 7: PORTD &= ~ENA; // ENA low TCCR1B = (1<<WGM01) | (1<<CS12); // CTC mode, prescaler 256 OCR1A = 21600 - 1; // next interrupt in 500 ms state = 0; break; } } |