/** * \brief Initialize the app in low power: now PB0 push button has been pressed * once, the application switches in low power mode: Stop LCD controller, stop * LCD backlight, stop QTouch acquisition, switch SAM4L in power scaling PS1 * mode. SAM4L is in RUN mode. */ void app_init_lowpower(void) { // Stop LCD Controller lcdca_disable(); // Stop QTouch Initialization touch_sensors_deinit(); // Initialize board features board_init(); // Clear LCD backlight ioport_set_pin_level(LCD_BL_GPIO, IOPORT_PIN_LEVEL_LOW); // Disable the peripheral that we do not use anymore sysclk_disable_peripheral_clock(CATB); sysclk_disable_peripheral_clock(PDCA); sysclk_disable_peripheral_clock(LCDCA); // Set MCU Status ui_set_mcu_status(POWER_SCALING_PS1, SLEEP_MODE_RUN, 12000000, CPU_SRC_RC4M); // Switch in selected Power Scaling mode app_switch_power_scaling(ui_get_power_scaling_mcu_status()); // Send new MCU status to the board monitor ui_bm_send_mcu_status(); }
/** * \brief Disable the IPC peripheral. * * \param p_ipc Pointer to an IPC instance. */ void ipc_disable(Ipc *p_ipc) { if (p_ipc == IPC0) { sysclk_disable_peripheral_clock(ID_IPC0); } else { sysclk_disable_peripheral_clock(ID_IPC1); } }
void rs485_deinit(void) { sysclk_disable_peripheral_clock(&RS485_1_UART); sysclk_disable_peripheral_clock(&RS485_2_UART); ioport_configure_pin(IOPORT_CREATE_PIN(PORTC, 3), IOPORT_DIR_INPUT); ioport_configure_pin(IOPORT_CREATE_PIN(PORTC, 2), IOPORT_DIR_INPUT); ioport_configure_pin(IOPORT_CREATE_PIN(PORTC, 7), IOPORT_DIR_INPUT); ioport_configure_pin(IOPORT_CREATE_PIN(PORTC, 6), IOPORT_DIR_INPUT); //dma_disable(); }
/** * \brief Disables interrupt pin change */ static void ui_disable_asynchronous_interrupt(void) { eic_line_disable_interrupt(EIC, UI_WAKEUP_EIC_LINE); bpm_disable_wakeup_source(BPM, (1 << UI_WAKEUP_BPM_SRC)); bpm_disable_backup_pin(BPM, 1 << UI_WAKEUP_EIC_LINE); sysclk_disable_peripheral_clock(EIC); }
void disable_timeoutcnt(void) { tc_disable_interrupt(TC0, TC_CHANNEL_TICKCNT, TC_IER_CPCS); sysclk_disable_peripheral_clock(ID_TC0); timerEnabled = false; }
platform_result_t platform_uart_deinit( platform_uart_driver_t* driver ) { usart_disable_interrupt( driver->peripheral->peripheral, 0xffffffff ); NVIC_DisableIRQ( platform_uarts_irq_numbers[driver->peripheral->uart_id] ); pdc_disable_transfer( usart_get_pdc_base( driver->peripheral->peripheral ), PERIPH_PTCR_TXTDIS | PERIPH_PTCR_RXTDIS ); usart_disable_tx( driver->peripheral->peripheral ); usart_disable_rx( driver->peripheral->peripheral ); sysclk_disable_peripheral_clock( driver->peripheral->peripheral_id ); platform_gpio_deinit( driver->peripheral->tx_pin ); platform_gpio_deinit( driver->peripheral->rx_pin ); if ( driver->peripheral->cts_pin != NULL ) { platform_gpio_deinit( driver->peripheral->cts_pin ); } if ( driver->peripheral->rts_pin != NULL ) { platform_gpio_deinit( driver->peripheral->rts_pin ); } host_rtos_deinit_semaphore( &driver->tx_dma_complete ); host_rtos_deinit_semaphore( &driver->rx_dma_complete ); driver->peripheral = NULL; memset( driver, 0, sizeof(platform_uart_driver_t) ); return WICED_SUCCESS; }
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { /* Sanity check arguments */ MBED_ASSERT(obj); MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven)); MBED_ASSERT((data_bits == 5) || (data_bits == 6) || (data_bits == 7) || (data_bits == 8)); uint32_t clockid = 0; clockid = get_usart_clock_id(pUSART_S(obj)); if (clockid != (uint32_t)NC) { sysclk_disable_peripheral_clock(clockid); } switch(stop_bits) { /*selecting the stop bits*/ case 1: pSERIAL_S(obj)->uart_serial_options.stopbits = US_MR_NBSTOP_1_BIT; break; case 2: pSERIAL_S(obj)->uart_serial_options.stopbits = US_MR_NBSTOP_2_BIT; break; } switch(parity) { /*selecting the parity bits*/ case ParityNone: pSERIAL_S(obj)->uart_serial_options.paritytype = US_MR_PAR_NO; break; case ParityOdd: pSERIAL_S(obj)->uart_serial_options.paritytype = US_MR_PAR_ODD; break; case ParityEven: pSERIAL_S(obj)->uart_serial_options.paritytype = US_MR_PAR_EVEN; break; case ParityForced1: /*No Hardware Support*/ MBED_ASSERT(0); break; case ParityForced0: /*No Hardware Support*/ MBED_ASSERT(0); break; } switch(data_bits) { /*selecting the data bits*/ case 5: pSERIAL_S(obj)->uart_serial_options.charlength = US_MR_CHRL_5_BIT; break; case 6: pSERIAL_S(obj)->uart_serial_options.charlength = US_MR_CHRL_6_BIT; break; case 7: pSERIAL_S(obj)->uart_serial_options.charlength = US_MR_CHRL_7_BIT; break; case 8: pSERIAL_S(obj)->uart_serial_options.charlength = US_MR_CHRL_8_BIT; break; } usart_serial_init(_USART(obj), &(pSERIAL_S(obj)->uart_serial_options)); sysclk_enable_peripheral_clock(clockid); }
void tc_disable(volatile void *tc) { irqflags_t iflags = cpu_irq_save(); sysclk_disable_peripheral_clock(tc); cpu_irq_restore(iflags); }
/** * \brief Generate the CRC value for the firmware */ static void generate_crc(void) { uint32_t buffer_size = 0; /* Enable CRCCU peripheral clock */ sysclk_enable_peripheral_clock(CRCCU); /* Reset the CRCCU */ crccu_reset(CRCCU); /* Open the input file for CRC32 generation */ f_open(&file_object1, (char const *)input_file_name, FA_OPEN_EXISTING | FA_READ); /* Generate the CRC32 for the input binary */ while (true) { /* Read the data from the firmware */ f_read(&file_object1, (uint8_t *)buffer, FLASH_BUFFER_SIZE, &buffer_size); /* Check if there is any buffer */ if (!buffer_size) { break; } /* Set the memory address for CRCCU DMA transfer */ crc_dscr.ul_tr_addr = (uint32_t) buffer; /* Transfer width: byte, interrupt disable */ crc_dscr.ul_tr_ctrl = CRCCU_TR_CTRL_TRWIDTH_BYTE | buffer_size | CRCCU_TR_CTRL_IEN_DISABLE; /* Configure the CRCCU descriptor */ crccu_configure_descriptor(CRCCU, (uint32_t) &crc_dscr); /* Configure CRCCU mode */ crccu_configure_mode(CRCCU, CRCCU_MR_ENABLE | APP_CRC_POLYNOMIAL_TYPE); /* Start the CRC calculation */ crccu_enable_dma(CRCCU); /* Wait for calculation ready */ while ((crccu_get_dma_status(CRCCU) == CRCCU_DMA_SR_DMASR)) { } } /* Store the CRC32 Value */ firmware_crc = crccu_read_crc_value(CRCCU); /* Enable CRCCU peripheral clock */ sysclk_disable_peripheral_clock(CRCCU); /* Close the input file */ f_close(&file_object1); }
/** * \brief User Interface - Board Monitor Initialization : * and send SAM4L status. */ void ui_bm_init(void) { /* * Initialize Board Monitor and send first status */ sysclk_enable_peripheral_clock(BM_USART_USART); bm_init(); sysclk_disable_peripheral_clock(BM_USART_USART); ui_bm_send_mcu_status(); }
/** * \brief External interrupt handler, used by PB0 push button */ static void eic5_callback(void) { sysclk_enable_peripheral_clock(EIC); if(eic_line_interrupt_is_pending(EIC,GPIO_PUSH_BUTTON_EIC_LINE)) { eic_line_clear_interrupt(EIC,GPIO_PUSH_BUTTON_EIC_LINE); event_pbEvent = true; } sysclk_disable_peripheral_clock(EIC); }
// Interrupt on "pin change" from PB0 to do wakeup on USB // Note: // This interrupt is enable when the USB host enable remotewakeup feature // This interrupt wakeup the CPU if this one is in idle mode static void UI_WAKEUP_HANDLER(void) { sysclk_enable_peripheral_clock(EIC); if(eic_line_interrupt_is_pending(EIC, UI_WAKEUP_EIC_LINE)) { eic_line_clear_interrupt(EIC, UI_WAKEUP_EIC_LINE); ui_disable_asynchronous_interrupt(); // It is a wakeup then send wakeup USB udc_remotewakeup(); } sysclk_disable_peripheral_clock(EIC); }
/** * \brief User Interface Board Monitor send SAM4L status. */ void ui_bm_send_mcu_status(void) { uint32_t power_scaling, sleep_mode, cpu_freq, cpu_src; sysclk_enable_peripheral_clock(BM_USART_USART); power_scaling = sam4l_status.power_scaling; sleep_mode = sam4l_status.sleep_mode; cpu_freq = sam4l_status.cpu_freq; cpu_src = sam4l_status.cpu_src; bm_send_mcu_status(power_scaling, sleep_mode, cpu_freq, cpu_src); sysclk_disable_peripheral_clock(BM_USART_USART); }
// Interrupt on "pin change" from SW0 to do wakeup on USB // Note: // This interrupt is enable when the USB host enable remotewakeup feature // This interrupt wakeup the CPU if this one is in idle mode static void UI_WAKEUP_HANDLER(void) { sysclk_enable_peripheral_clock(EIC); if(eic_line_interrupt_is_pending(EIC, UI_WAKEUP_EIC_LINE)) { eic_line_clear_interrupt(EIC, UI_WAKEUP_EIC_LINE); ui_disable_asynchronous_interrupt(); // It is a wakeup then send wakeup USB udc_remotewakeup(); // Wakeup, ignore button change until button is back to default state btn_wakeup = true; } sysclk_disable_peripheral_clock(EIC); }
status_code_t picouart_set_config(struct picouart_dev_inst *const dev_inst, struct picouart_config *config) { if(PM->PM_PBDMASK & (1 << SYSCLK_PICOUART)) { dev_inst->dev_ptr->PICOUART_CFG = config->action | PICOUART_CFG_MATCH(config->match); } else { sysclk_enable_peripheral_clock(dev_inst->dev_ptr); dev_inst->dev_ptr->PICOUART_CFG = config->action | PICOUART_CFG_MATCH(config->match); sysclk_disable_peripheral_clock(dev_inst->dev_ptr); } return STATUS_OK; }
/** * \brief Disable FREQM. * * \param dev_inst Device structure pointer. * * \return Status code */ enum status_code freqm_disable(struct freqm_dev_inst *const dev_inst) { uint32_t timeout = FREQM_NUM_OF_ATTEMPTS; /* Wait until the measurement is done */ while (freqm_get_status(dev_inst) & FREQM_STATUS_BUSY) { if (!timeout--) { return ERR_TIMEOUT; } } sysclk_disable_peripheral_clock(dev_inst->hw_dev); sleepmgr_unlock_mode(SLEEPMGR_SLEEP_1); return STATUS_OK; }
/** * \brief Interrupt handler for interrupt pin change */ static void UI_WAKEUP_HANDLER(void) { sysclk_enable_peripheral_clock(EIC); if (eic_line_interrupt_is_pending(EIC, UI_WAKEUP_EIC_LINE)) { eic_line_clear_interrupt(EIC, UI_WAKEUP_EIC_LINE); if (uhc_is_suspend()) { ui_disable_asynchronous_interrupt(); /* Wakeup host and device */ uhc_resume(); } } sysclk_disable_peripheral_clock(EIC); }
/** * \brief Event Button Init. */ void event_button_init(void) { // Structure holding the configuration parameters // of the EIC module. struct eic_line_config eic_line_conf; // Initialize EIC Controller sysclk_enable_peripheral_clock(EIC); // Enable level-triggered interrupt. eic_line_conf.eic_mode = EIC_MODE_EDGE_TRIGGERED; // Interrupt will trigger on low-level. eic_line_conf.eic_level = EIC_LEVEL_LOW_LEVEL; // Edge on falling edge eic_line_conf.eic_edge = EIC_EDGE_FALLING_EDGE; // Enable filter. eic_line_conf.eic_filter = EIC_FILTER_DISABLED; // For Wake Up mode, initialize in asynchronous mode eic_line_conf.eic_async = EIC_ASYNCH_MODE; // Enable clock for EIC controller eic_enable(EIC); // Init the EIC controller with the options eic_line_set_config(EIC, GPIO_PUSH_BUTTON_EIC_LINE, &eic_line_conf); // Init the callback eic_line_set_callback(EIC, GPIO_PUSH_BUTTON_EIC_LINE, eic5_callback, EIC_5_IRQn, 1); // Enable the EIC line eic_line_enable(EIC, GPIO_PUSH_BUTTON_EIC_LINE); // EIC can wake the device from backup mode bpm_enable_wakeup_source(BPM, BPM_BKUP_WAKEUP_SRC_EIC | BPM_BKUP_WAKEUP_SRC_AST); // EIC can wake the device from backup mode bpm_enable_backup_pin(BPM, 1 << GPIO_PUSH_BUTTON_EIC_LINE); // Retain I/O lines after wakeup from backup bpm_disable_io_retention(BPM); bpm_enable_io_retention(BPM); bpm_enable_fast_wakeup(BPM); sysclk_disable_peripheral_clock(EIC); event_pbEvent = false; // Initialize WDT Controller sysclk_enable_peripheral_clock(WDT); enable_wdt(); }
void serial_baud(serial_t *obj, int baudrate) { /* Sanity check arguments */ MBED_ASSERT(obj); MBED_ASSERT((baudrate == 110) || (baudrate == 150) || (baudrate == 300) || (baudrate == 1200) || (baudrate == 2400) || (baudrate == 4800) || (baudrate == 9600) || (baudrate == 19200) || (baudrate == 38400) || (baudrate == 57600) || (baudrate == 115200) || (baudrate == 230400) || (baudrate == 460800) || (baudrate == 921600) ); uint32_t clockid = 0; clockid = get_usart_clock_id(pUSART_S(obj)); if (clockid != (uint32_t)NC) { sysclk_disable_peripheral_clock(clockid); } pSERIAL_S(obj)->uart_serial_options.baudrate = baudrate; usart_serial_init(_USART(obj), &(pSERIAL_S(obj)->uart_serial_options)); sysclk_enable_peripheral_clock(clockid); }
/** * \brief Initialize the AES module. * * \param p_aes Base address of the AES instance. * \param p_cfg Pointer to AES configuration. * */ void aes_init(Aes *const p_aes, struct aes_config *const p_cfg) { /* Sanity check arguments */ Assert(p_aes); Assert(p_cfg); /* Enable clock for AES */ sysclk_enable_peripheral_clock(ID_AES); /* Perform a software reset */ aes_reset(p_aes); /* Initialize the AES with new configurations */ aes_set_config(p_aes, p_cfg); /* Disable clock for AES */ sysclk_disable_peripheral_clock(ID_AES); }
/** Disables the target's PDI interface, exits programming mode and starts the target's application. */ void XPROGTarget_DisableTargetPDI(void) { /* Switch to Rx mode to ensure that all pending transmissions are complete */ if (IsSending) XPROGTarget_SetRxMode(); /* Turn off receiver and transmitter of the USART, clear settings */ usart_disable_rx(USART_PDI); usart_disable_tx(USART_PDI); /* Tristate all pins */ gpio_configure_pin(PIN_PDIC_GPIO, PIN_PDIC_IN_FLAGS); gpio_configure_pin(PIN_PDIDRX_GPIO, PIN_PDIDRX_FLAGS); gpio_configure_pin(PIN_PDIDTX_GPIO, PIN_PDIDTX_IN_FLAGS); /* Turn off USART */ sysclk_disable_peripheral_clock(USART_PDI_ID); }
OSStatus platform_uart_deinit( platform_uart_driver_t* driver ) { uint8_t uart_number; OSStatus err = kNoErr; platform_mcu_powersave_disable(); require_action_quiet( ( driver != NULL ), exit, err = kParamErr); usart_disable_interrupt( driver->peripheral->peripheral, 0xffffffff ); NVIC_DisableIRQ( platform_uarts_irq_numbers[driver->peripheral->uart_id] ); pdc_disable_transfer( usart_get_pdc_base( driver->peripheral->peripheral ), PERIPH_PTCR_TXTDIS | PERIPH_PTCR_RXTDIS ); usart_disable_tx( driver->peripheral->peripheral ); usart_disable_rx( driver->peripheral->peripheral ); sysclk_disable_peripheral_clock( driver->peripheral->peripheral_id ); platform_gpio_deinit( driver->peripheral->tx_pin ); platform_gpio_deinit( driver->peripheral->rx_pin ); if ( driver->peripheral->cts_pin != NULL ) { platform_gpio_deinit( driver->peripheral->cts_pin ); } if ( driver->peripheral->rts_pin != NULL ) { platform_gpio_deinit( driver->peripheral->rts_pin ); } #ifndef UART_NO_OS mico_rtos_deinit_semaphore(&driver->rx_complete); mico_rtos_deinit_semaphore(&driver->tx_complete); #endif driver->peripheral = NULL; memset( driver, 0, sizeof(platform_uart_driver_t) ); exit: platform_mcu_powersave_enable(); return err; }
wwd_result_t platform_bus_enter_powersave( void ) { if ( sdio_bus_initted == WICED_TRUE ) { uint32_t a; /* Disable the MCI peripheral */ sysclk_disable_peripheral_clock( ID_HSMCI ); /* Disable SDIO peripheral clock */ for ( a = WWD_PIN_SDIO_CLK; a < WWD_PIN_SDIO_MAX; a++ ) { ioport_set_pin_mode( wifi_sdio_pins[0].pin, IOPORT_MODE_PULLUP ); ioport_set_pin_dir ( wifi_sdio_pins[0].pin, IOPORT_DIR_INPUT ); } } return WICED_SUCCESS; }
void naiboard_sleep(void) { if (naiboard_state.usb_vendor_enabled) // If we're not connected we won't go to sleep. return; // We're only using the IDLE sleep level because USB doesn't work below that. // Not much power saving though... SLEEP.CTRL = SLEEP_SMODE_IDLE_gc; sysclk_disable_peripheral_clock(&RTC); //printf_P(PSTR("sleep\n")); WDT_Disable(); sleep_enable(); cpu_sleep(); // Waking up sleep_disable(); WDT_Enable(); sysclk_enable_peripheral_clock(&RTC); //printf_P(PSTR("wake\n")); }
/** * \brief Initialize the ADC module. * * \param dev_inst Device structure pointer. * \param adc Base address of the ADC instance. * \param cfg Pointer to AES configuration. * * \retval true if the initialization was successful. * \retval false if initialization failed. */ status_code_t adc_init(struct adc_dev_inst *const dev_inst, Adcife *const adc, struct adc_config *const cfg) { /* Sanity check arguments */ Assert(dev_inst); Assert(adc); Assert(cfg); dev_inst->hw_dev = adc; dev_inst->adc_cfg = cfg; /* Enable APB clock for ADC */ sysclk_enable_peripheral_clock(adc); /* Initialize the ADC with new configurations */ adc_set_config(dev_inst, cfg); /* Disable APB clock for ADC */ sysclk_disable_peripheral_clock(adc); return STATUS_OK; }
/** * \brief Initialize the AES module. * * \param dev_inst Device structure pointer. * \param aesa Base address of the AESA instance. * \param cfg Pointer to AES configuration. * * \retval true if the initialization was successful. * \retval false if initialization failed. */ bool aes_init(struct aes_dev_inst *const dev_inst, Aesa *const aesa, struct aes_config *const cfg) { /* Sanity check arguments */ Assert(dev_inst); Assert(aesa); Assert(cfg); dev_inst->hw_dev = aesa; dev_inst->aes_cfg = cfg; /* Enable APB clock for AES */ sysclk_enable_peripheral_clock(aesa); /* Initialize the AES with new configurations */ aes_set_config(dev_inst); /* Disable APB clock for AES */ sysclk_disable_peripheral_clock(aesa); return true; }
/** * \brief Interrupt handler for interrupt pin change */ static void UI_WAKEUP_HANDLER(void) { sysclk_enable_peripheral_clock(EIC); if (eic_line_interrupt_is_pending(EIC, UI_WAKEUP_EIC_LINE)) { eic_line_clear_interrupt(EIC, UI_WAKEUP_EIC_LINE); if (ui_b_host_mode) { if (!uhc_is_suspend()) { /* USB is not in suspend mode * Let's interrupt enable. */ return; } ui_disable_asynchronous_interrupt(); /* Wakeup the devices connected */ uhc_resume(); } else { /* In device mode, wakeup the USB host. */ udc_remotewakeup(); } } sysclk_disable_peripheral_clock(EIC); }
void picouart_disable(struct picouart_dev_inst *const dev_inst) { dev_inst->dev_ptr->PICOUART_CR = PICOUART_CR_DIS; sysclk_disable_peripheral_clock(PICOUART); sleepmgr_unlock_mode(SLEEPMGR_BACKUP); }
/** * \brief Disable the events module. */ void events_disable(void) { sysclk_disable_peripheral_clock(PEVC); sleepmgr_unlock_mode(SLEEPMGR_BACKUP); }
/** * \brief Disables interrupt pin change */ static void ui_disable_asynchronous_interrupt(void) { eic_line_disable_interrupt(EIC, UI_WAKEUP_EIC_LINE); sysclk_disable_peripheral_clock(EIC); }