gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/power.cbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      power.c
   16:  *      power-saving function
   17:  */
   18: 
   19: #include "kernel.h"
   20: #include "check.h"
   21: 
   22: /*
   23:  * Number of times for disabling power-saving mode switch
   24:  *      If it is 0, the mode switch is enabled.
   25:  */
   26: EXPORT UINT     knl_lowpow_discnt = 0;
   27: 
   28: #if TK_SUPPORT_LOWPOWER
   29: /*
   30:  * Set Power-saving mode
   31:  */
   32: SYSCALL ER tk_set_pow( UINT pwmode )
   33: {
   34:         ER     ercd = E_OK;
   35: 
   36:         CHECK_INTSK();
   37: 
   38:         BEGIN_CRITICAL_SECTION;
   39: 
   40:         switch ( pwmode ) {
   41:           case TPW_DOSUSPEND:
   42:                 off_pow();
   43:                 break;
   44:           case TPW_DISLOWPOW:
   45:                 if ( knl_lowpow_discnt >= LOWPOW_LIMIT ) {
   46:                         ercd = E_QOVR;
   47:                 } else {
   48:                         knl_lowpow_discnt++;
   49:                 }
   50:                 break;
   51:           case TPW_ENALOWPOW:
   52:                 if ( knl_lowpow_discnt <= 0 ) {
   53:                         ercd = E_OBJ;
   54:                 } else {
   55:                         knl_lowpow_discnt--;
   56:                 }
   57:                 break;
   58: 
   59:           default:
   60:                 ercd = E_PAR;
   61:         }
   62:         END_CRITICAL_SECTION;
   63: 
   64:         return ercd;
   65: }
   66: 
   67: #endif  /* TK_SUPPORT_LOWPOWER */
   68: 
   69: 
   70: