int main( void ) { char name[80]; int age = 0; // initalise UART uart_init( UART_BAUD_RATE ); // enable UART as stdio uart_stdio_init( ); // enable echo on the UART stdin so the user can see what they are typing uart_stdio_echo( true ); while ( 1 ) { printf( "\r\n\r\nHello there, I'm a Penguino AVR!\r\n\r\n" ); printf( "What's your name? " ); scanf( "%s", name ); // sorry for the format vulnerability! example only printf( "\r\n\r\n" ); printf( "Why hello, %s! How old are you? ", name ); scanf( "%d", &age ); printf( "\r\n\r\n" ); printf( "Thanks, %s, for telling me you're %d years old!\r\n\r\n", name, age ); // snooze delay_ms( 300 ); } return 0; }
void board_init(void) { msp430_cpu_init(); msb_ports_init(); msp430_set_cpu_speed(MCLK_8MHZ_SCLK_8MHZ); /* initialize STDIO over UART */ uart_stdio_init(); }
void atmega_stdio_init(void) { uart_stdio_init(); stdout = &_uart_stdout; stdin = &_uart_stdin; /* Flush stdout */ puts("\f"); }
void board_init(void) { msp430_cpu_init(); msb_ports_init(); LED_RED_ON; msp430_set_cpu_speed(MCLK_8MHZ_SCLK_8MHZ); /* initialize the STDIO */ uart_stdio_init(); }
int main( void ) { statusLed_init( ); // flash status LED for a bit statusLed_orange( ); delay_ms( 500 ); statusLed_green( ); // initalise UART uart_init( UART_BAUD_RATE ); // enable UART as stdio uart_stdio_init( ); // enable echo on the UART stdin so the user can see what they are typing uart_stdio_echo( true ); // initialise by reading once from each LED /*readLed( 0 ); readLed( 1 ); readLed( 2 );*/ //readLed( 3 ); readLeds( ); readLeds( ); uint32_t bases[8]; for ( int i = 0; i < 8; i++ ) { bases[i] = clocks[i] >> 1; } while ( 1 ) { // main loop of the programmer /*if ( uart_hasData( ) ) { unsigned char cmd = uart_getc( ); if ( cmd >= '1' && cmd <= '4' ) { printf( "LED %c value: %d\r\n", cmd, readLed( cmd - '1' ) ); } }*/ if ( uart_hasData( ) ) { unsigned char cmd = uart_getc( ); readLeds( ); fwrite( clocks, sizeof(uint32_t), 8, stdout ); } /* int i; for ( i = 0; i < 8; i++ ) { printf( "%d: ", i ); displayBargraph( (clocks[i] - bases[i]) >> 8 ); printf( "\r\n" ); delay_ms( 10 ); } delay_ms( 100 );*/ } return 0; }
/** * @brief Initialize NewLib, called by __libc_init_array() from the startup script */ void _init(void) { uart_stdio_init(); }