void boardsupport_init(void) { central_data_t *central_data; irq_initialize_vectors(); cpu_irq_enable(); Disable_global_interrupt(); sysclk_init(); //delay_init(sysclk_get_cpu_hz()); INTC_init_interrupts(); central_data=central_data_get_pointer_to_struct(); #ifdef TELEMETRY_USE_UART uart_int_set_usart_conf(TELEMETRY_UART_INDEX, asv_debug_uart_conf()); //uart configuration uart_int_init(TELEMETRY_UART_INDEX); uart_int_register_write_stream(uart_int_get_uart_handle(TELEMETRY_UART_INDEX), &(central_data->wired_out_stream)); // Registering streams buffer_make_buffered_stream_lossy(&(wired_in_buffer), &(central_data->wired_in_stream)); uart_int_register_read_stream(uart_int_get_uart_handle(TELEMETRY_UART_INDEX), &(central_data->wired_in_stream)); central_data->debug_in_stream=¢ral_data->wired_in_stream; central_data->debug_out_stream=¢ral_data->wired_out_stream; #endif central_data_init(); Enable_global_interrupt(); }
/*! \brief Main function. Execution starts here. */ int main(void) { #if SAMD21 || SAML21 || SAMDA1 system_init(); #else sysclk_init(); board_init(); #endif irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager sleepmgr_init(); ui_init(); // Start USB host stack uhc_start(); // The USB management is entirely managed by interrupts. // As a consequence, the user application does only have to play with the power modes. while (true) { sleepmgr_enter_sleep(); } }
/** * \brief Main function of the Serial Bridge application */ int main(void) { irq_initialize_vectors(); #if SAMD || SAMR21 system_init(); delay_init(); #else sysclk_init(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); #endif cpu_irq_enable(); serial_bridge_init(); while (1) { serial_bridge_handler(); } }
/** * \brief Main function of the Performance Analyzer application * \ingroup group_app_init */ int main(void) { irq_initialize_vectors(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); sysclk_init(); /* * Power ON - so set the board to INIT state. All hardware, PAL, TAL and * stack level initialization must be done using this function */ set_main_state(INIT, NULL); cpu_irq_enable(); sio2host_init(); /* INIT was a success - so change to WAIT_FOR_EVENT state */ set_main_state(WAIT_FOR_EVENT, NULL); /* Endless while loop */ while (1) { pal_task(); /* Handle platform specific tasks, like serial interface */ tal_task(); /* Handle transceiver specific tasks */ app_task(); /* Application task */ serial_data_handler(); } }
/*! \brief Main function. Execution starts here. */ int main(void) { #if SAMD21 || SAML21 system_init(); #else sysclk_init(); board_init(); #endif irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager sleepmgr_init(); ui_init(); // Start USB dual mode which will start the correct mode (device or host) // corresponding at USB ID signal. uhc_start(); // The main loop manages only the power mode // because the USB stack is full interrupt driven. while (true) { sleepmgr_enter_sleep(); } }
int main(void) { irq_initialize_vectors(); #if SAMD || SAMR21 system_init(); delay_init(); #else sysclk_init(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); #endif performance_analyzer_init(); cpu_irq_enable(); /* Endless while loop */ while (1) { performance_analyzer_task(); } }
int I2C_init( void ) { twi_options_t opt; twi_slave_fct_t twi_slave_fct; int status; double total = 0; // Initialize and enable interrupt irq_initialize_vectors(); cpu_irq_enable(); // TWI gpio pins configuration gpio_enable_module(TWI_GPIO_MAP, sizeof(TWI_GPIO_MAP) / sizeof(TWI_GPIO_MAP[0])); // initialize the interrupt flag for alerting the Pi of new data (TWI = Three Wire Interface for us) ioport_enable_pin(I2C_FLAG); ioport_set_pin_dir(I2C_FLAG,IOPORT_DIR_OUTPUT); ioport_set_pin_level(I2C_FLAG,false); // options settings opt.pba_hz = FOSC0; opt.speed = TWI_SPEED; opt.chip = EEPROM_ADDRESS; // initialize TWI driver with options twi_slave_fct.rx = &twi_slave_rx; twi_slave_fct.tx = &twi_slave_tx; twi_slave_fct.stop = &twi_slave_stop; status = twi_slave_init(&AVR32_TWI, &opt, &twi_slave_fct ); return (&s_memory[0] ); }
/*! \brief Main function. Execution starts here. */ int main(void) { irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager sleepmgr_init(); #if !SAM0 sysclk_init(); board_init(); #else system_init(); #endif ui_init(); ui_powerdown(); // Start USB stack to authorize VBus monitoring udc_start(); // The main loop manages only the power mode // because the USB management is done by interrupt while (true) { sleepmgr_enter_sleep(); } }
/* This function is meant to contain board-specific initialization code * for, e.g., the I/O pins. The initialization can rely on application- * specific board configuration, found in conf_board.h. */ void v2x_board_init(void) { irq_initialize_vectors(); pmic_init(); sysclk_init(); //configure clock sources for core and USB sleepmgr_init(); // Initialize the sleep manager ioport_init(); //Initializes the IOPORT service pin_init(); //whole chip pin init, modes and initial conditions spi_start(); //start SPI driver PWR_init(); //sets SR to default states - holds power up cpu_irq_enable(); eeprom_init(); //verifies eeprom safe for use menu_init(); //loads menu settings time_init(); //starts the RTC button_init(); //init button stuffs ACL_init(); //configures, but does not start sampling GSM_usart_init(); //starts direct serial channel to the SIM module CAN_uart_start(); //starts direct serial channel to the ELM module canbus_serial_routing(AVR_ROUTING); //cause the serial 3-state buffer to route the serial path from the ELM to the FTDI udc_start(); //start stack and vbus monitoring PWR_hub_start(); //connect the hub to the computer //autostart all systems delay_ms(500); GSM_modem_init(); CAN_elm_init(); ACL_set_sample_on(); PWR_host_start(); }
/*! \brief Main function. Execution starts here. */ int main(void) { /* Initialize the synchronous clock system to the default configuration set in conf_clock.h. \note All non-essential peripheral clocks are initially disabled. */ sysclk_init(); /* Initialize interrupts */ irq_initialize_vectors(); cpu_irq_enable(); /* Initialize the sleep manager, lock initial mode. */ sleepmgr_init(); /* Initialize the resources used by this example to the default configuration set in conf_board.h */ board_init(); /* Initialize the user interface */ ui_init(); /* Start USB host stack */ uhc_start(); /* The main loop manages only the power mode because the USB management is done by interrupt */ while (true) { sleepmgr_enter_sleep(); } }
/*! \brief Main function. */ int main(void) { irq_initialize_vectors(); #if SAMD20 system_init(); delay_init(); #else sysclk_init(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); #endif sw_timer_init(); serial_interface_init(); if (MAC_SUCCESS != wpan_init()) { app_alert(); } LED_On(LED_POWER); cpu_irq_enable(); while (1) { wpan_task(); serial_data_handler(); } }
/*! \brief Main function. Execution starts here. */ int main(void) { irq_initialize_vectors(); cpu_irq_enable(); /* Initialize the sleep manager */ sleepmgr_init(); #if !SAMD21 && !SAMR21 sysclk_init(); board_init(); #else system_init(); #endif ui_init(); ui_powerdown(); /* Start USB stack to authorize VBus monitoring */ udc_start(); /* The main loop manages only the power mode * because the USB management is done by interrupt */ while (true) { sleepmgr_enter_sleep(); if (main_b_phdc_enable) { if (ieee11073_skeleton_process()) { ui_association(true); /* Association Ok */ } else { ui_association(false); /* No association */ } } } }
/*! \brief Main function. Execution starts here. */ int main(void) { irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager sleepmgr_init(); sysclk_init(); board_init(); ui_init(); ui_powerdown(); memories_initialization(); // Start USB stack to authorize VBus monitoring udc_start(); // The main loop manages only the power mode // because the USB management is done by interrupt while (true) { if (main_b_msc_enable) { if (!udi_msc_process_trans()) { sleepmgr_enter_sleep(); } }else{ sleepmgr_enter_sleep(); } } }
/************************************************************************************************** * Main entry point */ int main(void) { CCP = CCP_IOREG_gc; // unlock IVSEL PMIC.CTRL |= PMIC_IVSEL_bm; // set interrupt vector table to bootloader section // check for VUSB PORTD.DIRCLR = PIN5_bm; PORTD.PIN5CTRL = (PORTD.PIN5CTRL & ~PORT_OPC_gm) | PORT_OPC_PULLDOWN_gc; _delay_ms(1); if (0) //if (!(PORTD.IN & PIN5_bm)) // not connected to USB { // exit bootloader AppPtr application_vector = (AppPtr)0x000000; CCP = CCP_IOREG_gc; // unlock IVSEL PMIC.CTRL = 0; // disable interrupts, set vector table to app section EIND = 0; // indirect jumps go to app section RAMPZ = 0; // LPM uses lower 64k of flash application_vector(); } // set up USB HID bootloader interface sysclk_init(); irq_initialize_vectors(); cpu_irq_enable(); udc_start(); udc_attach(); for(;;); }
/*! \brief Main function. Execution starts here. */ int main(void) { /* System clock is initialized. */ sysclk_init(); /* Board related init such as SPI and GPIO. */ board_init(); /* IRQs init. */ irq_initialize_vectors(); /* Transceiver init. */ if (at86rfx_init() != AT86RFX_SUCCESS) { Assert("Transceiver initialization failed" == 0); } /* Interrupt enabled before USB init as it uses IRQ for enumeration. */ cpu_irq_enable(); /* Start USB stack */ udc_start(); /* Continuous looping of available tasks, starts here. */ while (true) { usb_task(); app_task(); at86rfx_task(); } }
/*! \brief Main function. Execution starts here. */ int main(void) { irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager sleepmgr_init(); sysclk_init(); board_init(); ui_init(); ui_powerdown(); // Start USB stack to authorize VBus monitoring udc_start(); if (!udc_include_vbus_monitoring()) { // VBUS monitoring is not available on this product // thereby VBUS has to be considered as present main_vbus_action(true); } // The main loop manages only the power mode // because the USB management is done by interrupt while (true) { sleepmgr_enter_sleep(); } }
int main(void) { init_sys_clocks(); init_dbg_rs232(FPBA_HZ); print_dbg("AVR UC3 DSP DEMO\r\n"); irq_initialize_vectors(); // GUI, Controller and DSP process init gui_init(FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ); gui_text_print(GUI_COMMENT_ID, TEXT_IDLE); gui_text_print(GUI_FILTER_ID, filter_active_get_description()); controller_init(FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ); twi_init(); dsp_process_init(FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ); cpu_irq_enable(); // Main loop while (1) { gui_task(); controller_task(); dsp_process_task(); state_machine_task(); } }
int main (void) { irq_initialize_vectors(); cpu_irq_enable(); system_init(); sleepmgr_init(); HAL_usb_init(); module_in = xQueueCreate(MODULE_QUEUE_LENGTH , MODULE_QUEUE_ITEM_SIZE); module_out = xQueueCreate(MODULE_QUEUE_LENGTH , MODULE_QUEUE_ITEM_SIZE); if( module_in == NULL || module_out == NULL){ /* The queue could not be created. */ while(1); } // Create tasks xTaskCreate(&receiver_stream, (const char *)"receiver_stream", RECEIVER_STREAM_STACK_SIZE, NULL , RECEIVER_STREAM_PRIORITY , NULL); xTaskCreate(&sender_stream, (const char *)"sender_stream", SENDER_STREAM_STACK_SIZE, NULL , SENDER_STREAM_PRIORITY , NULL); xTaskCreate(&modules, (const char *)"modules", MODULES_STACK_SIZE, NULL , MODULES_PRIORITY , NULL); //Start FreeRTOS scheduler vTaskStartScheduler(); /* Code should never get here */ while (1) { } }
/*! \brief Main File Section: * - Initialization (CPU, Controller Task,... ) * - Main loop with task management (ADC, DAC, CAN and GUI) */ int main(void) { irq_initialize_vectors(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); /* Initialize the clocks. * The clock-specific conf_clocks.h file contains the configuration of * the clocks initialization. */ sysclk_init(); // Initialize the sleep manager sleepmgr_init(); sleepmgr_lock_mode(SLEEPMGR_IDLE); /* Initialize the required Task. * - Initialize the DAC task to start the signal generator, * - Initialize the ADC task to start the scope acquisition, * - Initialize the Noise Task to add digital noise to the signal, * - Initialize the Filter Task to remove the digital noise of the signal, * - Initialize the GUI Task to display signals as a scope on the LCD, * - Initialize the Remote Task to display signals as a scope on the LCD, */ dac_task_init(); adc_task_init(); noise_task_init(); filter_task_init(); gui_task_init(); controller_task_init(); remote_task_init(); cpu_irq_enable(); // Free running scheduler loop while (true) { // Enter Sleep Mode sleepmgr_enter_sleep(); // Call ADC task adc_task(); // Call DAC task dac_task(); // Call Noise task noise_task(); // Filter Task filter_task(); // Call Gui task for update gui_task(); // Call Controller Task for control Update controller_task(); // Send data to the PC Application remote_task(); } }
//! @{ void twis_init (void) { twis_slave_fct_t twis_slave_fct; #if BOARD == UC3L_EK /** * \internal For UC3L devices, TWI default pins are, * TWIMS0 -> PB05,PA21 * TWIMS1 -> PB04 * To enable TWI clock/data in another pin, these have * to be assigned to other peripherals or as GPIO. * \endinternal */ gpio_enable_gpio_pin(AVR32_PIN_PB05); gpio_enable_gpio_pin(AVR32_PIN_PA21); #endif const gpio_map_t TWIS_GPIO_MAP = { {TEST_TWIS_TWCK_PIN, TEST_TWIS_TWCK_FUNCTION}, {TEST_TWIS_TWD_PIN, TEST_TWIS_TWD_FUNCTION} }; const twis_options_t TWIS_OPTIONS = { .pba_hz = FPBA_HZ, .speed = TWI_SPEED, .chip = SLAVE_ADDRESS, .smbus = false, }; // Assign I/Os to SPI. gpio_enable_module (TWIS_GPIO_MAP, sizeof (TWIS_GPIO_MAP) / sizeof (TWIS_GPIO_MAP[0])); // Set pointer to user specific application routines twis_slave_fct.rx = &twis_slave_rx; twis_slave_fct.tx = &twis_slave_tx; twis_slave_fct.stop = &twis_slave_stop; // Initialize as master. twis_slave_init (TWIS, &TWIS_OPTIONS, &twis_slave_fct); } //! @} /*! \brief Main function. */ /*! \remarks Main Function */ //! @{ int main (void) { // Configure the system clock init_sys_clocks (); // Init debug serial line init_dbg_rs232 (FPBA_HZ); // Display a header to user print_dbg ("Slave Example\r\n"); print_dbg ("Slave Started\r\n"); // Initialize and enable interrupt irq_initialize_vectors(); cpu_irq_enable(); // Initialize the TWIS Module twis_init (); while (true); }
/** * Main function, initialization and main message loop * */ int main(void) { irq_initialize_vectors(); /* Initialize the board.*/ board_init(); /* Initialize the Software timer */ sw_timer_init(); /* Init the RF4CE Network layer */ if (nwk_init()!= NWK_SUCCESS) { app_alert(); } #ifdef RF4CE_CALLBACK_PARAM /* Register the ZID Callback indication */ zid_ind.zid_report_data_indication_cb = zid_report_data_indication; zid_ind.zid_get_report_indication_cb = zid_get_report_indication; register_zid_indication_callback(&zid_ind); #endif /* * The stack is initialized above, * hence the global interrupts are enabled here. */ cpu_irq_enable(); sw_timer_get_id(&APP_TIMER_ACC_READ); if (get_zid_keyrc_button(button_scan()) == ZID_COLD_START) { /* Cold start */ LED_On(ZID_APP_LED); node_status = COLD_START; nlme_reset_request(true #ifdef RF4CE_CALLBACK_PARAM ,(FUNC_PTR)nlme_reset_confirm #endif ); } else { /* Warm start */ node_status = WARM_START; nlme_reset_request(false #ifdef RF4CE_CALLBACK_PARAM ,(FUNC_PTR)nlme_reset_confirm #endif ); } /* Endless while loop */ while (1) { app_task(); /* Application task */ nwk_task(); /* RF4CE network layer task */ } }
int main(void) { struct adc_config adc_conf; struct adc_channel_config adcch_conf; board_init(); sysclk_init(); sleepmgr_init(); irq_initialize_vectors(); cpu_irq_enable(); gfx_mono_init(); // Enable back light of display ioport_set_pin_high(LCD_BACKLIGHT_ENABLE_PIN); // Initialize configuration structures. adc_read_configuration(&ADCA, &adc_conf); adcch_read_configuration(&ADCA, ADC_CH0, &adcch_conf); /* Configure the ADC module: * - unsigned, 12-bit results * - VCC voltage reference * - 200 kHz maximum clock rate * - manual conversion triggering * - temperature sensor enabled * - callback function */ adc_set_conversion_parameters(&adc_conf, ADC_SIGN_ON, ADC_RES_12, ADC_REF_VCC); adc_set_clock_rate(&adc_conf, 200000UL); adc_set_conversion_trigger(&adc_conf, ADC_TRIG_MANUAL, 1, 0); adc_enable_internal_input(&adc_conf, ADC_INT_TEMPSENSE); adc_write_configuration(&ADCA, &adc_conf); adc_set_callback(&ADCA, &adc_handler); /* Configure ADC channel 0: * - single-ended measurement from temperature sensor * - interrupt flag set on completed conversion * - interrupts disabled */ adcch_set_input(&adcch_conf, ADCCH_POS_PIN1, ADCCH_NEG_NONE, 1); adcch_set_interrupt_mode(&adcch_conf, ADCCH_MODE_COMPLETE); adcch_enable_interrupt(&adcch_conf); adcch_write_configuration(&ADCA, ADC_CH0, &adcch_conf); // Enable the ADC and start the first conversion. adc_enable(&ADCA); adc_start_conversion(&ADCA, ADC_CH0); do { // Sleep until ADC interrupt triggers. sleepmgr_enter_sleep(); } while (1); }
/*! \brief Main function. Execution starts here. */ int main(void) { //Initialize interrupt controller irq_initialize_vectors(); cpu_irq_enable(); // Initialize sleep manager sleepmgr_init(); // Initialize clock tree sysclk_init(); // Initialize hardware board resources board_init(); // Initialize user interface ui_init(); ui_powerdown(); // Sanity check about Silicon revision Vs Firmware build // for Silicon revision A, firmware should be specific if ((!firmware_rev_a) && (nvm_read_device_rev()==0)) { ui_si_revision_error(); while(ui_button()!=1); while(ui_button()!=2); while(ui_button()!=4); while(ui_button()!=8); } // Initialize DATA Flash at45dbx_init(); // Initialize ADC for on-board sensors adc_sensors_init(); // Initialize USB HID report protocol usb_hid_com_init(); // Start USB stack main_build_usb_serial_number(); udc_start(); // The main loop manages only the power mode // because everything else is managed by interrupt. // The USB Start of Frame event manages internal tick events for // on-board sensor updates as well as LCD display update. while (true) { if (main_b_msc_enable) { if (!udi_msc_process_trans()) { sleepmgr_enter_sleep(); } } else { sleepmgr_enter_sleep(); } if (usb_hid_com_is_start_dfu()) { main_start_dfu_session(); } } }
/** * @brief Main function of the Terminal Target application */ int main(void) { irq_initialize_vectors(); sysclk_init(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); sw_timer_init(); if (nwk_init()!= NWK_SUCCESS) { app_alert(); } zrc_ind.vendor_data_ind_cb = vendor_data_ind; #ifdef ZRC_CMD_DISCOVERY zrc_ind.zrc_cmd_disc_indication_cb = zrc_cmd_disc_indication; #endif zrc_ind.zrc_cmd_indication_cb = zrc_cmd_indication; register_zrc_indication_callback(&zrc_ind); nwk_ind.nwk_ch_agility_indication_cb = nwk_ch_agility_indication; nwk_ind.nlme_unpair_indication_cb = nlme_unpair_indication; register_nwk_indication_callback(&nwk_ind); /* Initialize LEDs. */ LED_On(LED_START); /* indicating application is started */ LED_Off(LED_NWK_SETUP); /* indicating network is started */ LED_Off(LED_DATA); /* indicating data reception */ /* * The stack is initialized above, hence the global interrupts are *enabled * here. */ cpu_irq_enable(); #ifdef SIO_HUB /* Initialize the serial interface used for communication with terminal *program. */ sio2host_init(); #endif sw_timer_get_id(&led_timer); /* Endless while loop */ while (1) { app_task(); /* Application task */ nwk_task(); /* RF4CE network layer task */ } }
int main(void) { /* Usual initializations */ board_init(); sysclk_init(); sleepmgr_init(); irq_initialize_vectors(); cpu_irq_enable(); /* Unmask clock for TCC4 */ tc45_enable(&TCC4); /* Configure TC in normal mode */ tc45_set_wgm(&TCC4, TC45_WG_NORMAL); /* Configure period equal to resolution to obtain 1Hz */ tc45_write_period(&TCC4, TIMER_EXAMPLE_RESOLUTION); /* Configure CCA to occur at the middle of TC period */ tc45_write_cc(&TCC4, TC45_CCA, TIMER_EXAMPLE_RESOLUTION / 2); /* Configure CCB to occur at the quarter of TC period */ tc45_write_cc(&TCC4, TC45_CCB, TIMER_EXAMPLE_RESOLUTION / 4); /* Enable both CCA and CCB channels */ tc45_enable_cc_channels(&TCC4, TC45_CCACOMP); tc45_enable_cc_channels(&TCC4, TC45_CCBCOMP); /* * Configure interrupts callback functions for TCC4 * overflow interrupt, CCA interrupt and CCB interrupt */ tc45_set_overflow_interrupt_callback(&TCC4, example_ovf_interrupt_callback); tc45_set_cca_interrupt_callback(&TCC4, example_cca_interrupt_callback); tc45_set_ccb_interrupt_callback(&TCC4, example_ccb_interrupt_callback); /* * Enable TC interrupts (overflow, CCA and CCB) */ tc45_set_overflow_interrupt_level(&TCC4, TC45_INT_LVL_LO); tc45_set_cca_interrupt_level(&TCC4, TC45_INT_LVL_LO); tc45_set_ccb_interrupt_level(&TCC4, TC45_INT_LVL_LO); /* * Run TCC4 */ tc45_set_resolution(&TCC4, TIMER_EXAMPLE_RESOLUTION); do { /* Go to sleep, everything is handled by interrupts. */ sleepmgr_enter_sleep(); } while (1); }
int main(void) { struct adc_config adc_conf; struct adc_channel_config adcch_conf; board_init(); sysclk_init(); sleepmgr_init(); irq_initialize_vectors(); cpu_irq_enable(); // Initialize configuration structures. adc_read_configuration(&ADCA, &adc_conf); adcch_read_configuration(&ADCA, ADC_CH0, &adcch_conf); /* Configure the ADC module: * - unsigned, 12-bit results * - bandgap (1 V) voltage reference * - 200 kHz maximum clock rate * - manual conversion triggering * - temperature sensor enabled * - callback function */ adc_set_conversion_parameters(&adc_conf, ADC_SIGN_OFF, ADC_RES_12, ADC_REF_BANDGAP); adc_set_clock_rate(&adc_conf, 200000UL); adc_set_conversion_trigger(&adc_conf, ADC_TRIG_MANUAL, 1, 0); adc_enable_internal_input(&adc_conf, ADC_INT_TEMPSENSE); adc_write_configuration(&ADCA, &adc_conf); adc_set_callback(&ADCA, &adc_handler); /* Configure ADC channel 0: * - single-ended measurement from temperature sensor * - interrupt flag set on completed conversion * - interrupts disabled */ adcch_set_input(&adcch_conf, ADCCH_POS_TEMPSENSE, ADCCH_NEG_NONE, 1); adcch_set_interrupt_mode(&adcch_conf, ADCCH_MODE_COMPLETE); adcch_enable_interrupt(&adcch_conf); adcch_write_configuration(&ADCA, ADC_CH0, &adcch_conf); // Get measurement for 85 degrees C (358 kelvin) from calibration data. tempsense = adc_get_calibration_data(ADC_CAL_TEMPSENSE); // Enable the ADC and start the first conversion. adc_enable(&ADCA); adc_start_conversion(&ADCA, ADC_CH0); do { // Sleep until ADC interrupt triggers. sleepmgr_enter_sleep(); } while (1); }
/** \brief This function initializes peripherals (timer and communication). */ void sha204p_init(void) { // Initialize timer. sha204h_timer_init(); // Initialize interrupt vectors. irq_initialize_vectors(); // Enable interrupts. cpu_irq_enable(); }
int main(void) { const usart_serial_options_t usart_serial_options = { .baudrate = CONF_TEST_BAUDRATE, .charlength = CONF_TEST_CHARLENGTH, .paritytype = CONF_TEST_PARITY, .stopbits = CONF_TEST_STOPBITS, }; uint16_t volts_values[3][NB_VALUE]; int16_t volt_output; uint8_t i; /* Usual initializations */ board_init(); sysclk_init(); sleepmgr_init(); irq_initialize_vectors(); cpu_irq_enable(); stdio_serial_init(CONF_TEST_USART, &usart_serial_options); printf("\x0C\n\r-- ADC Calibration and averaging example"); printf(" (Compiled: %s %s)\n\r", __DATE__, __TIME__); /* ADC and DAC initializations */ main_dac_init(); main_adc_init(); /* Conversions without averaging and without corrections */ main_conversions(volts_values[0]); /* Enable averaging */ main_adc_averaging(); /* Conversions with averaging and without corrections */ main_conversions(volts_values[1]); /* Measure and enable corrections */ main_adc_correction(); /* Conversions with averaging and with corrections */ main_conversions(volts_values[2]); /* Display values */ printf("| ADC input | ADC res. | Delta | Averaging | Delta | Aver.+Corr. | Delta |\n\r"); volt_output = -CONV_MAX_VOLTAGE; for (i = 0; i < NB_VALUE; i++) { printf("| %5d mV | %5d mV | %4d mV | %5d mV | %4d mV | %5d mV | %4d mV |\n\r", volt_output, volts_values[0][i], volts_values[0][i] - volt_output, volts_values[1][i], volts_values[1][i] - volt_output, volts_values[2][i], volts_values[2][i] - volt_output); volt_output += CONV_VOLTAGE_STEP; } while (1) { } }
/** * \brief Application entry point. * * \return Unused (ANSI-C compatibility). */ int main(void) { uint8_t slot = 0; sd_mmc_err_t err; system_init(); delay_init(); cdc_uart_init(); irq_initialize_vectors(); cpu_irq_enable(); time_tick_init(); // Initialize SD MMC stack sd_mmc_init(); printf("\x0C\n\r-- SD/MMC Card Example --\n\r"); printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); while (1) { if (slot == sd_mmc_nb_slot()) { slot = 0; } printf("Please plug an SD/MMC card in slot %d.\n\r", slot+1); // Wait for a card and ready do { err = sd_mmc_check(slot); if ((SD_MMC_ERR_NO_CARD != err) && (SD_MMC_INIT_ONGOING != err) && (SD_MMC_OK != err)) { printf("Card install FAILED\n\r"); printf("Please unplug and re-plug the card.\n\r"); while (SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) { } } } while (SD_MMC_OK != err); // Display basic card information main_display_info_card(slot); /* Test the card */ if (sd_mmc_get_type(slot) & (CARD_TYPE_SD | CARD_TYPE_MMC)) { // SD/MMC Card R/W main_test_memory(slot); } printf("Test finished, please unplugged the card.\n\r"); while (SD_MMC_OK == sd_mmc_check(slot)) { } slot++; } }
/*! \brief Main function. Execution starts here. */ int main(void) { irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager sleepmgr_init(); #if !SAMD21 && !SAMR21 sysclk_init(); board_init(); #else system_init(); #endif ui_init(); ui_powerdown(); // Start USB stack to authorize VBus monitoring udc_start(); // The main loop manages only the power mode // because the USB management is done by interrupt PORTC_DIR=0b00000011; // USTAWIENIE NA PORCIE C DWÓCH PINÓW WYJŒCIOWYCH while (true) { char ch; if (udi_cdc_is_rx_ready()) { ch = udi_cdc_getc(); switch(ch) { case '0' : PORTC.OUT=PIN1_bm; _delay_ms(1000); udi_cdc_write_buf("START \n\r", 14); PORTC.OUTTGL=PIN1_bm; break;// USTAWIENIE 0 I 1 case '1' : PORTC.OUT=PIN0_bm; _delay_ms(1000); udi_cdc_write_buf("ZAWORY \n\r", 14); PORTC.OUTTGL=PIN0_bm; break; // NEGACJA PORTÓW default : udi_cdc_write_buf("'S' TO START A 'Z' TO ZMIANA", 26); break; }; } } }