示例#1
0
uint_32 _kuart_int_enable
   (
      /* [IN] the address of the device specific information */
      KUART_INFO_STRUCT_PTR io_info_ptr
   )
{ /* Body */
   uint_8                  flags = IO_PERIPHERAL_MODULE_ENABLE | IO_PERIPHERAL_CLOCK_ENABLE;
   UART_MemMapPtr          sci_ptr = io_info_ptr->SCI_PTR;

#if MQX_ENABLE_LOW_POWER

   uint_32 clock, mode = _lpm_get_operation_mode ();
   if (mode >= LPM_OPERATION_MODES)
   {
      return MQX_INVALID_CONFIGURATION;
   }
   flags = io_info_ptr->INIT.OPERATION_MODE[mode].FLAGS;

   clock = _lpm_get_clock_configuration ();
   if (clock >= BSP_CLOCK_CONFIGURATIONS)
   {
      return MQX_INVALID_CONFIGURATION;
   }
#endif

   /* Enable module clocks to be able to write registers */
   _bsp_serial_io_init (io_info_ptr->INIT.DEVICE, IO_PERIPHERAL_CLOCK_ENABLE);

   /* Enable/disable module */
   if (flags & IO_PERIPHERAL_MODULE_ENABLE)
   {
      _kuart_int_peripheral_enable (sci_ptr);
   }
   else
   {
      _kuart_int_peripheral_disable (sci_ptr);
   }

   /* Disable module clocks if required */
   if (flags & IO_PERIPHERAL_CLOCK_DISABLE)
   {
      _bsp_serial_io_init (io_info_ptr->INIT.DEVICE, IO_PERIPHERAL_CLOCK_DISABLE);
   }

   return MQX_OK;

} /* Endbody */
示例#2
0
文件: main.c 项目: BillyZhangZ/wifi
void main_task
(
    uint32_t initial_data
)
{
    BSP_CLOCK_CONFIGURATION clock_configuration;

    printf("\n***********************************************************\n");
    printf("   MQX frequency change demo\n");
    printf("***********************************************************\n");

    /* Create global event */
    if (_lwevent_create(&app_event, LWEVENT_AUTO_CLEAR) != MQX_OK)
    {
        printf("\nCreating app_event failed.\n");
        _task_block();
    }

    printf("\n***********  DEFAULT CLOCK CONFIGURATION  **********\n");

    /* Get and print active clock configuration */
    clock_configuration =  _lpm_get_clock_configuration();
    display_clock_values(clock_configuration);

    printf("\nPress button on the board to loop over frequency modes.\n");

    while (1)
    {
        /* wait for button press */
        wait_for_event();
        printf("\n***************  BSP_CLOCK_CONFIGURATION_0  **************\n");

        /* Switch clock configuration */
        if (CM_ERR_OK != _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_0))
        {
            printf("Cannot change clock configuration");
            _task_block();
        }

        /* Get active clock configuration */
        clock_configuration =  _lpm_get_clock_configuration();
        /* Display new clock settings */
        display_clock_values(clock_configuration);

        /* wait for button press */
        wait_for_event();
        printf("\n***************  BSP_CLOCK_CONFIGURATION_1  **************\n");

        /* Switch clock configuration */
        if (CM_ERR_OK != _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_1))
        {
            printf("Cannot change clock configuration");
            _task_block();
        }

        /* Get active clock configuration */
        clock_configuration =  _lpm_get_clock_configuration();
        /* Display new clock settings */
        display_clock_values(clock_configuration);

        /* wait for button press */
        wait_for_event();
        printf("\n***************  BSP_CLOCK_CONFIGURATION_2  **************\n");

        /* Switch clock configuration */
        if (CM_ERR_OK != _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_2))
        {
            printf("Cannot change clock configuration");
            _task_block();
        }

        /* Get active clock configuration */
        clock_configuration =  _lpm_get_clock_configuration();
        /* Display new clock settings */
        display_clock_values(clock_configuration);
    }
}