Difference between revisions of "6272 Embedded Controller I/Oktober 2016"
From Teknologisk videncenter
m |
m (→Opgaver) |
||
Line 13: | Line 13: | ||
=Opgaver= | =Opgaver= | ||
[[MSP430/MSP430G2 Serial 1 project]] | [[MSP430/MSP430G2 Serial 1 project]] | ||
+ | |||
+ | == Få stdio bibliotek til at virke == | ||
+ | ===UART_poll.c=== | ||
+ | Indsæt følgende nederst i UART_poll.c | ||
+ | <source lang=c> | ||
+ | int putchar( int charout ) { | ||
+ | cout( (char) charout ); | ||
+ | return(charout); | ||
+ | } | ||
+ | |||
+ | int getchar( void ) { | ||
+ | int charin; | ||
+ | charin = (int) cin(); | ||
+ | if ( (charin == 0x0d ) || (charin == 0x0a) ) { // CR or LF | ||
+ | putchar( 0x0d ); // Output CR+LF | ||
+ | putchar( 0x0a ); | ||
+ | return( 0x0a ); // Return LF | ||
+ | } else { // Else other character | ||
+ | putchar( charin ); | ||
+ | return( charin ); | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | ===UART_poll.h=== | ||
+ | Indsæt følgende linier nederst i UART_poll.h | ||
+ | <source lang=c> | ||
+ | extern int putchar( int charout ); | ||
+ | extern int getchar( void ); | ||
+ | </source> | ||
+ | ===Main.c=== | ||
+ | Indsæt følgende include sætning øverst i main.c | ||
+ | <source lang=c> | ||
+ | #include <stdio.h> | ||
+ | </source> | ||
+ | |||
[[Category:Embedded]] | [[Category:Embedded]] |
Revision as of 12:59, 10 October 2016
Contents
C
- ctutor.pdf
- C programming (Local articles)
- Const and volatile type qualifiers
- ASC-II tegnsættet
MSP430
- MSP430
- MSP430 Introduktion (Loads PDF)
Opgaver
MSP430/MSP430G2 Serial 1 project
Få stdio bibliotek til at virke
UART_poll.c
Indsæt følgende nederst i UART_poll.c
int putchar( int charout ) {
cout( (char) charout );
return(charout);
}
int getchar( void ) {
int charin;
charin = (int) cin();
if ( (charin == 0x0d ) || (charin == 0x0a) ) { // CR or LF
putchar( 0x0d ); // Output CR+LF
putchar( 0x0a );
return( 0x0a ); // Return LF
} else { // Else other character
putchar( charin );
return( charin );
}
}
UART_poll.h
Indsæt følgende linier nederst i UART_poll.h
extern int putchar( int charout );
extern int getchar( void );
Main.c
Indsæt følgende include sætning øverst i main.c
#include <stdio.h>