gonzui


Format: Advanced Search

mtkernel_3/kernel/sysdepend/iote_m367/hw_setting.cbare sourcepermlink (0.03 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.02
    4:  *
    5:  *    Copyright (C) 2006-2020 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.2.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2020/10/21 .
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: #include <sys/machine.h>
   15: #ifdef IOTE_M367
   16: 
   17: /*
   18:  *      hw_setting.c (M367 IoT-Engine)
   19:  *      startup / shoutdown processing for hardware
   20:  */
   21: 
   22: #include "kernel.h"
   23: #include <tm/tmonitor.h>
   24: 
   25: #include "sysdepend.h"
   26: 
   27: /* 
   28:  * Setup pin functions Tadle
   29:  */
   30: typedef struct {
   31:         UW     addr;
   32:         UW     data;
   33: } T_SETUP_REG;
   34: 
   35: LOCAL const T_SETUP_REG setup_regs[] = {
   36: 
   37: #if !USE_SDEV_DRV       // Do not use device sample driver
   38:         //  Debugger I/F : PA0 ~ PA4
   39:         //  Serial debug I/F : PA4 -> RTS5, PA5 -> RXD5, PA6 -> TXD5, PA7 -> CTS5
   40:         {PORT_FR1(A),  0x0000000F},
   41:         {PORT_FR2(A),  0x000000F0},
   42:         {PORT_PUP(A),  0x0000000A},
   43:         {PORT_CR(A),   0x00000053},
   44:         {PORT_IE(A),   0x000000AE},
   45: 
   46: #else                   // Use the device sample driver
   47:         //  Debugger I/F : PA0 ~ PA4
   48:         //  Serial debug I/F : PA4 -> RTS5, PA5 -> RXD5, PA6 -> TXD5, PA7 -> CTS5
   49:         {PORT_FR1(A),  0x0000000F},
   50:         {PORT_FR2(A),  0x000000F0},
   51:         {PORT_PUP(A),  0x0000000A},
   52:         {PORT_CR(A),   0x00000053},
   53:         {PORT_IE(A),   0x000000AE},
   54: 
   55:         // I2C I/F : PF6 -> SCL1, PF7 -> SDA1
   56:         {PORT_FR4(F),  0x000000c0},
   57:         {PORT_OD(F),   0x000000c0},
   58:         {PORT_CR(F),   0x000000c0},
   59:         {PORT_IE(F),   0x000000C0},
   60: 
   61:         // PL1 P-OUT   I2C_ENABLE
   62:         {PORT_DATA(L), 0x00000000},
   63:         {PORT_CR(L),   0x00000002},
   64: 
   65: #endif /* USE_SDEV_DRV */
   66: 
   67:         {0, 0}
   68: };
   69: 
   70: /*
   71:  * Startup Device
   72:  */
   73: EXPORT void knl_startup_hw(void)
   74: {
   75:         const T_SETUP_REG      *p;
   76: 
   77:         /* Disable Watch Dog Timer */
   78:         *(_UW*)WDOG_WDMOD &= ~0x00000080;
   79:         *(_UW*)WDOG_WDCR = WDOG_WDCR_DISABLE;
   80: 
   81:         startup_clock(PLL_MODE_6X);
   82: 
   83:         /* Setup Pin Function */
   84:         for(p = setup_regs; p->addr != 0; p++) {
   85:                 *(_UW*)(p->addr) = p->data;
   86:         }
   87: }
   88: 
   89: #if USE_SHUTDOWN
   90: /*
   91:  * Shutdown device
   92:  */
   93: EXPORT void knl_shutdown_hw( void )
   94: {
   95:         disint();
   96:         while(1);
   97: }
   98: #endif /* USE_SHUTDOWN */
   99: 
  100: /*
  101:  * Re-start device
  102:  *      mode = -1            reset and re-start        (Reset -> Boot -> Start)
  103:  *      mode = -2            fast re-start             (Start)
  104:  *      mode = -3            Normal re-start           (Boot -> Start)
  105:  */
  106: EXPORT ER knl_restart_hw( W mode )
  107: {
  108:         switch(mode) {
  109:         case -1: /* Reset and re-start */
  110:                 SYSTEM_MESSAGE("\n<< SYSTEM RESET & RESTART >>\n");
  111:                 return E_NOSPT;
  112:         case -2: /* fast re-start */
  113:                 SYSTEM_MESSAGE("\n<< SYSTEM FAST RESTART >>\n");
  114:                 return E_NOSPT;
  115:         case -3: /* Normal re-start */
  116:                 SYSTEM_MESSAGE("\n<< SYSTEM RESTART >>\n");
  117:                 return E_NOSPT;
  118:         default:
  119:                 return E_PAR;
  120:         }
  121: }
  122: 
  123: 
  124: #endif /* IOTE_M367 */