6272 Embedded Controller I/Oktober 2016

From Teknologisk videncenter
< 6272 Embedded Controller I
Revision as of 12:59, 10 October 2016 by Heth (talk | contribs) (Opgaver)
Jump to: navigation, search

C

MSP430

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>