示例#1
0
int main(void) {
    unsigned char data = 0x00;
    unsigned short addr = 0x00;

    init_sys();
    init_uart();
    init_am27c();
    wait_for_sequence(seq, seq_len);

    for (;;) {
        addr = get_short();
        data = am27c_get_data(addr);
        UARTCharPut(UART0_BASE, data);
    }
}
示例#2
0
int main()
{
	int i = 0;

	init_uart();

	printf("\r\n\r\n#############irq_vectaddr test#############\r\n");
	while (1)
	{
		printf("%d\r\n",i++);
		delay();
	}

	return 0;
}
示例#3
0
void
init_platform()
{
    /*
     * If you want to run this example outside of SDK,
     * uncomment one of the following two lines and also #include "ps7_init.h"
     * or #include "ps7_init.h" at the top, depending on the target.
     * Make sure that the ps7/psu_init.c and ps7/psu_init.h files are included
     * along with this example source files for compilation.
     */
    /* ps7_init();*/
    /* psu_init();*/
    enable_caches();
    init_uart();
}
示例#4
0
int main (void)
{
	unsigned char AP;	
	unsigned char i = 0,bit;
	flag = RX;
	AP = 0;
//若为第一个节点则AP = 0,第二个节点AP = 1
	if (AP == 1)
	{
		for (i = 0; i< TX_ADR_WIDTH; i++)
		{
			TX_ADDRESS[i] = TX_AP0[i];
		}
	}
	init_uart (BAUD_SETTING);
	stdout = &mystdout;
	SPI_Init ();
	for (i = 0; i < 32; i++)
	{
		tx_buf[i] = 0xff;
	}
	while (1)
	{
		if (flag==RX)
		{
			bit = nrf_rx (TX_ADDRESS);
			if (bit)
			{
				printf ("the data are: \n");
				for (i = 0; i < 32; i++)
				{
					printf ("%4d", rx_buf[i]);
					rx_buf[i] = '\0';
					if ((i+1) % 10 == 0)
					printf ("\n");
				}
				printf ("\n");
			}
			else 
				printf ("the data error\n");
		}
		else
		{
			nrf_tx (TX_ADDRESS);
		}
		_delay_ms (1000);
	}
}
示例#5
0
int main(void)
{
	char str[256];
	init_adc();
	init_uart(&uartD0, &USARTD0, F_CPU, D0_BAUD, D0_CLK2X);
	PMIC.CTRL = PMIC_LOLVLEN_bm;
	sei();
	
	while(1)
	{
		uint16_t ch0_value = ADCA.CH0.RES;	
		sprintf(str, "%d\r\n", ch0_value);
		uart_puts(&uartD0, str);
		_delay_ms(50);
	}
}
示例#6
0
文件: main.c 项目: kehribar/xmegaE5
int main()
{
	uint32_t pc = 0;
	initClock_32Mhz();
	init_dac();	
	init_uart();

	while(1)
	{
		pc += increment;

		DACA.CH0DATAH = lut[pc >> 24];

		while(!(DACA.STATUS & (DAC_CH1DRE_bm)));
	}
}
示例#7
0
int main()
{
	int a, b;

	init_uart();
	
	while (1)
	{
		printf("please enter two number: \n\r");
		scanf("%d %d", &a, &b);
		printf("\n\r");
		printf("the sum of %d + %d is: %d\n\r", a, b, a+b);
	}
	
	return 0;
}
示例#8
0
文件: main.c 项目: youngvoice/start
int main()
{
    char c;
    GPIO_LedInit();


    init_uart();
    while(1)
    {
        LedTest();
        c = getchar();
        putchar(c+1);
    }

    return 0;
}
示例#9
0
int 
main (int argc, char **argv)
{
  if ((uart_fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY)) <0) {
	fprintf(stderr, "port /dev/ttyS1 could not be opened, error %d\n", errno);
	exit(1);
  }
	
  //set_bluetooth_power(1);

	init_uart();

	proc_reset();
	
	exit(0);
}
示例#10
0
void setup(void) {
    // Initialize PIC24 modules.
    init_clock();
    init_ui();
    init_timer();
    init_pin();
    init_oc();
    init_spi();
    init_uart();

    // Configure single SPI comms. system
    pin_digitalOut(SPI_CS);
    pin_set(SPI_CS);
    spi_open(spi_inst, SPI_MISO, SPI_MOSI, SPI_SCK, spi_freq, spi_mode);

    // Configure & start timers used.
    timer_setPeriod(&timer1, 1);
    timer_setPeriod(&timer2, 1);  // Timer for LED operation/status blink
    timer_setPeriod(&timer3, LOOP_TIME); // Timer for main control loop
    timer_start(&timer1);
    timer_start(&timer2);
    timer_start(&timer3);

    // Configure motor current conversion coefficient
    CURRENT_CONV_COEF = MAX_ADC_OUTPUT * MOTOR_VOLTAGE_RESISTOR;
    cur_control.Kp = KP;
    cur_control.Kd = KD;
    cur_control.Ki = KI;
    cur_control.dt = LOOP_TIME;
    cur_control.integ_min = -100;
    cur_control.integ_max = 100;
    cur_control.integ_state = 0;
    read_motor_current(&motor);
    cur_control.prev_position = convert_motor_torque(motor.current);
    // Configure dual PWM signals for bidirectional motor control
    oc_pwm(&oc1, PWM_I1, NULL, pwm_freq, pwm_duty);
    oc_pwm(&oc2, PWM_I2, NULL, pwm_freq, pwm_duty);
    pin_analogIn(MOTOR_VOLTAGE);
    pin_digitalOut(DEBUGD0);
    pin_digitalOut(DEBUGD1);

    InitUSB();                              // initialize the USB registers and
                                            // serial interface engine
    while (USB_USWSTAT != CONFIG_STATE) {   // while periph. is not configured,
        ServiceUSB();                       // service USB requests
    }
}
示例#11
0
文件: serial_api.c 项目: haydar9/mbed
void serial_init(serial_t *obj, PinName tx, PinName rx)
{
    // Determine the UART to use (UART_1, UART_2, ...)
    UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
    UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);

    // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object
    obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
    MBED_ASSERT(obj->uart != (UARTName)NC);

    // Enable USART clock
    if (obj->uart == UART_1) {
        __USART1_CLK_ENABLE();
        obj->index = 0;
    }
    if (obj->uart == UART_2) {
        __USART2_CLK_ENABLE();
        obj->index = 1;
    }
    if (obj->uart == UART_3) {
        __USART3_CLK_ENABLE();
        obj->index = 2;
    }

    // Configure the UART pins
    pinmap_pinout(tx, PinMap_UART_TX);
    pinmap_pinout(rx, PinMap_UART_RX);
    pin_mode(tx, PullUp);
    pin_mode(rx, PullUp);

    // Configure UART
    obj->baudrate = 9600;
    obj->databits = UART_WORDLENGTH_8B;
    obj->stopbits = UART_STOPBITS_1;
    obj->parity   = UART_PARITY_NONE;

    obj->pin_tx = tx;
    obj->pin_rx = rx;

    init_uart(obj);

    // For stdio management
    if (obj->uart == STDIO_UART) {
        stdio_uart_inited = 1;
        memcpy(&stdio_uart, obj, sizeof(serial_t));
    }
}
示例#12
0
/**
 * Set HW Control Flow
 * @param obj    The serial object
 * @param type   The Control Flow type (FlowControlNone, FlowControlRTS, FlowControlCTS, FlowControlRTSCTS)
 * @param rxflow Pin for the rxflow
 * @param txflow Pin for the txflow
 */
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
{
    struct serial_s *obj_s = SERIAL_S(obj);

    // Checked used UART name (UART_1, UART_2, ...)
    UARTName uart_rts = (UARTName)pinmap_peripheral(rxflow, PinMap_UART_RTS);
    UARTName uart_cts = (UARTName)pinmap_peripheral(txflow, PinMap_UART_CTS);
    if (((UARTName)pinmap_merge(uart_rts, obj_s->uart) == (UARTName)NC) || ((UARTName)pinmap_merge(uart_cts, obj_s->uart) == (UARTName)NC)) {
        MBED_ASSERT(0);
        return;
    }

    if (type == FlowControlNone) {
        // Disable hardware flow control
        obj_s->hw_flow_ctl = UART_HWCONTROL_NONE;
    }
    if (type == FlowControlRTS) {
        // Enable RTS
        MBED_ASSERT(uart_rts != (UARTName)NC);
        obj_s->hw_flow_ctl = UART_HWCONTROL_RTS;
        obj_s->pin_rts = rxflow;
        // Enable the pin for RTS function
        pinmap_pinout(rxflow, PinMap_UART_RTS);
    }
    if (type == FlowControlCTS) {
        // Enable CTS
        MBED_ASSERT(uart_cts != (UARTName)NC);
        obj_s->hw_flow_ctl = UART_HWCONTROL_CTS;
        obj_s->pin_cts = txflow;
        // Enable the pin for CTS function
        pinmap_pinout(txflow, PinMap_UART_CTS);
    }
    if (type == FlowControlRTSCTS) {
        // Enable CTS & RTS
        MBED_ASSERT(uart_rts != (UARTName)NC);
        MBED_ASSERT(uart_cts != (UARTName)NC);
        obj_s->hw_flow_ctl = UART_HWCONTROL_RTS_CTS;
        obj_s->pin_rts = rxflow;
        obj_s->pin_cts = txflow;
        // Enable the pin for CTS function
        pinmap_pinout(txflow, PinMap_UART_CTS);
        // Enable the pin for RTS function
        pinmap_pinout(rxflow, PinMap_UART_RTS);
    }

    init_uart(obj);
}
示例#13
0
int main(void)
{
	int c = 0;

	init_uart();
	
	// 初始化LCD控制器
	lcd_init();

	// 打印菜单
	while(1)
	{
		printf("\r\n###############lcd test##############\r\n");
		printf("[1] lcd_clear_screen\r\n");
		printf("[2] lcd_draw_cross\r\n");
		printf("[3] lcd_draw_hline\r\n");
		printf("[4] lcd_draw_vline\r\n");
		printf("[5] lcd_draw_circle\r\n");
		printf("Enter your choice:");
		c = getc();
		printf("%c\r\n",c);
		switch(c)
		{
		case '1':
			// 清屏
			lcd_clear_screen(0xFFFFFF);
			break;
		case '2':
			// 划十字
			lcd_draw_cross(50, 50, 20, 0x000000);
			break;
		case '3':
			// 划横线
			lcd_draw_hline(HEIGHT/2, 100, WIDTHEIGHT-100, 0xff0000);
			break;
		case '4':
			// 划竖线
			lcd_draw_vline(WIDTHEIGHT/2, 50, HEIGHT-50, 0xff0000);
			break;
		case '5':
			// 划圆
			lcd_draw_circle();
			break;
		}
	}
	return 0;
}
示例#14
0
/**
 * Set HW Control Flow
 * @param obj    The serial object
 * @param type   The Control Flow type (FlowControlNone, FlowControlRTS, FlowControlCTS, FlowControlRTSCTS)
 * @param rxflow Pin for the rxflow
 * @param txflow Pin for the txflow
 */
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
{
    struct serial_s *obj_s = SERIAL_S(obj);

    // Determine the UART to use (UART_1, UART_2, ...)
    UARTName uart_rts = (UARTName)pinmap_peripheral(rxflow, PinMap_UART_RTS);
    UARTName uart_cts = (UARTName)pinmap_peripheral(txflow, PinMap_UART_CTS);

    // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object
    obj_s->uart = (UARTName)pinmap_merge(uart_cts, uart_rts);
    MBED_ASSERT(obj_s->uart != (UARTName)NC);

    if(type == FlowControlNone) {
        // Disable hardware flow control
      obj_s->hw_flow_ctl = UART_HWCONTROL_NONE;
    }
    if (type == FlowControlRTS) {
        // Enable RTS
        MBED_ASSERT(uart_rts != (UARTName)NC);
        obj_s->hw_flow_ctl = UART_HWCONTROL_RTS;
        obj_s->pin_rts = rxflow;
        // Enable the pin for RTS function
        pinmap_pinout(rxflow, PinMap_UART_RTS);
    }
    if (type == FlowControlCTS) {
        // Enable CTS
        MBED_ASSERT(uart_cts != (UARTName)NC);
        obj_s->hw_flow_ctl = UART_HWCONTROL_CTS;
        obj_s->pin_cts = txflow;
        // Enable the pin for CTS function
        pinmap_pinout(txflow, PinMap_UART_CTS);
    }
    if (type == FlowControlRTSCTS) {
        // Enable CTS & RTS
        MBED_ASSERT(uart_rts != (UARTName)NC);
        MBED_ASSERT(uart_cts != (UARTName)NC);
        obj_s->hw_flow_ctl = UART_HWCONTROL_RTS_CTS;
        obj_s->pin_rts = rxflow;
        obj_s->pin_cts = txflow;
        // Enable the pin for CTS function
        pinmap_pinout(txflow, PinMap_UART_CTS);
        // Enable the pin for RTS function
        pinmap_pinout(rxflow, PinMap_UART_RTS);
    }
    
    init_uart(obj);
}
示例#15
0
int main()
{
	uint16_t Addr;
	uint8_t WriteBuffer[256]={0};
	uint8_t ReadBuffer[256]={0};
	init_uart();
	printf("\r\n****************************************************************\r\n");
	
	I2C_Configuration();
	
	for(Addr=0; Addr<256; Addr++){
		WriteBuffer[Addr]=Addr+100;	 /* 填充WriteBuffer */
	}

	//全部擦出,每个字节置0xff
	//I2C_Erase();
	//printf("Erase ok\r\n");
	
	/* 开始向EEPROM写数据 */
	printf("\r\n EEPROM 24C64 Write Test \r\n");
	
	for(Addr=0;Addr<sizeof(WriteBuffer);Addr++){
		printf("%d ",WriteBuffer[Addr]);
	}
	printf("\r\n");
	
	I2C_Write(I2C,ADDR_24L64,0x0,WriteBuffer,sizeof(WriteBuffer) );
	printf("\r\n EEPROM 24C64 Write Test OK \r\n");
	
	/* EEPROM读数据 */
	printf("\r\n EEPROM 24C64 Read Test \r\n");
	I2C_Read(I2C,ADDR_24L64,0x0,ReadBuffer,sizeof(ReadBuffer) );
	
	for(Addr=0;Addr<sizeof(ReadBuffer);Addr++){
		printf("%d ",ReadBuffer[Addr]);
	}
	printf("\r\n");
	
	if(strcmp((const char *)ReadBuffer,(const char *)WriteBuffer)==0){
		printf("\r\n EEPROM 24C64 Read Test ok \r\n");
	}

	while (1)
	{
	}
}
示例#16
0
int main()
{

	char helpstr[]=" \
------------------------------\r\n \
|                            |\r\n \
|      helloworld .v1.0      |\r\n \
|      'h'  --> 'hello'      |\r\n \
|      'w'  --> 'world'      |\r\n \
|                            |\r\n \
------------------------------\r\n" ;
	
	uint8_t cmdchar;  /* 按键代码 */ 
	
	init_uart();   /* 串口初始化 */ 
	
	printf("%s",helpstr);	
		
	while(1)
	{
		printf("#");
		scanf("%c",&cmdchar);
		
		if(cmdchar)
		{
		
			switch(cmdchar)
			{
				case 'h':
					printf("hello \r\n");
					break;
			
				case 'w':
					printf("world \r\n");
					break;
			
				default:
					printf("command error \r\n");
					printf("%s",helpstr);
					break;
			}
			
		}
	}
	
}
示例#17
0
文件: main.c 项目: bibiyaya/tiny6410
int main()
{
   char c;
   int a, b;

   init_uart();
   printf("Hello world\n\r");

   while (1)
   {   
       printf("Please input two number:\n\r");
       scanf("%d%d", &a, &b);
       printf("\n\r");
       printf("The sum is :%d\n\r", a+b);
   }
   return 0;
}
示例#18
0
文件: platform.c 项目: keskella/omat
void
init_platform()
{
    /*
     * If you want to run this example outside of SDK,
     * uncomment the following line and also #include "ps7_init.h" at the top.
     * Make sure that the ps7_init.c and ps7_init.h files are included
     * along with this example source files for compilation.
     */
	#if( INCLUDE_PS7_INIT != 0 )
	{
		ps7_init();
	}
	#endif
    enable_caches();
    init_uart();
}
示例#19
0
int main()
{
	int i = 0;

	init_uart();

	timer_init(0,65,4,62500,0);

	printf("\r\n#############timer test############\r\n");
	while (1)
	{
		printf("%d\r\n",i++);
		delay();
	}
	
	return 0;
}
示例#20
0
int main(void){	
	//whether to blink LED2
	uint8_t blink=1;
	//temporally UART data holder
	uint8_t byte=0;

	//initialize system
	SystemInit();

	//initialize UART5 with 8-N-1 settings, 57600 baudrate
	init_uart(UART5_BASE_PTR,periph_clk_khz,57600);

	//clear all interrupts and enable interrupts
	nvic->ICPR[2] |= 1 << (87 & 0x1F); //Clear Pending Interrupts
	nvic->ISER[2] |= 1 << (87 & 0x1F); //Enable Interrupts
	
	//initialize GPIO ports
	gpio_init();

	//Loop forever
	while(true)
	{
		//use polling method to echo back data when available
		if(data_available()){ 
			byte = uart_read();
			if(byte==0xD) puts((uint8_t *)"\r\n"); //send new line character
			else if ((byte >= 0x30)&&(byte <= 0x39)){
				byte = byte - (0x30); //Evaluate the hexadecimal that has been sent from terminal 0-9
				display(byte); //Display function is written in the gpio.h
			}
			else if ((byte >= 0x41)&&(byte <= 0x46)){
				byte = byte - (0x37); //Evaluate the hexadecimal sent from terminal Uppercase letters A-F
				display(byte);
			}
			else if ((byte >= 0x61)&&(byte <= 0x66)){
				byte = byte - (0x57); //Evaluate hexadecimal sent Lowercase letters a-f
				display(byte);
			}
			else{
				display(byte);  //Show nothing Hopefully
			}
		delay();
			
		}
	}
}
示例#21
0
int16_t main(void) {
    init_clock();
    init_uart();

    printf("Hello World!\n");

    printf("What is your name? ");
    uart_gets(&uart1, string, 40);
    printf("Hello %s!\n", string);

    printf("Type something at the prompt.\n");

    while (1) {
        printf(">> ");
        uart_gets(&uart1, string, 40);
        printf("You typed '%s'\n", string);
    }
}
示例#22
0
/**
 * @brief Called on early hypervisor initialization and responsable for basic the
 * platform configuration. 
 */
void early_platform_init(){
    init_uart(115200, 9600, CPU_FREQ);
    
    /* SPI1 pin map */
    ANSELBCLR = 0x0008; /* pin B3 used as output for CS */
    TRISBCLR = 0x0008;
    TRISDCLR = 0x0002;  /* pin D1 used as output for SCLK */
    TRISFCLR = 0x0020;  /* pin F5 used as output for MOSI */
    TRISFSET = 0x0010;  /* pin F4 used as input for MISO */
    LATFSET = 0x0010;

    SDI1R = 2;  /* pin F4 as SPI1 data input */
    RPF5R = 5;  /* pin F5 as SPI1 data output */

    /* SPI config settings */
    SPI1BRG = 4; /* Set clock divider to selected_clock/10: selected_clk/(2*(4+1)) */
    SPI1CON = 0x8120; /* enable SPI / master mode / data transition from high to low clk */
}
示例#23
0
文件: lab6.c 项目: stasetzzz/IPU_Lab6
void main( void )
{
    init_uart();

    while(1)
    {
        print_menu();

        switch(read_uart())
        {
            case '1':    write_eeprom(1); break;
            case '2':    read_eeprom(1); break;
            case '3':    clear_eeprom(); break;
            case '4':    write_eeprom(0); read_eeprom(0); break;

            default: writeln_uart("wrong input\r\n"); break;
        }
    }
}    
示例#24
0
int16_t main(void) {
    //initialize modules
    init_clock();
    init_timer();
    init_uart();

    timer_setPeriod(&timer1,1e-2);//100 Hz
    timer_lower(&timer1);
    timer_start(&timer1);

    printf("Begin");

    while (1) {
        if (timer_flag(&timer1)){
            printf("GO");
            timer_lower(&timer1);
        }
    }
}
示例#25
0
文件: main.c 项目: bourne015/myCODES
int main()
{
	char c;
	int a, b;
	
	init_uart();

	printf("hello, world\n\r");
/*
	while (1)
	{
		printf("please enter two number: \n\r");
		scanf("%d %d", &a, &b);
		printf("\n\r");
		printf("the sum is: %d\n\r", a+b);
	}
*/	
	return 0;
}
示例#26
0
/**
 * @brief Initialises IOs, Motor driver, watchdog, UART, filtered ADC
 *
 */
void init(void)											

{			
													
	error_reg = 0x00;								//! Error Register							
	
													//! Defining the Outputs
	DDR_DRV				|= DRV_EN | DRV_MODE | DRV_PHASE | DRV_SLEEP;
	DDR_LIMIT_A_OUT		|= LIMIT_A_OUT;
	DDR_LIMIT_B_OUT		|= LIMIT_B_OUT;
	DDR_DIR_A_LED		|= DIR_A_LED;
	DDR_DIR_B_LED		|= DIR_B_LED;
	DDR_ERR_LED			|= DIR_ERR_LED;
	DDR_PWR_LED			|= PWR_LED;
	
	
	SET_PWR_LED;								//! Set Power LED													
	MOTOR_BREAK;								//! Engine on brake
			
							
	if (MCUCSR & (1<<WDRF))						//! Checking the watchdog-flag
	{
		error_reg |= ERR_WATCHDOG;				//! If a watchdog reset occurs, set the bit 6 of the error register high	
				MCUCSR = ~(1<<WDRF);			//! Delete the watchdog flag			
	}
		
	
	init_uart();								//! Call the UART init
	ADC_init ();								//! Call the ADC init	
	
	pRbUFuse= &rbUFuse;
	pRbU24	= &rbU24;
	pRbIDrv = &rbIDrv;
	
	rbInit(pRbUFuse);							//! Init ring buffers for median
	rbInit(pRbU24);							
	rbInit(pRbIDrv);
								
	Interrupt_init();							//! Call Interrupt init
	WDT_init ();								//! Call watchdog init
	
	return;										//! Return
}
示例#27
0
int main() {
	init_clock();
	init_uart();

	Uart_SendString("Hellocyj");
	//rGPBCON = 0x2; // GPB0 = TOUt0

    GPFCON &= ~(GPF4_MASK); //清0
    GPFCON |= (GPF4_CON); //赋值
    GPFDAT |= (1 << 4);

    initWatchdog();



    while (1);


    return 0;
}
示例#28
0
int main(void)
{
	int i = 0;
	
	char str[100];
		
	init_uart( );	//波特率57600,8N1(8个数据位,无校验位,1个停止位)

	printf("\n\rStart : \n\r");
	
	while(1)
	{
		printf("Enter a value : \n\r");
		scanf("%s", str);
		sscanf(str,"%d", &i);
		printf("print interger : %d, 0x%x\n\r", i, i);
	}

	return 0;
}
示例#29
0
int16_t main(void) {
    init_clock();
    init_uart();
    init_ui();
    init_timer();
    init_oc();
    
    led_on(&led2);
    timer_setPeriod(&timer2, 0.5);
    timer_start(&timer2);

    val1 = 0;
    val2 = 0;

    interval = 0.02;
    min_width = 5.5E-4;
    max_width = 2.3E-3;
    pos = 0; //16 bit int with binary point in front of the MSB

    oc_servo(&oc1,&D[0],&timer1, interval,min_width, max_width, pos);
    oc_servo(&oc2,&D[2],&timer3, interval,min_width, max_width, pos);

    printf("Good morning\n");

    InitUSB();                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
    }
    while (1) {
        ServiceUSB();
        //write the values to the servos (move the servos to the requested position)
        pin_write(&D[0],val1);
        pin_write(&D[2],val2);                     
        if (timer_flag(&timer2)) {
            //show a heartbeat and a status message
            timer_lower(&timer2);
            led_toggle(&led1);
            printf("val1 = %u, val2 = %u\n", val1, val2);
        }
    }
}
/** @brief  Main function for UART example / test program.
  *
  * @return None (never returns).
  *
  * Sits in a loop waiting for characters on the given UART, then sends
  *  a string telling what it got.
  */
int main()
{
    /* Choose the UART to use for test */
    UART_Type *uart = UART;
    uint8_t c;


    /* Set up uart for 8n2 */
    init_uart(uart, BAUD);

    uart_putstr(uart, "Now echoing characters: ");

    /* Loop forever, reporting what is received */
    while(1) {
        if (uart_available(uart)) {
            c = uart_getchar(uart);
            uart_putchar(uart, c);
            
        }
    }
}