Esempio n. 1
0
int main(void)
{
	system_init();
	configure_usart();
	configure_usart_callbacks();
	
	struct port_config pin_conf;
	port_get_config_defaults(&pin_conf);

	/* Configure LEDs as outputs, turn them off */
	pin_conf.direction  = PORT_PIN_DIR_OUTPUT;
	port_pin_set_config(LED_1_PIN, &pin_conf);
	port_pin_set_output_level(LED_1_PIN, LED_1_INACTIVE);

	/* Set buttons as inputs */
	pin_conf.direction  = PORT_PIN_DIR_INPUT;
	pin_conf.input_pull = PORT_PIN_PULL_UP;
	port_pin_set_config(BUTTON_1_PIN, &pin_conf);


#if USE_EIC == true
	configure_extint();
#endif

#if USE_INTERRUPTS == true
#  if USE_EIC == false
	configure_systick_handler();
#  else
	configure_eic_callback();
#  endif

	system_interrupt_enable_global();

	uint16_t temp;
	while (true) {
		/* Do nothing - use interrupts */
		//if (usart_read_wait(&usart_instance, &temp) == STATUS_OK)
		//{
			//while (usart_write_wait(&usart_instance, temp) != STATUS_OK);
		//}
		usart_read_buffer_job(&usart_instance, (uint8_t *)rx_buffer, 1);
		//sleepmgr_sleep(SLEEPMGR_STANDBY);
	}
#else
#  if USE_EIC == false
	while (true) {
		update_led_state();
	}
#  else
	while (true) {
		if (extint_chan_is_detected(BUTTON_1_EIC_LINE)) {
			extint_chan_clear_detected(BUTTON_1_EIC_LINE);

			update_led_state();
		}
	}
#  endif
#endif
}
Esempio n. 2
0
int main(void)
{
	system_init();

#if USE_EIC == true
	configure_extint();
#endif

#if USE_INTERRUPTS == true
#  if USE_EIC == false
	configure_systick_handler();
#  else
	configure_eic_callback();
#  endif

	system_interrupt_enable_global();

	while (true) {
		/* Do nothing - use interrupts */
	}
#else
#  if USE_EIC == false
	while (true) {
		update_led_state();
	}
#  else
	while (true) {
		if (extint_chan_is_detected(BUTTON_0_EIC_LINE)) {
			extint_chan_clear_detected(BUTTON_0_EIC_LINE);

			update_led_state();
		}
	}
#  endif
#endif
}
Esempio n. 3
0
/** Callback function for the EXTINT driver, called when an external interrupt
 *  detection occurs.
 *
 *  \param[in] channel  External Interrupt channel that has changed state
 */
static void extint_callback(uint32_t channel)
{
	update_led_state();
}
Esempio n. 4
0
/** Handler for the device SysTick module, called when the SysTick counter
 *  reaches the set period.
 *
 *  \note As this is a raw device interrupt, the function name is significant
 *        and must not be altered to ensure it is hooked into the device's
 *        vector table.
 */
void SysTick_Handler(void)
{
	update_led_state();
}
Esempio n. 5
0
/** Callback function for the EXTINT driver, called when an external interrupt
 *  detection occurs.
 */
static void extint_callback(void)
{
	update_led_state();
}