/** * main * * The main function for the project. This function initializes the os, calls * init_tasks to initialize tasks (and possibly other objects), then starts the * OS. We should not return from os start. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF); log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL); stats_init(STATS_HDR(g_stats_gpio_toggle), STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32), STATS_NAME_INIT_PARMS(gpio_stats)); stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle)); conf_load(); log_reboot(HARD_REBOOT); init_tasks(); os_start(); /* os start should never return. If it does, this should be an error */ assert(0); return rc; }
/* ********************************************************************************************************* * * * Description: Initialize the DHCP client * Arguments : s - Socket number for the DHCP client ip_update - handler called when the leased IP address is updated ip_conflict - handler called when the leased IP address is conflict * p - pointer to parameter * Returns : None. * Note : ********************************************************************************************************* */ void init_dhcp_client(void) { uint8 txsize[MAX_SOCK_NUM] = {2,2,2,2,2,2,2,2}; uint8 rxsize[MAX_SOCK_NUM] = {2,2,2,2,2,2,2,2}; //uint8 ip_broadcast[4]={255,}; uint8 ip_0[4]={0,}; DHCP_XID = 0x12345678; memset(OLD_SIP,0,sizeof(OLD_SIP)); memset(DHCP_SIP,0,sizeof(DHCP_SIP)); memset(DHCP_REAL_SIP,0,sizeof(GET_SN_MASK)); iinchip_init(); setSHAR(ConfigMsg.mac); setSUBR(ip_0); setGAR(ip_0); setSIPR(ip_0); printf("mac=%02x:%02x:%02x:%02x:%02x:%02x\r\n",SRC_MAC_ADDR[0],SRC_MAC_ADDR[1],SRC_MAC_ADDR[2],SRC_MAC_ADDR[3],SRC_MAC_ADDR[4],SRC_MAC_ADDR[5]); sysinit(txsize, rxsize); //clear ip setted flag dhcp_state = STATE_DHCP_READY; #ifdef DHCP_DEBUG printf("init_dhcp_client:%u\r\n",SOCK_DHCP); #endif }
/** * main * * The main task for the project. This function initializes the packages, * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(void) { int rc; /* Initialize OS */ sysinit(); /* Initialize the blesplit log. */ log_register("blesplit", &blesplit_log, &log_console_handler, NULL, LOG_SYSLEVEL); /* Initialize the NimBLE host configuration. */ log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL, LOG_SYSLEVEL); ble_hs_cfg.reset_cb = blesplit_on_reset; ble_hs_cfg.sync_cb = blesplit_on_sync; ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /* Set the default device name. */ rc = ble_svc_gap_device_name_set("nimble-blesplit"); assert(rc == 0); conf_load(); /* * As the last thing, process events from default event queue. */ while (1) { os_eventq_run(os_eventq_dflt_get()); } return 0; }
/** * main * * The main task for the project. This function initializes the packages, * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(void) { int rc; /* Initialize OS */ sysinit(); /* Initialize the BLE host. */ log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL, LOG_SYSLEVEL); ble_hs_cfg.sync_cb = bleuart_on_sync; ble_hs_cfg.store_status_cb = ble_store_util_status_rr; rc = bleuart_gatt_svr_init(); assert(rc == 0); /* Set the default device name. */ rc = ble_svc_gap_device_name_set("Mynewt_BLEuart"); assert(rc == 0); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never exit */ return 0; }
/* ************************************************************************ * * * * C6747_init( ) ** * * Setup I2C, MSP430, & I2C GPIO Expander * * * * *********************************************************************** */ Int16 C6747_init( ) { sysinit(); TIMER0_TRC=0x0; return 0; }
int main(void) { sysinit(); lcd_init(); for(;;) { zputs(PSTR("Hello, world!")); wait(); zputc_rep(10, 'x'); wait(); zputs_rev("9876543210", 10); wait(); zput_dec(1); zput_dec(200); zput_dec(30000); zput_dec(-30000); wait(); zput_udec(1); zput_udec(200); zput_udec(30000); zput_udec(65535); wait(); zput_hex(1); zput_hex(0xeeee); wait(); } return 0; }
//主函数 void main() { //long int DAValue; sysinit(); IO_init(); while(1) { uchar Key_Value; init(); Key_Value = KeyDown(); switch(Key_Value) { case 0:display_8x16(1,105,jz0);delay(100);break; case 1:display_8x16(1,105,jz1);delay(100);break; case 2:display_8x16(1,105,jz2);delay(100);break; case 3:display_8x16(1,105,jz3);delay(100);break; case 4:display_8x16(1,105,jz4);delay(100);break; case 5:display_8x16(1,105,jz5);delay(100);break; case 6:display_8x16(1,105,jz6);delay(100);break; case 7:display_8x16(1,105,jz7);delay(100);break; case 8:display_8x16(1,105,jz8);delay(100);break; case 9:display_8x16(1,105,jz9);delay(100);break; case 10:display_8x16(1,105,jz10);delay(100);break; case 11:display_8x16(1,105,jz11);delay(100);break; case 12:display_8x16(1,105,jz12);delay(100);break; case 13:display_8x16(1,105,jz13);delay(100);break; case 14:display_8x16(1,105,jz14);delay(100);break; case 15:display_8x16(1,105,jz15);delay(100);break; default:delay(100); } //DA_Conver(DAValue); //加上滤波后,就可以形成模拟输出 delay_da(); } }
/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { /* Disable the watchdog timer */ wdog_disable(); /* Copy any vector or data sections that need to be in RAM */ common_startup(); /* Perform processor initialization */ sysinit(); printf("\n\n"); /* Determine the last cause(s) of reset */ outSRS(); /* Determine specific Kinetis device and revision */ cpu_identify(); /* Jump to main process */ main(); /* No actions to perform after this so wait forever */ while(1); }
void NET_Config(void) { unsigned char mac[6] = MY_NET_MAC; unsigned char sm[4] = MY_SUBNET; unsigned char gwip[4] = MY_NET_GWIP; unsigned char m_sip[4] = MY_SOURCEIP; //W5100 Chip Init iinchip_init(); //Set MAC Address setSHAR(mac); //Set Subnet Mask setSUBR(sm); //Set Gateway setGAR(gwip); //Set My IP setSIPR(m_sip); #ifdef __DEF_IINCHIP_INT__ //setIMR(0xEF); #endif sysinit(MY_NET_MEMALLOC, MY_NET_MEMALLOC); printSysCfg(); }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF); log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL); stats_init(STATS_HDR(g_stats_gpio_toggle), STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32), STATS_NAME_INIT_PARMS(gpio_stats)); stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle)); conf_load(); reboot_start(hal_reset_cause()); init_tasks(); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never exit */ return rc; }
int main() { //static unsigned int i = 0; WDTCTL = WDTPW | WDTHOLD; DCOCTL = CALDCO_16MHZ; BCSCTL1 = CALBC1_16MHZ; sysinit(16000000UL); Serial.begin(9600); pinMode(4, INPUT_PULLUP); attachInterrupt(4, myCallback, FALLING); pinMode(1, OUTPUT); digitalWrite(1, LOW); int c; while(1) { if (Serial.available()) { c = Serial.read(); if (c >= 0) Serial.write(c); } } return 0; }
void Set_network(void) { uint8 tmp_array[6]; uint8 i; ip_from = IP_FROM_DHCP; //DHCP // MAC ADDRESS for (i = 0 ; i < 6; i++) Config_Msg.Mac[i] = MAC[i]; setSHAR(Config_Msg.Mac); // Set DHCP Config_Msg.DHCP = Enable_DHCP; //Destination IP address for TCP Client //Set PTR and RCR register setRTR(2000); setRCR(5); //Init. TX & RX Memory size sysinit(txsize, rxsize); printf("\r\n----------------------------------------- \r\n"); printf("W5500E01-M3 \r\n"); printf("Network Configuration Information \r\n"); printf("----------------------------------------- "); getSHAR(tmp_array); printf("\r\nMAC : %.2X.%.2X.%.2X.%.2X.%.2X.%.2X\r\n", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3],tmp_array[4],tmp_array[5]); }
void main(int argc, char *argv[]) { INT8U err; #if 0 BSP_IntDisAll(); /* For an embedded target, disable all interrupts until we are ready to accept them */ #endif OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */ sysinit(); OSTaskCreate(AppStartTask,(void *)0,(OS_STK *)&AppStartTaskStk[0][TASK_STK_SIZE-1],2); OSTaskCreate(test2, (void *)0,(OS_STK *)&AppStartTaskStk[1][TASK_STK_SIZE-1],3); OSTaskCreate(test3, (void *)0,(OS_STK *)&AppStartTaskStk[2][TASK_STK_SIZE-1],4); OSTaskCreate(getStr, (void *)0,(OS_STK *)&AppStartTaskStk[3][TASK_STK_SIZE-1],5); #if OS_TASK_NAME_SIZE > 11 OSTaskNameSet(APP_TASK_START_PRIO, (INT8U *)"Start Task", &err); #endif #if OS_TASK_NAME_SIZE > 14 OSTaskNameSet(OS_IDLE_PRIO, (INT8U *)"uC/OS-II Idle", &err); #endif #if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0) OSTaskNameSet(OS_STAT_PRIO, "uC/OS-II Stat", &err); #endif OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */ }
/*------------------------------------------------------------------------ * nulluser -- initialize system and become the null process (id==0) *------------------------------------------------------------------------ */ nulluser() /* babysit CPU when no one is home */ { int userpid; console_dev = SERIAL0; /* set console to COM0 */ initevec(); kprintf("system running up!\n"); sysinit(); /* create a process to execute the user's main program */ /*****************************/ enable(); /* enable interrupts */ sprintf(vers, "PC Xinu %s", VERSION); kprintf("\n\n%s\n", vers); if (reboot++ < 1) kprintf("\n"); else kprintf(" (reboot %d)\n", reboot); kprintf("%d bytes real mem\n", (unsigned long) maxaddr+1); #ifdef DETAIL kprintf(" %d", (unsigned long) 0); kprintf(" to %d\n", (unsigned long) (maxaddr) ); #endif kprintf("%d bytes Xinu code\n", (unsigned long) ((unsigned long) &end - (unsigned long) start)); #ifdef DETAIL kprintf(" %d", (unsigned long) start); kprintf(" to %d\n", (unsigned long) &end ); #endif #ifdef DETAIL kprintf("%d bytes user stack/heap space\n", (unsigned long) ((unsigned long) maxaddr - (unsigned long) &end)); kprintf(" %d", (unsigned long) &end); kprintf(" to %d\n", (unsigned long) maxaddr); #endif kprintf("clock %sabled\n", clkruns == 1?"en":"dis"); userpid = create(main, INITSTK, INITPRIO, INITNAME, INITARGS); enable_paging((proctab[NULLPROC].pd->frm_num) * NBPG); enable(); resume(userpid); /* create a process to execute the user's main program */ while (TRUE) /* empty */; }
/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { //#ifdef DEBUG /* 关闭看门狗 */ wdog_disable(); //#endif /* 复制中断向量表、初始化数据、以__ramfunc声明的子函数复制到RAM区 */ common_startup(); /* CPU初始化,设置频率 */ sysinit(); #if (defined(DEBUG) && defined(DEBUG_PRINT)) printf("\n\n\t\t野火kinetis核心板测试程序\n"); printf("内核频率:%dMHz\t总线频率 :%dMHz\nflex频率:%dMHz \tflash频率:%dMHz\n\n",\ core_clk_mhz,core_clk_mhz/(mcg_div.bus_div+1),core_clk_mhz/(mcg_div.flex_div+1),core_clk_mhz/(mcg_div.flash_div+1)); /* Determine the last cause(s) of reset */ if (MC_SRSH & MC_SRSH_SW_MASK) printf("Software Reset\n"); if (MC_SRSH & MC_SRSH_LOCKUP_MASK) printf("Core Lockup Event Reset\n"); if (MC_SRSH & MC_SRSH_JTAG_MASK) printf("JTAG Reset\n"); if (MC_SRSL & MC_SRSL_POR_MASK) printf("Power-on Reset\n"); if (MC_SRSL & MC_SRSL_PIN_MASK) printf("External Pin Reset\n"); if (MC_SRSL & MC_SRSL_COP_MASK) printf("Watchdog(COP) Reset\n"); if (MC_SRSL & MC_SRSL_LOC_MASK) printf("Loss of Clock Reset\n"); if (MC_SRSL & MC_SRSL_LVD_MASK) printf("Low-voltage Detect Reset\n"); if (MC_SRSL & MC_SRSL_WAKEUP_MASK) printf("LLWU Reset\n"); /* 这两个数组的地址 在 链接器Linker文件,即ICF文件 定义 */ extern uint32 __VECTOR_TABLE[]; extern uint32 __VECTOR_RAM[]; /* 检测是否需要 复制中断向量表,即可以知道是ROM启动还是RAM启动*/ printf("\n野火Kinetis开发板启动方式:"); if (__VECTOR_RAM != __VECTOR_TABLE) printf("flash启动\n"); else printf("SRAM启动\n"); /* Determine specific Kinetis device and revision */ cpu_identify(); #endif //DUBUG && DEBUG_PRINT /* 跳进main函数 */ main(); /* 保证CPU不会停止执行 */ while(1); }
void nulluser() { struct memblk *memptr; /* Ptr to memory block */ uint32 free_mem; /* Total amount of free memory */ /* Initialize the system */ sysinit(); kprintf("\n\r%s\n\n\r", VERSION); /* Output Xinu memory layout */ free_mem = 0; for (memptr = memlist.mnext; memptr != NULL; memptr = memptr->mnext) { free_mem += memptr->mlength; } kprintf("%10d bytes of free memory. Free list:\n", free_mem); for (memptr=memlist.mnext; memptr!=NULL;memptr = memptr->mnext) { kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)memptr, ((uint32)memptr) + memptr->mlength - 1); } kprintf("%10d bytes of Xinu code.\n", (uint32)&etext - (uint32)&text); kprintf(" [0x%08X to 0x%08X]\n", (uint32)&text, (uint32)&etext - 1); kprintf("%10d bytes of data.\n", (uint32)&ebss - (uint32)&data); kprintf(" [0x%08X to 0x%08X]\n\n", (uint32)&data, (uint32)&ebss - 1); /* Enable interrupts */ enable(); /* Create a ready list for processes */ int32 i; for (i=0; i < 10; ++i) { readylist[i] = newqueue(); } /* Create a process to execute function main() */ resume ( create((void *)main, INITSTK, INITPRIO, "Main process", 0, NULL)); /* Become the Null process (i.e., guarantee that the CPU has */ /* something to run when no other process is ready to execute) */ while (TRUE) { ; /* Do nothing */ } }
/** **=========================================================================== ** Reset handler **=========================================================================== */ void __init_hardware() { SCB_VTOR = (uint32_t)__vector_table; /* Set the interrupt vector table position */ // Disable the Watchdog because it may reset the core before entering main(). SIM_COPC = KINETIS_WDOG_DISABLED_CTRL; sysinit(); }
int main(void) { sysinit(); boot_serial_test(); return tu_any_failed; }
void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway, uint8_t *subnet) { iinchip_init(); sysinit(); setSHAR(mac); setSIPR(ip); setGAR(gateway); setSUBR(subnet); }
void nulluser() { struct memblk *memptr; /* Ptr to memory block */ uint32 free_mem; /* Total amount of free memory */ /* Initialize the system */ sysinit(); /* Output Xinu memory layout */ free_mem = 0; for (memptr = memlist.mnext; memptr != NULL; memptr = memptr->mnext) { free_mem += memptr->mlength; } kprintf("%10d bytes of free memory. Free list:\n", free_mem); for (memptr=memlist.mnext; memptr!=NULL;memptr = memptr->mnext) { kprintf(" [0x%08X to 0x%08X]\n", (uint32)memptr, ((uint32)memptr) + memptr->mlength - 1); } kprintf("%10d bytes of Xinu code.\n", (uint32)&etext - (uint32)&text); kprintf(" [0x%08X to 0x%08X]\n", (uint32)&text, (uint32)&etext - 1); kprintf("%10d bytes of data.\n", (uint32)&ebss - (uint32)&data); kprintf(" [0x%08X to 0x%08X]\n\n", (uint32)&data, (uint32)&ebss - 1); /* Enable interrupts */ enable(); /* Initialize the network stack and start processes */ net_init(); /* Create a process to finish startup and start main */ resume(create((void *)startup, INITSTK, INITPRIO, "Startup process", 0, NULL)); /* Become the Null process (i.e., guarantee that the CPU has */ /* something to run when no other process is ready to execute) */ while (TRUE) { /* Halt until there is an external interrupt */ asm volatile ("hlt"); } }
void nulluser() { struct memblk *memptr; /* Ptr to memory block */ uint32 free_mem; /* Total amount of free memory */ /* Initialize the system */ sysinit(); kprintf("\n\r%s\n\n\r", VERSION); /* Output Xinu memory layout */ free_mem = 0; for (memptr = memlist.mnext; memptr != NULL; memptr = memptr->mnext) { free_mem += memptr->mlength; } kprintf("%10d bytes of free memory. Free list:\n", free_mem); for (memptr=memlist.mnext; memptr!=NULL;memptr = memptr->mnext) { kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)memptr, ((uint32)memptr) + memptr->mlength - 1); } kprintf("%10d bytes of Xinu code.\n", (uint32)&etext - (uint32)&text); kprintf(" [0x%08X to 0x%08X]\n", (uint32)&text, (uint32)&etext - 1); kprintf("%10d bytes of data.\n", (uint32)&ebss - (uint32)&data); kprintf(" [0x%08X to 0x%08X]\n\n", (uint32)&data, (uint32)&ebss - 1); /* Enable interrupts */ enable(); kprintf("\nHello World!\n"); kprintf("\nI'm the first XINU app and running function main() in system/main.c.\n"); kprintf("\nI was created by nulluser() in system/initialize.c using create().\n"); kprintf("\nMy creator will turn itself into the do-nothing null process.\n"); kprintf("\nI will create a second XINU app that runs shell() in shell/shell.c as an example.\n"); kprintf("\nYou can do something else, or do nothing; it's completely up to you.\n"); kprintf("\n...creating a shell\n"); kprintf("My name's Dhruv Subramanian\n"); kprintf("Purdue Id : 0026458203\n"); /* Create a process to execute function main() */ resume(create((void *)main,INITSTK,INITPRIO,"Main process",0,NULL)); while(TRUE){ ; } }
//-------------------------------------------------------------------------* //函数名: start * //功 能: 系统启动 * //参 数: 无 * //说 明: 无 * //-------------------------------------------------------------------------* void start(void) { //关闭看门狗 wdog_disable(); //复制中断向量表到RAM中 common_startup(); //系统设置 sysinit(); //进入主函数 main(); }
/*------------------------------------------------------------------------ * nulluser -- initialize system and become the null process (id==0) *------------------------------------------------------------------------ */ int nulluser() /* babysit CPU when no one home */ { // int userpid; console_dev = SERIAL0; initevec(); sysinit(); sprintf(vers, "Xinu Version %s", VERSION); kprintf("\n\n%s\n", vers); if (reboot++ < 1) kprintf("\n"); else kprintf("(reboot #%d)\n", reboot); kprintf("%d bytes real mem\n", (unsigned long) maxaddr+1); #ifdef DETAIL kprintf(" %d", (unsigned long) 0); kprintf(" to %d\n", (unsigned long) (maxaddr) ); #endif kprintf("%d bytes Xinu code\n", (unsigned long) ((unsigned long) &end - (unsigned long) start)); #ifdef DETAIL kprintf(" %d", (unsigned long) start); kprintf(" to %d\n", (unsigned long) &end ); #endif #ifdef DETAIL kprintf("%d bytes user stack/heap space\n", (unsigned long) ((unsigned long) maxaddr - (unsigned long) &end)); kprintf(" %d", (unsigned long) &end); kprintf(" to %d\n", (unsigned long) maxaddr); #endif kprintf("clock %sabled\n", clkruns == 1?"en":"dis"); enable(); /* enable interrupts */ open(CONSOLE, console_dev, 0); /* create a process to execute the user's main program */ resume(create((int *)main,INITSTK,INITPRIO,INITNAME,INITARGS)); while (TRUE) /* empty */; dskend(&devtab[DISK0]); dskend(&devtab[DISK1]); }
/*------------------------------------------------------------------------ * nulluser -- initialize system and become the null process (id==0) *------------------------------------------------------------------------ */ nulluser() /* babysit CPU when no one home */ { int userpid; initevec(); sysinit(); /* associate CONSOLE with a tty */ open(CONSOLE, KBMON, 0); /* open(CONSOLE, SERIAL0); */ sprintf(vers, "Xinu Version %s", VERSION); kprintf("\n\n%s\n", vers); if (reboot++ < 1) kprintf("\n"); else kprintf(" (reboot %d)\n", reboot); kprintf("%d bytes real mem\n", (unsigned long) maxaddr+1); #ifdef DETAIL kprintf(" %d", (unsigned long) 0); kprintf(" to %d\n", (unsigned long) (maxaddr) ); #endif kprintf("%d bytes Xinu code\n", (unsigned long) ((unsigned long) &end - (unsigned long) start)); #ifdef DETAIL kprintf(" %d", (unsigned long) start); kprintf(" to %d\n", (unsigned long) &end ); #endif #ifdef DETAIL kprintf("%d bytes user stack/heap space\n", (unsigned long) ((unsigned long) maxaddr - (unsigned long) &end)); kprintf(" %d", (unsigned long) &end); kprintf(" to %d\n", (unsigned long) maxaddr); #endif kprintf("clock %sabled\n", clkruns == 1?"en":"dis"); enable(); /* enable interrupts */ /* create a process to execute the user's main program */ userpid = create(main,INITSTK,INITPRIO,INITNAME,INITARGS); /* start the network */ resume(create(netstart,NETSTK,NETPRI,NETNAM,NETARGC,userpid)); while (TRUE) /* empty */; }
void nulluser() { struct memblk *memptr; /* Ptr to memory block */ uint32 free_mem; /* Total amount of free memory */ /* Initialize the system */ sysinit(); kprintf("\n\r%s\n\n\r", VERSION); /* Output Xinu memory layout */ free_mem = 0; for (memptr = memlist.mnext; memptr != NULL; memptr = memptr->mnext) { free_mem += memptr->mlength; } kprintf("%10d bytes of free memory. Free list:\n", free_mem); for (memptr=memlist.mnext; memptr!=NULL;memptr = memptr->mnext) { kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)memptr, ((uint32)memptr) + memptr->mlength - 1); } kprintf("%10d bytes of Xinu code.\n", (uint32)&etext - (uint32)&text); kprintf(" [0x%08X to 0x%08X]\n", (uint32)&text, (uint32)&etext - 1); kprintf("%10d bytes of data.\n", (uint32)&ebss - (uint32)&data); kprintf(" [0x%08X to 0x%08X]\n\n", (uint32)&data, (uint32)&ebss - 1); /* Enable interrupts */ enable(); /* * Prints the welcome message */ mywelcomemsg(); /* Create a process to execute function main() */ kprintf("\n Just before main creation"); resume ( create((void *)main, INITSTK, 11, "Main process", 0, NULL)); /* Become the Null process (i.e., guarantee that the CPU has */ /* something to run when no other process is ready to execute) */ while (TRUE) { //pause(); //Alternate way to idle insteaad of using an infinite while loop ; /* Do nothing */ } }
void nulluser(void) { kprintf("\n\r%s\n\n\r", VERSION); sysinit(); /* Output Xinu memory layout */ kprintf("%10d bytes physical memory.\r\n", (uint32)maxheap - (uint32)addressp2k(0)); kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)addressp2k(0), (uint32)maxheap - 1); kprintf("%10d bytes reserved system area.\r\n", (uint32)_start - (uint32)addressp2k(0)); kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)addressp2k(0), (uint32)_start - 1); kprintf("%10d bytes Xinu code.\r\n", (uint32)&_end - (uint32)_start); kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)_start, (uint32)&_end - 1); kprintf("%10d bytes stack space.\r\n", (uint32)minheap - (uint32)&_end); kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)&_end, (uint32)minheap - 1); kprintf("%10d bytes heap space.\r\n", (uint32)maxheap - (uint32)minheap); kprintf(" [0x%08X to 0x%08X]\r\n\r\n", (uint32)minheap, (uint32)maxheap - 1); /* Enable interrupts */ enable(); /* Create a process to execute function main() */ resume(create ((void *)main, INITSTK, INITPRIO, "Main process", 0, NULL)); /* Become the Null process (i.e., guarantee that the CPU has */ /* something to run when no other process is ready to execute) */ /*CS 354 Spring 2012*/ /*Lab 2: Round Robin Scheduling*/ /*Created by : Wilson Sumanang Date : 12 February 2012*/ while (TRUE) { kprintf("N"); /* do nothing */ } }
void nulluser(void) { sysinit(); kprintf("\n\r%s\n\n\r", VERSION); /* Output Xinu memory layout */ kprintf("%10d bytes physical memory.\n", (uint32)maxheap - (uint32)0); kprintf(" [0x%08X to 0x%08X]\r\n", (uint32)0, (uint32)maxheap - 1); kprintf("%10d bytes of Xinu code.\n", (uint32)&etext - (uint32)0); kprintf(" [0x%08X to 0x%08X]\n", (uint32)0, (uint32)&etext - 1); kprintf("%10d bytes of data.\n", (uint32)&end - (uint32)&etext); kprintf(" [0x%08X to 0x%08X]\n", (uint32)&etext, (uint32)&end - 1); if ( (char *)minheap < HOLESTART) { kprintf("%10d bytes of heap space below 640K.\n", (uint32)HOLESTART - (uint32)roundmb(minheap)); } if ( (char *)maxheap > HOLEEND ) { kprintf("%10d bytes of heap space above 1M.\n", (uint32)maxheap - (uint32)HOLEEND); kprintf(" [0x%08X to 0x%08X]\n", (uint32)HOLEEND, (uint32)truncmb(maxheap) - 1); } /* Enable interrupts */ enable(); /* Start the network */ resume(create((void *)netin, NETSTK, NETPRIO, "netin", 0)); /* Create a process to execute function main() */ resume ( create((void *)main, INITSTK, INITPRIO, "Main process", 2, 0, NULL)); /* Become the Null process (i.e., guarantee that the CPU has */ /* something to run when no other process is ready to execute) */ while (TRUE) { ; /* do nothing */ } }
void Set_network(void) { uint8 tmp_array[6]; uint8 i; // MAC ADDRESS for (i = 0 ; i < 6; i++) Config_Msg.Mac[i] = MAC[i]; // Local IP ADDRESS Config_Msg.Lip[0] = IP[0]; Config_Msg.Lip[1] = IP[1]; Config_Msg.Lip[2] = IP[2]; Config_Msg.Lip[3] = IP[3]; // GateWay ADDRESS Config_Msg.Gw[0] = GateWay[0]; Config_Msg.Gw[1] = GateWay[1]; Config_Msg.Gw[2] = GateWay[2]; Config_Msg.Gw[3] = GateWay[3]; // Subnet Mask ADDRESS Config_Msg.Sub[0] = SubNet[0]; Config_Msg.Sub[1] = SubNet[1]; Config_Msg.Sub[2] = SubNet[2]; Config_Msg.Sub[3] = SubNet[3]; setSHAR(Config_Msg.Mac); // setSUBR(Config_Msg.Sub); saveSUBR(Config_Msg.Sub); setGAR(Config_Msg.Gw); setSIPR(Config_Msg.Lip); // Set DHCP Config_Msg.DHCP = Enable_DHCP; //Destination IP address for TCP Client Chconfig_Type_Def.destip[0] = Dest_IP[0]; Chconfig_Type_Def.destip[1] = Dest_IP[1]; Chconfig_Type_Def.destip[2] = Dest_IP[2]; Chconfig_Type_Def.destip[3] = Dest_IP[3]; Chconfig_Type_Def.port = Dest_PORT; //Set PTR and RCR register setRTR(6000); setRCR(3); //Init. TX & RX Memory size sysinit(txsize, rxsize); printf("\r\n----------------------------------------- \r\n"); printf("W5200E01-M3 \r\n"); printf("Network Configuration Information \r\n"); printf("----------------------------------------- "); printf("\r\nMAC : %.2X.%.2X.%.2X.%.2X.%.2X.%.2X", IINCHIP_READ(SHAR0+0),IINCHIP_READ(SHAR0+1),IINCHIP_READ(SHAR0+2), IINCHIP_READ(SHAR0+3),IINCHIP_READ(SHAR0+4),IINCHIP_READ(SHAR0+5)); getSIPR (tmp_array); printf("\r\nIP : %d.%d.%d.%d", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3]); getSUBR(tmp_array); printf("\r\nSN : %d.%d.%d.%d", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3]); getGAR(tmp_array); printf("\r\nGW : %d.%d.%d.%d", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3]); }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); rc = conf_register(&test_conf_handler); assert(rc == 0); cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF); log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL); stats_init(STATS_HDR(g_stats_gpio_toggle), STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32), STATS_NAME_INIT_PARMS(gpio_stats)); stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle)); flash_test_init(); conf_load(); log_reboot(hal_reset_cause()); init_tasks(); /* If this app is acting as the loader in a split image setup, jump into * the second stage application instead of starting the OS. */ #if MYNEWT_VAL(SPLIT_LOADER) { void *entry; rc = split_app_go(&entry, true); if(rc == 0) { hal_system_restart(entry); } } #endif /* * As the last thing, process events from default event queue. */ while (1) { os_eventq_run(os_eventq_dflt_get()); } }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); rc = conf_register(&test_conf_handler); assert(rc == 0); cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF); log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL); /* Initialize the OIC */ log_register("oic", &oc_log, &log_console_handler, NULL, LOG_SYSLEVEL); stats_init(STATS_HDR(g_stats_gpio_toggle), STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32), STATS_NAME_INIT_PARMS(gpio_stats)); stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle)); conf_load(); reboot_start(hal_reset_cause()); #if MYNEWT_VAL(SPLIT_LOADER) { void *entry; rc = split_app_go(&entry, true); if(rc == 0) { hal_system_start(entry); } } #endif init_tasks(); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never returns */ return rc; }