Пример #1
0
int main(void)
{
	int i;
	int j = 0;
	clock_setup();
	usart_setup();
	printf("hi guys!\n");
	adc_setup();
	dac_setup();
	gpio_set_mode(LED_DISCOVERY_USER_PORT, GPIO_MODE_OUTPUT_2_MHZ,
		GPIO_CNF_OUTPUT_PUSHPULL, LED_DISCOVERY_USER_PIN);
	
	while (1) {
		uint16_t input_adc0 = read_adc_naiive(0);
		uint16_t target = input_adc0 / 2;
		dac_load_data_buffer_single(target, RIGHT12, CHANNEL_2);
		dac_software_trigger(CHANNEL_2);
		uint16_t input_adc1 = read_adc_naiive(1);
		printf("tick: %d: adc0= %u, target adc1=%d, adc1=%d\n",
			j++, input_adc0, target, input_adc1);
		gpio_toggle(LED_DISCOVERY_USER_PORT, LED_DISCOVERY_USER_PIN); /* LED on/off */
		for (i = 0; i < 1000000; i++) /* Wait a bit. */
			__asm__("NOP");
	}

	return 0;
}
Пример #2
0
void console_init(console_t *con)
{
	usart_setup(con->usart, con->speed);

	//putchar_cb = put_cb;
	//getchar_cb = get_cb;

	//stdout = &uart_fdstream;
	//stdin = &uart_fdstream;
}
Пример #3
0
void init(void)
{
	clock_setup();
	systick_setup();
	usart_setup();

	platform_simrf_init();
	// interrupt pin from mrf
	platform_mrf_interrupt_enable();
}
Пример #4
0
int main(void)
{
	int i;
	int iserr = 1;

	clock_setup();
	gpio_setup();
	usart_setup();

	/* Blink the LED (PD12) on the board with every transmitted byte. */
	while (1) {
		gpio_toggle(GPIOD, GPIO12);	/* LED on/off */

		/* encode the plaintext message into ciphertext */

		crypto_set_key(CRYPTO_KEY_128BIT, key);
		crypto_set_iv(iv); /* only in CBC or CTR mode */
		crypto_set_datatype(CRYPTO_DATA_32BIT);
		crypto_set_algorithm(ENCRYPT_DES_ECB);

		crypto_start();
		crypto_process_block((uint32_t *)plaintext,
				     (uint32_t *)ciphertext,
				      8 / sizeof(uint32_t));
		crypto_stop();

		/* decode the previously encoded message
		   from ciphertext to plaintext2 */

		crypto_set_key(CRYPTO_KEY_128BIT, key);
		crypto_set_iv(iv); /* only in CBC or CTR mode */
		crypto_set_datatype(CRYPTO_DATA_32BIT);
		crypto_set_algorithm(DECRYPT_DES_ECB);

		crypto_start();
		crypto_process_block((uint32_t *)ciphertext,
				     (uint32_t *)plaintext2,
				      8 / sizeof(uint32_t));
		crypto_stop();

		/* compare the two plaintexts if they are same */
		iserr = 0;
		for (i = 0; i < 8; i++) {
			if (plaintext[i] != plaintext2[i]) {
				iserr = true;
			}
		}

		if (iserr) {
			gpio_toggle(GPIOD, GPIO12); /* something went wrong. */
		}
	}

	return 0;
}
static void prvSetupHardware( void )
{
	clock_setup();
    systickSetup();
	gpio_setup();
	usart_setup();
/* Setup Rx/Tx buffers for USART */
	buffer_init(send_buffer,BUFFER_SIZE);
	buffer_init(receive_buffer,BUFFER_SIZE);

}
Пример #6
0
int main() {
  rcc_clock_setup_in_hse_8mhz_out_72mhz();
  usart_setup();
  
  UARTSink sink;
  arm_bootloader::Handler handler(sink, arm_bootloader::get_unique_dest(), 1024);
  
  while(true) {
    handler.handleByte(usart_recv_blocking(USART1));
  }
}
int main(void)
{
	clock_setup();
	gpio_setup();
	usart_setup();
	systick_setup();

	while (1)
		__asm__("nop");

	return 0;
}
Пример #8
0
int main(void)
{
	clock_setup();
	gpio_setup();
	usart_setup();

	/* Wait forever and do nothing. */
	while (1)
		__asm__("nop");

	return 0;
}
Пример #9
0
int main(void)
{
	clock_setup();
	gpio_setup();
	usart_setup();

	while (1) {
		__asm__("NOP");
	}

	return 0;
}
int main(void)
{
	uint8_t channel_array[16];
	uint16_t temperature = 0;

	rcc_clock_setup_in_hse_12mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	timer_setup();
	adc_setup();

	gpio_set(GPIOA, GPIO8);	                /* LED1 on */
	gpio_set(GPIOC, GPIO15);		/* LED2 on */

	/* Send a message on USART1. */
	usart_send_blocking(USART2, 's');
	usart_send_blocking(USART2, 't');
	usart_send_blocking(USART2, 'm');
	usart_send_blocking(USART2, '\r');
	usart_send_blocking(USART2, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	/* Set the injected sequence here, with number of channels */
	adc_set_injected_sequence(ADC1, 1, channel_array);

	/* Continously convert and poll the temperature ADC. */
	while (1) {
		/*
		 * Since the injected sampling is triggered by the timer, it gets
		 * updated automatically, we just need to periodically read out the value.
		 * It would be better to check if the JEOC bit is set, and clear it following
		 * so that you do not read the same value twice, especially for a slower
		 * sampling rate.
		 */

		temperature = adc_read_injected(ADC1,1); //get the result from ADC_JDR1 on ADC1 (only bottom 16bits)

		/*
		 * That's actually not the real temperature - you have to compute it
		 * as described in the datasheet.
		 */
		my_usart_print_int(USART2, temperature);

		gpio_toggle(GPIOA, GPIO8); /* LED2 on */

	}

	return 0;
}
Пример #11
0
int main(void)
{
	clock_setup();
	gpio_setup();
	usart_setup();
	printf("hi guys!\n");
	setup_buttons();
	setup_tim6();
	setup_tim7();
	while (1) {
		;
	}

	return 0;
}
Пример #12
0
void FastSerial::begin(long baud, uint32_t tx_timeout) {

    if ( (uint32)baud > this->usart_device->max_baud) {
        return;
    }

    const stm32_pin_info *txi = &PIN_MAP[tx_pin];
    const stm32_pin_info *rxi = &PIN_MAP[rx_pin];

    gpio_set_mode(txi->gpio_device, txi->gpio_bit, GPIO_AF_OUTPUT_PP);
    gpio_set_mode(rxi->gpio_device, rxi->gpio_bit, GPIO_INPUT_FLOATING);

    usart_init(usart_device);
    usart_setup(usart_device, baud, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, USART_Mode_Rx | USART_Mode_Tx, USART_HardwareFlowControl_None);
    usart_enable(usart_device); 
}
Пример #13
0
static void reset_clocks(void)
{
	/* 4MHz MSI raw range 2*/
	struct rcc_clock_scale myclock_config = {
		.hpre = RCC_CFGR_HPRE_SYSCLK_NODIV,
		.ppre1 = RCC_CFGR_PPRE1_HCLK_NODIV,
		.ppre2 = RCC_CFGR_PPRE2_HCLK_NODIV,
		.voltage_scale = PWR_SCALE2,
		.flash_waitstates = FLASH_ACR_LATENCY_0WS,
		.apb1_frequency = 4194000,
		.apb2_frequency = 4194000,
		.msi_range = RCC_ICSCR_MSIRANGE_4MHZ,
	};
	rcc_clock_setup_msi(&myclock_config);

	/* buttons and uarts */
	rcc_periph_clock_enable(RCC_GPIOA);
	/* user feedback leds */
	rcc_periph_clock_enable(RCC_GPIOB);
	/* Enable clocks for USART2. */
	rcc_periph_clock_enable(RCC_USART2);
	/* And a timers for button presses */
	rcc_periph_clock_enable(RCC_TIM7);
}

int main(void)
{
	reset_clocks();
	gpio_setup();
	usart_setup();
	setup_buttons();
	setup_button_press_timer();
	printf("we're awake!\n");

	setup_rtc();
	setup_rtc_wakeup(1);

	while (1) {
		PWR_CR |= PWR_CR_LPSDSR;
		pwr_set_stop_mode();
		__WFI();
		reset_clocks();
		process_state(&state);
	}

	return 0;
}
Пример #14
0
int main(void)
{
	int counter = 0;
	uint16_t rx_value = 0x42;

/* Setup Rx/Tx buffers for USART */
	buffer_init(send_buffer,BUFFER_SIZE);
	buffer_init(receive_buffer,BUFFER_SIZE);

	clock_setup();
	gpio_setup();
	usart_setup();
    usart_print_string("SPI-DMA Test\n\r");
	spi_setup();

	while (1) {

        gpio_toggle(GPIOA, GPIO1);

#ifdef LOOPBACK
/* Print what is going to be sent on the SPI bus */
		usart_print_string("Sending  packet ");
        usart_print_int(counter);
        usart_print_string("\n\r");
		spi_send(SPI1, (uint8_t) counter);
		rx_value = spi_read(SPI1);
		usart_print_string("Received  packet ");
        usart_print_int(rx_value);
        usart_print_string("\n\r");
        counter++;
#else
/* This is a 1-byte "reset" command to SD card */
		spi_send(SPI1, 0x40);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x95);
	/* Read the byte that just came in (use a loopback between MISO and MOSI
	 * to get the same byte back)
	 */
		rx_value = spi_read(SPI1);
#endif
	}

	return 0;
}
Пример #15
0
int main(void)
{
	u8 channel_array[16];
	u16 temperature;

	rcc_clock_setup_in_hse_16mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	adc_setup();

	gpio_clear(GPIOB, GPIO7);	/* LED1 on */
	gpio_set(GPIOB, GPIO6);		/* LED2 off */

	/* Send a message on USART1. */
	usart_send(USART1, 's');
	usart_send(USART1, 't');
	usart_send(USART1, 'm');
	usart_send(USART1, '\r');
	usart_send(USART1, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	adc_set_regular_sequence(ADC1, 1, channel_array);

	/*
	 * If the ADC_CR2_ON bit is already set -> setting it another time
	 * starts the conversion.
	 */
	adc_on(ADC1);

	/* Wait for end of conversion. */
	while (!(ADC_SR(ADC1) & ADC_SR_EOC));

	temperature = ADC_DR(ADC1);

	/*
	 * That's actually not the real temperature - you have to compute it
	 * as described in the datasheet.
	 */
	my_usart_print_int(USART1, temperature);

	gpio_clear(GPIOB, GPIO6); /* LED2 on */

	while(1); /* Halt. */

	return 0;
}
Пример #16
0
int main(void)
{
	u8 channel_array[16];

	rcc_clock_setup_in_hse_12mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	timer_setup();
	irq_setup();
	adc_setup();

	gpio_set(GPIOA, GPIO8);	                /* LED1 on */
	gpio_set(GPIOC, GPIO15);		/* LED2 on */

	/* Send a message on USART1. */
	usart_send_blocking(USART2, 's');
	usart_send_blocking(USART2, 't');
	usart_send_blocking(USART2, 'm');
	usart_send_blocking(USART2, '\r');
	usart_send_blocking(USART2, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	/* Set the injected sequence here, with number of channels */
	adc_set_injected_sequence(ADC1, 1, channel_array);

	/* Continously convert and poll the temperature ADC. */
	while (1) {
		/*
		 * Since sampling is triggered by the timer and copying the value
		 * out of the data register is handled by the interrupt routine,
		 * we just need to print the value and toggle the LED. It may be useful
		 * to buffer the adc values in some cases.
		 */

		/*
		 * That's actually not the real temperature - you have to compute it
		 * as described in the datasheet.
		 */
		my_usart_print_int(USART2, temperature);

		gpio_toggle(GPIOA, GPIO8); /* LED2 on */

	}

	return 0;
}
Пример #17
0
int main(void)
{
	uint8_t channel_array[16];
	uint16_t temperature;

	rcc_clock_setup_in_hse_16mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	adc_setup();

	gpio_clear(GPIOB, GPIO7);	/* LED1 on */
	gpio_set(GPIOB, GPIO6);		/* LED2 off */

	/* Send a message on USART1. */
	usart_send(USART1, 's');
	usart_send(USART1, 't');
	usart_send(USART1, 'm');
	usart_send(USART1, '\r');
	usart_send(USART1, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	adc_set_regular_sequence(ADC1, 1, channel_array);

	/*
	 * Start the conversion directly (not trigger mode).
	 */
	adc_start_conversion_direct(ADC1);

	/* Wait for end of conversion. */
	while (!(ADC_SR(ADC1) & ADC_SR_EOC));

	temperature = ADC_DR(ADC1);

	/*
	 * That's actually not the real temperature - you have to compute it
	 * as described in the datasheet.
	 */
	my_usart_print_int(USART1, temperature);

	gpio_clear(GPIOB, GPIO6); /* LED2 on */

	while(1); /* Halt. */

	return 0;
}
int main(void)
{

	rcc_clock_setup_in_hse_12mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	timer_setup();
	irq_setup();
	adc_setup();

	gpio_set(GPIOA, GPIO8);	                /* LED1 off */
	gpio_set(GPIOC, GPIO15);		/* LED5 off */

	/* Send a message on USART1. */
	usart_send_blocking(USART2, 's');
	usart_send_blocking(USART2, 't');
	usart_send_blocking(USART2, 'm');
	usart_send_blocking(USART2, '\r');
	usart_send_blocking(USART2, '\n');

	/* Moved the channel selection and sequence init to adc_setup() */

	/* Continously convert and poll the temperature ADC. */
	while (1) {
		/*
		 * Since sampling is triggered by the timer and copying the values
		 * out of the data registers is handled by the interrupt routine,
		 * we just need to print the values and toggle the LED. It may be useful
		 * to buffer the adc values in some cases.
		 */

		my_usart_print_int(USART2, temperature);
		usart_send_blocking(USART2, ' ');
		my_usart_print_int(USART2, v_refint);
		usart_send_blocking(USART2, ' ');
		my_usart_print_int(USART2, lisam_adc1);
		usart_send_blocking(USART2, ' ');
		my_usart_print_int(USART2, lisam_adc2);
		usart_send_blocking(USART2, '\r');

		gpio_toggle(GPIOA, GPIO8); /* LED2 on */

	}

	return 0;
}
Пример #19
0
int main(void)
{
       	uint16_t temp;

	clock_setup();
	gpio_setup();
	adc_setup();
	usart_setup();

	while (1) {
	  adc_start_conversion_regular(ADC1);
	  while (!(adc_eoc(ADC1)));
	  temp=adc_read_regular(ADC1);
 	  gpio_port_write(GPIOE, temp << 4);
	  my_usart_print_int(USART2, temp);
	}

	return 0;
}
Пример #20
0
int main(void) {
    clock_setup();
    gpio_setup();
    usart_setup();
    systick_setup();
    tim_setup();

    /* wait 3 seconds to allow Linux detecting /dev/ttyUSB */
    while (systick_counter_ms < 3000) ;

    /* output signal is on GPIO C 10 (EXT1-8) */
    /* gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_TRIGGER); */

    while (1) {
	/* If the input signal is high */
	if (gpio_get(GPIO_BANK_TIM1_CH2, GPIO_TIM1_CH2) != 0) {
	    /* Output a raising edge */
	    gpio_set(GPIOC, GPIO_TRIGGER);
	    /* Wait for the input signal going down, max 2 ms */
	    for (systick_counter_ms = 0; systick_counter_ms < 2;)
		if (gpio_get(GPIO_BANK_TIM1_CH2, GPIO_TIM1_CH2) == 0)
		    break;
	    /* Output a falling edge */
	    gpio_clear(GPIOC, GPIO_TRIGGER);
	} else {
	    latency = 0;
	    /* Output a raising edge (trigger signal) */
	    gpio_set(GPIOC, GPIO_TRIGGER);
	    /* Wait for the latency to be available */
	    for (systick_counter_ms = 0; systick_counter_ms < 2;)
		if (latency != 0)
		    break;
	    /* Output a falling edge */
	    gpio_clear(GPIOC, GPIO_TRIGGER);
	    if (latency != 0)
		printf("%3d - %3d\n", latency, latency_max);
	}

	/* Wait 1 ms before next trigger */
	for (systick_counter_ms = 0; systick_counter_ms < 1;) ;
    }
}
Пример #21
0
int main(void)
{
	int i = 0;
	uint16_t temperature;

	rcc_clock_setup_in_hse_16mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	i2c_setup();

	gpio_clear(GPIOB, GPIO7);	/* LED1 on */
	gpio_set(GPIOB, GPIO6);		/* LED2 off */

	/* Send a message on USART1. */
	usart_send(USART1, 's');
	usart_send(USART1, 't');
	usart_send(USART1, 'm');
	usart_send(USART1, '\r');
	usart_send(USART1, '\n');

	stts75_write_config(I2C2, STTS75_SENSOR0);
	stts75_write_temp_os(I2C2, STTS75_SENSOR0, 0x1a00); /* 26 degrees */
	stts75_write_temp_hyst(I2C2, STTS75_SENSOR0, 0x1a00);
	temperature = stts75_read_temperature(I2C2, STTS75_SENSOR0);

	/* Send the temperature as binary over USART1. */
	for (i = 15; i >= 0; i--) {
		if (temperature & (1 << i))
			usart_send(USART1, '1');
		else
			usart_send(USART1, '0');
	}

	usart_send(USART1, '\r');
	usart_send(USART1, '\n');

	gpio_clear(GPIOB, GPIO6); /* LED2 on */

	while (1); /* Halt. */

	return 0;
}
Пример #22
0
int main(void)
{
	uint16_t temp;

	adc_setup();
	usart_setup();

	while (1) {
		adc_start_conversion_regular(ADC1);
		while (!(adc_eoc(ADC1)));

		temp = adc_read_regular(ADC1);
		my_usart_print_int(USART1, temp);

		int i;
		for (i = 0; i < 800000; i++) {   /* Wait a bit. */
			__asm__("nop");
		}
	}

	return 0;
}
Пример #23
0
int main(void){
	ddr_setup();		//set up pins
	usart_setup(BAUD);	//set up USART with defined Baudrate

	uint8_t adc_data_xaxis = 0;	//hold x tilt data
	uint8_t adc_data_yaxis = 0;	//hold y tilt data

	uint8_t motor1_prev = 0;	//hold previous m1 state
	uint8_t motor2_prev = 0;	//hold previous m2 state
	uint8_t mtr_prev = 0;


	while(1){
		_delay_ms(1);				//just wait
		adc_data_xaxis = adc_read(X_AXIS);	//read x tilt
		adc_data_yaxis = adc_read(Y_AXIS);	//read y tilt


		set_mtr_state(adc_data_xaxis, adc_data_yaxis);
		//if ( mtr_state != mtr_prev){
		usart_sendbyte(mtr_state);
		//}
		mtr_prev = mtr_state;
		if (PINA & (1<<0)){
			usart_sendbyte(FORWARD);
		}
		else if (PINA & (1<<1)){
			usart_sendbyte(BACKWARD);
		}
		else if (PINA & (1<<2)){
			usart_sendbyte(RIGHT);
		}
		else if (PINA & (1<<3)){
			usart_sendbyte(LEFT);
		}
	}


}
Пример #24
0
int main(void)
{
	int i,c=0,j=0;

	led_setup();
    usart_setup();

	while (1) {

        gpio_toggle(GPIOF, GPIO_LEDS);
        usart_send_blocking(USART1, c + 'a');
        c = (c == 25) ? 0 : c+1 ;
        if((j++ % 80) == 0)
        {
            usart_send_blocking(USART1, '\r');
            usart_send_blocking(USART1, '\n');
        }
        for(i = 0; i < 800000; i++)
            __asm__("NOP");
    }
    return 0;
}
Пример #25
0
int main(void)
{
    int counter = 0;
    volatile uint16_t dummy __attribute__((unused));

    clock_setup();
    gpio_setup();
    usart_setup();
    spi_setup();

    while (1) {
        counter++;
        printf("Hello, world! %i\r\n", counter);
        /* Stops RX buffer overflow, but probably not needed. */
        dummy = spi_read(SPI2);
        spi_send(SPI2, (uint8_t) counter);
        gpio_toggle(GPIOC, GPIO3);
    }

    while (1);

    return 0;
}
Пример #26
0
int main(void)
{
	int i, c = 0;
	FILE *fp;

	clock_setup();
	gpio_setup();
	fp = usart_setup(USART1);

	/* Blink the LED (PD12) on the board with every transmitted byte. */
	while (1) {
		gpio_toggle(GPIOC, GPIO8);	/* LED on/off */
		
		fprintf(fp,"Pass: %d\n",c);
		
		c = (c == 200) ? 0 : c + 1;	/* Increment c. */
		
		for (i = 0; i < 1000000; i++)	/* Wait a bit. */
			__asm__("NOP");
	}

	return 0;
}
Пример #27
0
int main(void)
{
	int i, j = 0, c = 0;

	clock_setup();
	gpio_setup();
	usart_setup();

	/* Blink the LED (PC9) on the board with every transmitted byte. */
	while (1) {
		gpio_toggle(GPIOC, GPIO9);	/* LED on/off */
		usart_send_blocking(USART1, c + '0'); /* USART1: Send byte. */
		c = (c == 9) ? 0 : c + 1;	/* Increment c. */
		if ((j++ % 80) == 0) {		/* Newline after line full. */
			usart_send_blocking(USART1, '\r');
			usart_send_blocking(USART1, '\n');
		}
		for (i = 0; i < 800000; i++)	/* Wait a bit. */
			__asm__("NOP");
	}

	return 0;
}
Пример #28
0
int main(void)
{
    clock_setup();
    gpio_setup();
    usart_setup(115200);

    uint32_t address = 0x08080000;

    eeprom_program_word(address, 0x44434241);  // mind the endianness here
    uint32_t data[2] = {0x48474645, 0x4C4B4A49};
    eeprom_program_words(address+4, data, 2);

    int i;
    unsigned char buffer[12];
    for (i = 0; i < 12; i++) {
        buffer[i] = *((unsigned char *)(0x08080000 + i));
    }
    send_USART_bytes(buffer, 12);

    while (1);

    return 0;
}
Пример #29
0
int main(void)
{
    clock_setup();
    gpio_setup();
    usart_setup(115200);
    rng_setup();

	int i;
	
	unsigned char output[32];

	poly sk;
	unsigned char key_a[32], key_b[32];
	unsigned char senda[NEWHOPE_SENDABYTES];
	unsigned char sendb[NEWHOPE_SENDBBYTES];
	for(i=0;i<NTESTS;i++)
	{
		/*send_USART_str((unsigned char *)"starting to keygen\n");*/
		newhope_keygen(senda,&sk);

		/*send_USART_str((unsigned char *)"starting to sharedb\n");*/
		newhope_sharedb(key_a,sendb,senda);
    
		/*send_USART_str((unsigned char *)"starting to shareda\n");*/
		newhope_shareda(key_b,&sk,sendb);
        
		if(memcmp(key_a,key_b,32))
		{
		  sprintf((char *)output, "Error in keys");
		  send_USART_str(output);
		}
	}
	sprintf((char *)output, "done!");
	send_USART_str(output);
    signal_host();
    return 0;
}
Пример #30
0
/**
 * Callback from your main program to set up the board's hardware before
 * the kernel is started.
 */
int board_setup(void)
{
    /* Disable interrupts. This makes sure that the sys_tick_handler will
     * not be called before the first thread has been started.
     * Interrupts will be enabled by archFirstThreadRestore().
     */
    cm_mask_interrupts(true);

    /* configure system clock, user LED and UART */
    clock_setup();
    test_led_setup();
    usart_setup(57600);

    /* initialise SysTick counter */
    systick_setup();

    /* Set exception priority levels. Make PendSv the lowest priority and
     * SysTick the second to lowest
     */
    nvic_set_priority(NVIC_PENDSV_IRQ, 0xFF);
    nvic_set_priority(NVIC_SYSTICK_IRQ, 0xFE);

    return 0;
}