int main() { /* Setup an interrupt to notice when charging stops. */ MCUCR |= (1 << ISC10); /* INT1 - trigger on any logic change */ GIMSK |= (1 << INT1) | /* Enable INT1 interupt */ (1 << PCIE); /* Enable PCINT change interrupt */ PCMSK = (1 << PCINT3); /* Trigger PCINT interrupt on PCINT3 */ /* Setup the 16 bit timer to trigger every 1 second. */ TCCR1B = (1 << CS12) | (1 << CS10) | /* 1/1024 prescaler */ (1 << WGM12); /* CTC mode */ OCR1A = 7812; /* Set TOP of timer to give 1 second frequency */ TIMSK = (1 << OCIE1A); /* Enable the interrupt */ usi_init(I2C_SLAVE_ADDR, i2c_read_from_register, i2c_write_to_register); sei(); while (1) { } }
/** * \brief Main code entry point. */ int main( void ) { /* Prepare the hardware */ prvSetupHardware(); /* Usi initialization */ usi_init(); /* Initialize USI communication structure */ x_phy_serial_msg.uc_protocol_type = PROTOCOL_USER_DEFINED; while (1) { usi_process(); /* blink led 0 */ if (b_led_swap) { b_led_swap = false; #if (BOARD == SAM4CMP_DB || BOARD == SAM4CMS_DB) LED_Toggle(LED4); #else LED_Toggle(LED0); #endif } } }
/** * \brief Main code entry point. */ int main( void ) { #ifdef CONF_BOARD_LCD_EN status_code_t status; #endif /* count ms to blink led */ ul_count_ms = 500; /* Prepare the hardware */ prvSetupHardware(); /* UART debug */ configure_dbg_console(); puts(STRING_HEADER); #ifdef CONF_BOARD_LCD_EN /* Initialize the C42364A LCD glass component. */ status = c42364a_init(); if (status != STATUS_OK) { puts("-- LCD Initialization fails! --\r\n"); while (1) { } } c42364a_set_contrast(15); c42364a_clear_all(); c42364a_show_icon(C42364A_ICON_ATMEL); c42364a_show_icon(C42364A_ICON_USB); c42364a_show_text((const uint8_t *)"PHYSNF"); #endif /* Init process timers */ initTimer1ms(); /* Init Phy Layer */ phy_init(SNIFFER_IF_ENABLE); /* Init Usi Layer */ usi_init(); while (1) { /* blink led 0 */ if (b_led_swap) { b_led_swap = false; #if (BOARD == SAM4CMP_DB || BOARD == SAM4CMS_DB) LED_Toggle(LED4); #else LED_Toggle(LED0); #endif } /* updWatchDog (); */ /* sniffer serialization */ sniffer_if_process(); /* USI */ usi_process(); } }