⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 start.c

📁 CMX990 demonstration board (DE9901)
💻 C
字号:
/****h* DE9901/START
* FILE NAME
*  start.c
* COPYRIGHT
*  (c) 2004-2005 Mobitex Technology AB - All rights reserved
* 
*  Redistribution and use in source and binary forms, with or without modification,
*  are permitted provided that the following conditions are met:
*  * 1. Redistributions of source code must retain the above copyright notice,
*       this list of conditions and the following disclaimer. 
*  * 2. Redistributions in binary form must reproduce the above copyright notice,
*       this list of conditions and the following disclaimer in the documentation
*       and/or other materials provided with the distribution.
*  * 3. The name Mobitex Technology AB may not be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY MOBITEX TECHNOLOGY AB "AS IS" AND ANY EXPRESS OR
*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
*  SHALL MOBITEX TECHNOLOGY AB BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
*  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
*  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
*  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
*  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
*  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* AUTHOR
*  MPN/Kjell Westerberg
* HISTORY
*  Changes in the file are recorded in this list.
*   Ver:  Date:       Responsible:         Comment:
*   R1A01 2005-01-17  Kjell Westerberg     Approved.
*   R1A05 2005-03-17  Kjell Westerberg     Approved.
* DESCRIPTION
*  This is the startup file. The cyg_user_start function
*  is used to setup from eCos and the main function is called
*  as the first thread from eCos when the scheduler is started.
*  The main thread starts with a priority of 10.
*  Main is responsible to initialize the rest of the system
*  and to start all other threads.
***/

#include "hel.h"
#include "mbxtcl.h"


/* main is the default thread that is run by eCos. */
/* It will start the rest of the system. */
int main(int argc, char *argv[]) {

  /* Init CPU load measure before any other threads are started. */
  CpuLoadInit();

  printf("DE9901 main program started.\n");
  

  /* Init print function on MASC port. */
  PrintInit();

  PrintEvent("DE9901 started", 0, 0);


  /* Init digital IO */
  BINIO_Init();
  
  /* Init TCL interpreter */
  MbxTclInit();
  
  /* Set a high priority on the main thread. */
  /* The main thread is kicking the watchdog. */
  cyg_thread_set_priority(cyg_thread_self(), MAIN_THREAD_PRIO);

  /* Init CMX990 */
  CMX_Init();
  
  while (1) {
    WD_Kick();
    //Print("WD\n");
    cyg_thread_delay(250);
    if (mbxTclRun == FALSE) {
      /* Check if we shall start TCL. */
      MbxTclStartCheck();
    }
  }
}

/* We install our own startup routine which starts the whole system. */
void cyg_user_start(void) {

#ifndef DISABLE_WD
  WD_Enable();
  diag_printf("Watchdog enabled!\n");
#endif

#if 0
  diag_printf("u8 size: %d\n", sizeof(u8));
  diag_printf("s8 size: %d\n", sizeof(s8));
  diag_printf("u16 size: %d\n", sizeof(u16));
  diag_printf("s16 size: %d\n", sizeof(s16));
  diag_printf("u32 size: %d\n", sizeof(u32));
  diag_printf("s32 size: %d\n", sizeof(s32));
  diag_printf("u64 size: %d\n", sizeof(u64));
  diag_printf("s64 size: %d\n", sizeof(s64));
  diag_printf("r32 size: %d\n", sizeof(r32));
  diag_printf("r64 size: %d\n", sizeof(r64));
  diag_printf("bool size: %d\n", sizeof(bool));
  diag_printf("sbool size: %d\n", sizeof(sbool));
  diag_printf("void* size: %d\n", sizeof(void*));
  diag_printf("int size: %d\n", sizeof(int));
  diag_printf("char size: %d\n", sizeof(char));
  diag_printf("short size: %d\n", sizeof(short));
  diag_printf("long size: %d\n", sizeof(long));
#endif
  /*len = sizeof(ttyInfo);
    err = cyg_io_get_config(ttyHandl[1], CYG_IO_GET_CONFIG_TTY_INFO, &ttyInfo, &len);
  if (err) {
    diag_printf("ERROR get config tty %d.\n", err);
    }
  diag_printf("tty data (%d): %d %d\n", len, ttyInfo.tty_out_flags, ttyInfo.tty_in_flags);
  */

  /*
  len = sizeof(serInfo);
  err = cyg_io_get_config(ttyHandl[1], CYG_IO_GET_CONFIG_SERIAL_INFO, &serInfo, &len);
  if (err) {
    diag_printf("ERROR get config serial %d.\n", err);
  }
  diag_printf("serial data (%d): %d %d %d %d %d\n", len, serInfo.baud, serInfo.stop, serInfo.parity, serInfo.word_length, serInfo.flags);
  */
  diag_printf("System init ready.\n");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -