int main(){ init_serial(); printk("f**k\n"); //mem_test(); blue_screen(); hlt(); return 0; }
int main(void){ char i = 0; char temp; lcd_init(); init_serial(); char buf[16]={0}; while(1){ while((UCSR0A&(1<<RXC0)) == 0); // Wait for character input temp = UDR0; while((UCSR0A&(1<<UDRE0)) == 0); // Wait for release of input if(temp == ','){ buf[15] = '\0'; my_send_string(buf); printLCD(buf); for(i=0; i<16; i++){ buf[i] = 0; } i = 0; //Reset indexer } else{ buf[i] = temp; i++; } } }
int main(int argc, char ** argv) { struct sigaction sa; serialport = open(SERIALDEVICE, O_RDWR | O_NOCTTY); if (serialport < 0) { perror(SERIALDEVICE); exit(EXIT_FAILURE); } init_serial(serialport); send_init_commands(serialport); // Signal handler sa.sa_handler = shutdown_server; sigemptyset(&sa.sa_mask); if (sigaction(SIGINT, &sa, NULL) == -1) { exit(EXIT_FAILURE); } init_server(); fprintf(stderr, "Ready to serve\n"); get_server_data_loop(&on_socket_data); fprintf(stderr, "Shutting down\n"); send_shutdown_command(serialport); close(serialport); exit(EXIT_SUCCESS); }
BOOL RELAYER_start(int serial_port, int serial_speed) { TRC(); if (EM_BT_init()){ DBG("BT device power on success\n"); } else{ ERR("BT device power on failed\n"); return FALSE; } serial_fd = init_serial(serial_port, serial_speed); if (serial_fd < 0){ ERR("Initialize serial port to PC failed\n"); EM_BT_deinit(); return FALSE; } signal(SIGRTMIN, thread_exit); /* Create Tx monitor thread */ pthread_create(&txThread, NULL, bt_tx_monitor, (void*)NULL); /* Create RX monitor thread */ pthread_create(&rxThread, NULL, bt_rx_monitor, (void*)NULL); DBG("BT Relayer mode start\n"); return TRUE; }
int main(void) { /* Use the hardware (Timer1) to generate a fast (125kHz) pwm * that will drive the buck converter on/off. * * Initialize the PWM value *before*. */ redcpwm = 0x00; greencpwm = 0x00; bluecpwm= 0xFF; /* inverted */ init_current_loop(); /* Initializes the ADC */ init_adc(); /* Run a much slower (122Hz) PWM (based on Timer0 interrupts) */ init_timer0(); /* Initializes the serial port and prepare to receive data */ init_serial(); /* Enable interrupts and let the show begin! */ sei(); while(1) { } }
int main(int argc, char **argv) { int ret = 0; char buf[100] = {0}; int serial_fd; char * uart_dev; char * data_file; int data_fd; char * send_file_name = "file"; char * recv_file_name = "file_recv"; int loopback; int receive; int send; loopback = 0; receive = 0; send = 1; if (argc == 1) { print_usage(argv[0]); } if (argc > 1) { receive = 1; } //sighandler_t signal(int signum, sighandler_t handler); signal(SIGINT, &sighandler); init_ref_buf(0); serial_fd = init_serial(); if (receive) { ret = uart_recv_256( serial_fd, NULL); if (1 || ret) { goto failed; } } if (send) { ret = uart_send_256(serial_fd, send_file_name); if (ret) { goto failed; } } printf("sleep1\n"); sleep(1); //printf("%s\n", buf); failed: close(serial_fd); return 0; }
static void initialize_devices(void) { init_timer(); init_serial(); init_stdio(); sei(); }
int main() { init_timer(); init_serial(); init_SPI(); init_ATX_power(); sei(); enable_ATX_power(); delay_milliseconds(100); next_update_time = millisecond_time() + FRAME_MS; SPI_write_byte(0x00); while (true) { const uint8_t b1 = MAX_BRIGHTNESS / 4; const uint8_t b2 = MAX_BRIGHTNESS * 3 / 4; const uint8_t b3 = MAX_BRIGHTNESS; ramp(0, b1, set_LEDs_white); ramp(b1, 0, set_LEDs_white); ramp(0, b2, set_LEDs_CMY); ramp(b2, 0, set_LEDs_CMY); ramp(0, b3, set_LEDs_RGB); ramp(b3, 0, set_LEDs_RGB); } }
void init() { ResetReason = MCUSR; cli(); WDT_off(); // Turn off until initialization is done and we can pet the dog. init_leds (); init_buttons(); init_limit_switches(); init_motor(); float mBaseFrequencyHerz = 500.0; // 4khz pwm_init( mBaseFrequencyHerz, TRUE ); init_serial(); init_configuration(); // read_configuration_and_set(); // init_adc(); // start_sampling(); encoder_init(); // pot_init (); WDT_Prescaler_Change(); //delay(100000); // ~ 2 sec //read_cal(); // Read everything including motor stops. sei(); //OS_InitTask(); }
void main() { init_serial(); LCD_Init(); while(1){ if(!(switch_value == old_value)) { old_value = switch_value; LCD_CmdWrite(0x80); LCD_StringWrite("EE337", 5); sendStringForTx("EE337", 5); } else LCD_Init(); //LCD_StringWrite(" BCD", 4); delay_ms(500); /*SBUF = 'A'; while(!transmit_completed); transmit_completed = 0; toggle_bit=0;*/ } }
void main() { init_serial(); LCD_Init(); //P1^4 = 1; //SCON |= 0x10; while(1){ switch_value = P1 &=0x0F; if(!(switch_value == old_value)) { old_value = P1 &= 0x0F; LCD_CmdWrite(0x80); LCD_StringWrite("AAAAAAAAAA", 10); send_string("AAAAAAAAAA", 10); } else LCD_Init(); delay_ms(500); /*SBUF = 'A'; while(!transmit_completed); transmit_completed = 0; toggle_bit=0;*/ } }
/*---------------------------------------------------------------------------*/ int main(void) { uint16_t plen; init_serial(); init_mac(mymac); init_udp_or_www_server(mymac,myip); enc28j60Init(mymac); enc28j60PhyWrite(PHLCON,0x476); enc28j60EnableBroadcast(); xprintf(PSTR("Hello World!\r\n")); /* main loop */ while(1) { /* poll hardware ethernet buffer */ plen = enc28j60PacketReceive(BUFFER_SIZE,buf); /* any new message? */ if(plen > 0) { checkBootloaderCondition(buf); } } return 0; }
/* \brief Handles archetecture-specific initialization for i586. * * This function initializes various tables, paging, and the initial heap, * various timers, then passes the locations of modules and elf info (if any) * to \ref kmain. * * @param mboot The multiboot header passed by a compliant bootloader. * @param blarg At the moment, the initial stack placement. This parameter * is unused and will be removed soon. * @param magic The multiboot header checksum. */ void arch_init( multiboot_header_t *mboot, int blarg, int magic ){ void *modules = 0; void *elfinfo = 0; init_serial( ); // Take care of multiboot stuff... if ( magic != 0x2badb002 ) panic( "Need multiboot-compliant bootloader to boot Helix kernel.\n" ); if ( mboot->flags & MULTIBOOT_FLAG_ELF ) elfinfo = &mboot->elf_headers; if ( mboot->flags & MULTIBOOT_FLAG_MODS && mboot->mods_count ){ modules = *(int **)mboot->mods_addr; early_placement = *(int *)(mboot->mods_addr + 4); } // Set up memory utils init_tables( ); init_paging( mboot->mem_lower + mboot->mem_upper ); kheap = kmalloc_early( sizeof( mheap_t ), 0 ); init_heap( kheap, kernel_dir, 0xd0000000, PAGE_SIZE * 32 ); init_timer( ); kmain( 0, modules, elfinfo ); while( 1 ) asm volatile( "hlt" ); }
/* // This is where everything starts... // If you dont understand this go learn osDeving */ int kernel_main ( struct multiboot *mboot_point, u32int initial_stack ) { monitor_clear(); initial_esp = initial_stack; mboot_ptr = mboot_point; init_serial ( 1, 9 );//DO NOT DISABLE monitor_set_cursor_pos ( 0, 0 ); monitor_set_fore_colour ( GREEN ); kprintf ( "MatrixOS " ); monitor_set_cursor_pos ( 11, 0 ); print_version(); kprintf ( "\n" ); monitor_set_fore_colour ( WHITE ); u32int *pt = alloc(0x1000, 1, kheap); //init(); //init_PCI(); //set_f_verbose ( VB_NONE ); //elf("binary.elf"); //setDisplay(0x118); //drawRect(0, 0, 1024, 768, 0x0077FF00); //drawRect(25, 45, 190, 390, 0x000000FF); //startShell(); //switch_to_user_mode(); for ( ;; ) {} }
void init_kernel() { terminal_initialize(); init_serial(COM1); terminal_enable_serial_echo(COM1); terminal_printf("fOS version %s\n\n\n", KERNEL_VERSION); kinit(end + 4096, end + 4096 + (100 * 4096)); init_gdt(); load_gdt(); load_idt(); load_isrs(); irq_install(); asm volatile ( "sti" ); timer_install(); sleep(1); keyboard_install(); init_paging(); switch_to_paging(); }
void kmain(multiboot_t *mboot_ptr) { clear_screen(); print_d("%s\n",INTRODUCTION); init_serial(); init_descriptor_tables(); //asm volatile("int $0x3"); //asm volatile("int $0x4"); asm volatile("sti"); //timer_install(); register_keyboard(); kernel_elf = elf_from_multiboot (mboot_ptr); // unregister_keyboard(); // asm volatile ("int $0x3"); // //enable_interrupts(); //init_serial_port(); // int val1 = 5; // int val2 = 6 - 4 - 2; // val1 = val1/val2; }
void main() { mainFrame mouse; init_serial(); // Initialize serial communication devices. while(1) { // Continue to run the same mouse in the same mode. mouse.run(); } }
int main(void) { DDRC |= (1 << DDRC7); PORTC |= (1 << PORTC7); _delay_ms(2); PORTC &= ~(1 << PORTC7); init_power(); init_timeout_timer(); init_switch(); init_ref_clock(); init_spi(2); init_buttons(); init_serial(2400); init_adc(); init_i2c(); //Turn on interrupts sei(); play_sounds(); //Debug: Never Gets here while(1) { _delay_ms(1000); get_POT_set_TWIPOT(); } }
void os_init_cont(void) { /* Reset the GDT. Although user processes in Nanos run in Ring 0, they have their own virtual address space. Therefore, the old GDT located in physical address 0x7C00 cannot be used again. */ init_segment(); /* Initialize the serial port. After that, you can use printk() */ init_serial(); /* Set up interrupt and exception handlers, just as we did in the game. */ init_idt(); /* Initialize the intel 8259 PIC. */ init_intr(); /* Initialize processes. You should fill this. */ init_proc(); welcome(); sti(); /* This context now becomes the idle process. */ while (1) { wait_intr(); } }
static int setupHardware( void ) { // When using the JTAG debugger the hardware is not always initialised to // the correct default state. This line just ensures that this does not // cause all interrupts to be masked at the start. AT91C_BASE_AIC->AIC_EOICR = 0; // Enable the peripheral clock. AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, (1 << AT91C_ID_PIOA) | //Enable Clock for PIO (1 << AT91C_ID_IRQ0) | //Enable Clock for IRQ0 (1 << AT91C_ID_PWMC) | //Enable Clock for the PWM controller (1 << AT91C_ID_US0) | //USART0 (1 << AT91C_ID_US1) //USART1 ); // Enable reset-button AT91F_RSTSetMode( AT91C_BASE_RSTC , AT91C_RSTC_URSTEN ); if (!initUsart()) return 0; if (!vInitUSBInterface()) return 0; init_serial(); rtc_init(); InitLoggerHardware(); return 1; }
int main(int argc, char *argv[]) { init_serial(); int server_sockfd;//服务器端套接字 int client_sockfd;//客户端套接字 int len; struct sockaddr_in my_addr; //服务器网络地址结构体 struct sockaddr_in remote_addr; //客户端网络地址结构体 int sin_size; char buf[BUFSIZ]; //数据传送的缓冲区 memset(&my_addr,0,sizeof(my_addr)); //数据初始化--清零 my_addr.sin_family=AF_INET; //设置为IP通信 my_addr.sin_addr.s_addr=INADDR_ANY;//服务器IP地址--允许连接到所有本地地址上 my_addr.sin_port=htons(8000); //服务器端口号 /*创建服务器端套接字--IPv4协议,面向连接通信,TCP协议*/ if((server_sockfd=socket(PF_INET,SOCK_STREAM,0))<0) { perror("socket"); return 1; } /*将套接字绑定到服务器的网络地址上*/ if (bind(server_sockfd,(struct sockaddr *)&my_addr,sizeof(struct sockaddr))<0) { perror("bind"); return 1; } //----------------------------working------------------------------------------------------------ while(1){ printf("waiting...\n"); /*监听连接请求--监听队列长度为5*/ listen(server_sockfd,5); sin_size=sizeof(struct sockaddr_in); /*等待客户端连接请求到达*/ if((client_sockfd=accept(server_sockfd,(struct sockaddr *)&remote_addr,&sin_size))<0) { perror("accept"); return 1; } printf("accept client %s\n",inet_ntoa(remote_addr.sin_addr)); len=send(client_sockfd,"Welcome to my server\n",21,0);//发送欢迎信息 /*接收客户端的数据并将其发送给客户端--recv返回接收到的字节数,send返回发送的字节数*/ while((len=recv(client_sockfd,buf,BUFSIZ,0))>0) { buf[len]='\0'; printf("%s\n",buf); serial_res = nwrite(serial_fd,buf,strlen(buf));//通过串口发送 } } close(client_sockfd); close(server_sockfd); return 0; }
void init_communication_interfaces( void ) { #ifdef DEBUG init_serial( ); #endif DEBUG_PRINT( "init Control CAN - " ); init_can( g_control_can ); }
/* Initialisation */ void rcx_init (void) { init_timer(&async, &dispatch[0]); init_power(); systime_init(); init_sensors(); //init_motors init_buttons(); // Buttons & display pins init_serial(0, 0, 1, 1); }
static void socket_loop(void) { unsigned char recv_buf[4096], recbuf[4100]; int rec_len; int num_read, start, end; int i; int ret; rec_len = 0; for(;;) { num_read = recv(client_sockfd,recv_buf,sizeof(recv_buf),0); if(num_read == -1) { perror("recv"); } else if (num_read== 0) { printf("Server Close\n"); when_sigint(0); } else if (num_read > 0) { if (client_serfd < 0) { client_serfd = init_serial(client_sername); } printf("Socket Debug: read=%d, left=%d, [0]=%u\n", num_read, rec_len, recv_buf[0]); if (num_read+rec_len > 4100) rec_len = 0; memcpy(recbuf+rec_len, recv_buf, num_read); rec_len += num_read; start = end = 0; for (i=0; i<rec_len; i++) { if (recbuf[i] == CHAR_HDLC_END) { if (client_serfd > 0) { ret = write(client_serfd, recbuf+start, end-start+1); if (ret == -1) { perror("serial write"); close(client_serfd); client_serfd = -1; } } start = end = i+1; continue; } end++; } rec_len = end - start; if (rec_len > 0) memmove(recbuf, recbuf+start, rec_len); } } close(client_sockfd); }
void init() { PWMInit(); init_1602(); initTimer0(); init_serial(); timePrint(); car.current = TG_START; }
int main(int argc, char** argv) { // keep these values available for later mp_argc = argc; mp_argv = argv; #else int main(void) { mcu_init(); #endif #if (USE_TELELOG == 1) log_init(); #endif #if (USE_USB == 1) preflight(); // perhaps this would be better called usb_init() #endif gps_init(); // this sets function pointers so i'm calling it early for now udb_init(); dcm_init(); init_config(); // this will need to be moved up in order to support runtime hardware options #if (FLIGHT_PLAN_TYPE == FP_WAYPOINTS) init_waypoints(); #endif init_servoPrepare(); init_states(); init_behavior(); init_serial(); if (setjmp(buf)) { // a processor exception occurred and we're resuming execution here DPRINT("longjmp'd\r\n"); } #ifdef _MSC_VER #if (SERIAL_OUTPUT_FORMAT == SERIAL_MAVLINK) parameter_table_init(); #endif // SERIAL_OUTPUT_FORMAT #endif // _MSC_VER while (1) { #if (USE_TELELOG == 1) telemetry_log(); #endif #if (USE_USB == 1) USBPollingService(); #endif #if (CONSOLE_UART != 0 && SILSIM == 0) console(); #endif udb_run(); } return 0; }
void main() { init_serial(); transmite_serial('\n'); init_relogio(); display_relogio(); while(1) { display_relogio(); } }
void dream() { print("Initialising serial port at 0x3f8 to 9600\n"); init_serial(0x3f8, 9600); print("Writing to UART ... :"); blocking_send_serial(0x3f8, ':'); print("-"); blocking_send_serial(0x3f8, '-'); print(")"); blocking_send_serial(0x3f8, ')'); print("\n"); }
/* This is the C kernel entry point */ void kmain(struct multiboot *mboot_header, addr_t initial_stack) { /* Store passed values, and initiate some early things * We want serial log output as early as possible */ kernel_state_flags=0; mtboot = mboot_header; i_stack = initial_stack; parse_kernel_elf(mboot_header, &kernel_elf); #if CONFIG_MODULES init_kernel_symbols(); #endif init_serial(); console_init_stage1(); load_tables(); puts("~ SeaOS Version "); char ver[32]; get_kernel_version(ver); puts(ver); puts(" Booting Up ~\n\r"); #if CONFIG_MODULES init_module_system(); #endif init_syscalls(); load_initrd(mtboot); install_timer(1000); pm_init(placement, mtboot); init_main_cpu_1(); /* Now get the management stuff going */ printk(1, "[kernel]: Starting system management\n"); init_memory(mtboot); init_main_cpu_2(); console_init_stage2(); parse_kernel_cmd((char *)(addr_t)mtboot->cmdline); init_multitasking(); init_cache(); init_dm(); init_vfs(); /* Load the rest... */ process_initrd(); init_kern_task(); get_timed(&kernel_start_time); printk(KERN_MILE, "[kernel]: Kernel is setup (%2.2d:%2.2d:%2.2d, %s, kv=%d, ts=%d bytes: ok)\n", kernel_start_time.tm_hour, kernel_start_time.tm_min, kernel_start_time.tm_sec, kernel_name, KVERSION, sizeof(task_t)); assert(!set_int(1)); if(!fork()) init(); sys_setsid(); enter_system(255); kernel_idle_task(); }
int main (int argc, char **argv) { int i,j, number_bytes; unsigned char buffer[512]; /* Check inputs parameters */ if (argc < 2) { fprintf (stderr, "./bd970_rx <serial_port_path>\n"); return ERROR; } /* Open serial port*/ printf ("Connecting to BD970_EMU [%s].......", argv[1]); /* Argv[1] is the normal "/dev/ttyUSB0" driver description file on Linux system*/ int fd = init_serial (argv[1]); if (fd != ERROR) { /* Print text information confirming that the connection was stabilize */ printf ("OK.\n"); for (i=0; i < 10; ++i) { sleep(1.0); number_bytes = read_serial(fd, buffer, 512); printf("Read %d bytes from fd (%d) \n", number_bytes, fd); if (number_bytes != ERROR) { for (j=0; j < number_bytes; j++) { fprintf (stdout, "%c", buffer[j]); } } } close(fd); } //End if of file description (serial port) return OK; }