Hi, ich habe mir eine Software Uart Lib für AVRs im Inet runtergeladen. Verstehe aber nicht wie ich dies Sendefunktion genau aufrufen muss. Was machst dieses FILE* stream? Und was muss ich als Argument dafür übergeben? Hoffe ihr könnt mir weiterhelfen. int putChar( char c, FILE* stream ) { if ( c == '\n' ) putChar( '\r', stream ); // Don't send while busy receiving or // transmitting. while ( ( state != IDLE ) #ifndef TX_ONLY && ( state != DATA_PENDING ) #endif ); #ifndef TX_ONLY DISABLE_EXTERNAL0_INTERRUPT( ); // Disable reception. #endif // ifndef TX_ONLY state = TRANSMIT; SwUartTXData = c; // Put byte into TX buffer. SwUartTXBitCount = 0; TCCR_P &= ~CLOCK_SELECT_MASK; // Reset prescaler counter. TCNT0 = 0; // Clear counter register. TCCR_P |= CLOCK_SELECT; // CTC mode. Start prescaler clock. OCR = TICKS2WAITONE - 1; // Set compare value to one bit period CLEAR_TIMER_INTERRUPT( ); // Clear interrupt bits CLEAR_TX_PIN( ); // Clear TX line...start of preamble ENABLE_TIMER_INTERRUPT( ); // Enable interrupt return 0; } // end putChar #endif // ifndef RX_ONLY
Gast
#4853700
Johannes M. schrieb: > Was machst dieses FILE* stream? Und was muss ich als Argument dafür > übergeben? Bei mir ist mit Google alles ok ... z.B. https://www.gnu.org/software/libc/manual/html_node/I_002fO-on-Streams.html
Hi hier etwas zum Nachlesen: https://www.mikrocontroller.net/articles/Kategorie:UART_und_RS232 Das sind Grundlagen bzgl. AVR & U(S)ART. s.a. https://www.mikrocontroller.net/articles/AVR-GCC-Tutorial/Der_UART Dein Code wäre besser lesbar:
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
FILE* stream << FileDescriptor als Output-Stream s: http://www.cprogramming.com/tutorial/cfileio.html mfg Olaf
Antwort schreiben
Bitte melde dich an, um einen Beitrag zu schreiben.