您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ uart_init函数代码示例

51自学网 2021-06-03 09:04:09
  C++
这篇教程C++ uart_init函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中uart_init函数的典型用法代码示例。如果您正苦于以下问题:C++ uart_init函数的具体用法?C++ uart_init怎么用?C++ uart_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了uart_init函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: nrf_log_backend_uart_panic_set

static void nrf_log_backend_uart_panic_set(nrf_log_backend_t const * p_backend){    nrf_drv_uart_uninit(&m_uart);    uart_init(false);}
开发者ID:petersonev,项目名称:keyboard,代码行数:6,


示例2: user_init

/****************************************************************************** * FunctionName : user_init * Description  : entry of user application, init user function here * Parameters   : none * Returns      : none*******************************************************************************/void user_init(void){    os_delay_us(1000*1000);    uart_init (BIT_RATE_115200, BIT_RATE_115200, USER_TASK_PRIO_0, 0);    os_delay_us(100*1000);    os_printf("Interactive Cube starting../n");    config_init();    platform_i2c_setup(i2c_endpoint_id, 1, 2, PLATFORM_I2C_SPEED_SLOW);    display_init();    NODE_DBG("SDK version: %s/n", system_get_sdk_version());    system_print_meminfo();    os_printf("Heap size: %d./n", system_get_free_heap_size());#ifndef NODE_DEBUG    system_set_os_print(1);#endif    int b;    for(b=0; b<4; b++) {        display_set_pixel(0, 1);        display_update_inner();        os_delay_us(500*1000);        display_update_inner();        display_set_pixel(0, 0);        display_update_inner();        os_delay_us(500*1000);        display_update_inner();    }    if (display_is_key_down(0)) {        // enter setup mode, show as blinking...!        configui_init();        return;    }    display_set_pixel(0, 1);    display_set_pixel(1, 1);    display_set_pixel(2, 1);    display_update_inner();    // uart_init(BIT_RATE_9600,0);    os_delay_us(100*1000);    os_delay_us(1000*1000);    display_anim();    //  os_delay_us(500*1000);    NODE_DBG("Hello Wurst./n");    // os_delay_us(500*1000);    // Set up I2C    // Wire.begin(D1, D2); // sda, scl    display_set_pixel(0, 0);    display_set_pixel(1, 0);    display_set_pixel(2, 0);    display_set_pixel(3, 0);    display_update();    comm_init();    orient_init();    // system_init_done_cb(nodemcu_init);    system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);    system_os_post(user_procTaskPrio, 0, 0);    NODE_DBG("End of user_init./n");}
开发者ID:interactiveBrick,项目名称:mini-interactive-cube,代码行数:84,


示例3: cache_as_ram_main

void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx){	static const uint16_t spd_addr [] = {		(0xa<<3)|0, (0xa<<3)|2, 0, 0,		(0xa<<3)|1, (0xa<<3)|3, 0, 0,#if CONFIG_MAX_PHYSICAL_CPUS > 1		(0xa<<3)|4, (0xa<<3)|6, 0, 0,		(0xa<<3)|5, (0xa<<3)|7, 0, 0,#endif	};	int needs_reset;	unsigned bsp_apicid = 0;	struct mem_controller ctrl[8];	unsigned nodes;	if (!cpu_init_detectedx && boot_cpu()) {		/* Nothing special needs to be done to find bus 0 */		/* Allow the HT devices to be found */		enumerate_ht_chain();		sio_setup();		/* Setup the ck804 */		ck804_enable_rom();	}	if (bist == 0) {		bsp_apicid = init_cpus(cpu_init_detectedx);	}//	post_code(0x32); 	w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);	uart_init();	console_init();	/* Halt if there was a built in self test failure */	report_bist_failure(bist);	setup_s2891_resource_map();#if 0	dump_pci_device(PCI_DEV(0, 0x18, 0));	dump_pci_device(PCI_DEV(0, 0x19, 0));#endif	needs_reset = setup_coherent_ht_domain();	wait_all_core0_started();#if CONFIG_LOGICAL_CPUS==1	// It is said that we should start core1 after all core0 launched	start_other_cores();	wait_all_other_cores_started(bsp_apicid);#endif	needs_reset |= ht_setup_chains_x();	needs_reset |= ck804_early_setup_x();	if (needs_reset) {		printk(BIOS_INFO, "ht reset -/n");		soft_reset();	}	allow_all_aps_stop(bsp_apicid);	nodes = get_nodes();	//It's the time to set ctrl now;	fill_mem_ctrl(nodes, ctrl, spd_addr);	enable_smbus();#if 0	dump_spd_registers(&cpu[0]);#endif#if 0	dump_smbus_registers();#endif	memreset_setup();	sdram_initialize(nodes, ctrl);#if 0	print_pci_devices();#endif#if 0	dump_pci_devices();#endif	post_cache_as_ram();}
开发者ID:jaanek,项目名称:coreboot,代码行数:93,


示例4: ioinit

/* * Do all the startup-time peripheral initializations. */static voidioinit(void){  uart_init();  lcd_init();}
开发者ID:AVR-GCC,项目名称:ArduinoAnalyzer,代码行数:9,


示例5: main

int main() {	// LEDs as outputs	DDRC |= (1 << IR_LED_PIN);	DDRC |= (1 << IR_INDICATOR_LED_PIN);	DDRC |= (1 << TIMER_INDICATOR_LED_PIN);	//enable internal pullup resistors	PORTC |= (1 << MODE_SWITCH_PIN);	PORTC |= (1 << POTENTIOMETER_PIN);	PORTD |= (1 << TRIGGER_PIN);		// Pin change interrupt control register - enables interrupt vectors	// Bit 2 = enable PC vector 2 (PCINT23..16)	// Bit 1 = enable PC vector 1 (PCINT14..8)	// Bit 0 = enable PC vector 0 (PCINT7..0)	PCICR |= (1 << PCIE2);	// Pin change mask registers decide which pins are enabled as triggers	PCMSK2 |= (1 << PCINT18);	adc_init();	//start up the serial port	uart_init();	FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);	stdin = stdout = &uart_stream;	printf_P(PSTR("STARTING/r/n"));		//Check mode switch	if ((PINC & (1 << MODE_SWITCH_PIN)) == 0) {		mode = REMOTE;		blink_timer_led_times(1U);	} else {		mode = INTERVALOMETER;		blink_timer_led_times(2U);		SetupTimer2();		timer_interval_ms = get_interval_ms();	}	delay_ms(500U);		printf_P(PSTR("Mode %u ms/r/n"), mode);		while (1) {		if (mode == INTERVALOMETER) {					set_sleep_mode(SLEEP_MODE_PWR_SAVE);					cli();			sleep_enable();			sei();			sleep_cpu();			sleep_disable();			sei();			if (the_time_ms >= timer_interval_ms) {				the_time_ms = 0UL;				remainder_counter = 0UL;				click();				count_down_ms = 5000UL;				printf_P(PSTR("Waiting for: %lu ms/r/n"), timer_interval_ms);			} else {						//while waiting for next intervalometer click, flash a green LED to show it is still on				if (the_time_ms > 0UL && (count_down_ms <= 0L)) {		//turn on every 5 seconds					count_down_ms = 5000UL;					blink_timer_led_times(1U);				}			}		}		else {			set_sleep_mode(SLEEP_MODE_PWR_DOWN);			cli();			sleep_enable();			sei();			sleep_cpu();			sleep_disable();			sei();		}	}		return 0;}
开发者ID:sideproject,项目名称:cameraremote,代码行数:82,


示例6: main

int main(void){	/* Simulate a compal loader saying "ACK" */	int i = 0;	for (i = 0; i < sizeof(phone_ack); i++) {		putchar_asm(phone_ack[i]);	}	/* Always disable wdt (some platforms enable it on boot) */	wdog_enable(0);	/* Disable the bootrom mapping */	calypso_bootrom(0);	/* Initialize TWL3025 for power control */	twl3025_init();	/* Backlight */	bl_mode_pwl(1);	bl_level(50);	/* Initialize UART without interrupts */	uart_init(SERCOMM_UART_NR, 0);	uart_baudrate(SERCOMM_UART_NR, UART_115200);	/* Initialize HDLC subsystem */	sercomm_init();	/* Say hi */	puts("/n/nOSMOCOM Loader (revision " GIT_REVISION ")/n");	puts(hr);	/* Identify environment */	printf("Running on %s in environment %s/n", manifest_board,	       manifest_environment);	/* Initialize flash driver */	if (flash_init(&the_flash, 0)) {		puts("Failed to initialize flash!/n");	} else {		printf("Found flash of %d bytes at 0x%x with %d regions/n",		       the_flash.f_size, the_flash.f_base,		       the_flash.f_nregions);		int i;		for (i = 0; i < the_flash.f_nregions; i++) {			printf("  Region %d of %d pages with %d bytes each./n",			       i,			       the_flash.f_regions[i].fr_bnum,			       the_flash.f_regions[i].fr_bsize);		}	}	/* Set up a key handler for powering off */	keypad_set_handler(&key_handler);	/* Set up loader communications */	sercomm_register_rx_cb(SC_DLCI_LOADER, &cmd_handler);	/* Notify any running osmoload about our startup */	loader_send_init(SC_DLCI_LOADER);	/* Wait for events */	while (1) {		keypad_poll();		uart_poll(SERCOMM_UART_NR);	}	/* NOT REACHED */	twl3025_power_off();}
开发者ID:kashif-test,项目名称:VBTS,代码行数:73,


示例7: main

int main(void) {    uart_init();    servos_init();    steppers_init();    pumps_init();    *idle_ddr &= ~idle_mask;    *idle_port |= idle_mask;    *setup_ddr &= ~setup_mask;    *setup_port |= setup_mask;    *ready_ddr |= ready_mask;    *ready_port &= ~(ready_mask);    sei();    uart_puts("PumpControl 0.1 ready/n/r");    uint8_t active_pump = 0;    while(1) {        pumps_run();        // Setup is active low        if(!(*setup_pin & setup_mask)) {            for(uint8_t i = 0; i < PumpCount; i++) {                if(pump_states[i] != PUMP_SETUP) {                     pump_enter_setup(i);                }            }        }        // We only activate extruders if we are idle        if(*idle_pin & idle_mask) {            /*             * Check if we need a new active pump             * if full -> nice we've got a fresh one             * if dispense -> still some stuff left in this one             */            if(pump_states[active_pump] != PUMP_FULL &&                pump_states[active_pump] != PUMP_DISPENSE) {                for(uint8_t i = 0; i < PumpCount; i++) {                    if(pump_states[i] == PUMP_FULL) {                        active_pump = i;                        break;                    }                }            }            // We've selected a new active pump, now we need to start it            if(pump_states[active_pump] == PUMP_FULL) {                uart_debug_pump(active_pump, "is new acitve pump");                pump_enter_dispense(active_pump);            }        }        /*         * We are ready if we picked a new active pump and set it to dispense,         * or if the old one still has stuff left in it and is in dispense.         */        if(pump_states[active_pump] == PUMP_DISPENSE) {            *ready_port |= ready_mask;        }        else {            *ready_port &= ~(ready_mask);        }        /*         * If we are idle, try to fill all pumps         * If the active pump is also refilled, a other full one will be chosen         * in the next iteration.         */        if(!(*idle_pin & idle_mask)) {            for(uint8_t i = 0; i < PumpCount; i++) {                if(pump_states[i] == PUMP_DISPENSE) {                    uart_debug("Idle state detected, refilling");                    pump_enter_fill(i);                }            }        }    }}
开发者ID:chaos-inkl,项目名称:firecake-pump,代码行数:87,


示例8: main

void main(){  uint8_t sw1,sw2;  uint16_t  memaddr = 0;   // Start memory Address  uint8_t  dat,c,i;   /* *  Initialize UART library, pass baudrate and AVR cpu clock *  with the macro  *  UART_BAUD_SELECT() (normal speed mode ) *  or  *  UART_BAUD_SELECT_DOUBLE_SPEED() ( double speed mode)*/  DDRC = 0xFC;  uart_init();      d7segment_init();  i2ceeprom_init();//  i2c_set_localdeviceaddr(I2C_EEPROM_MASTER_ADDR,FALSE);//  i2c_set_localdeviceaddr(I2C_EEPROM_SLAVE_ADDR,FALSE);  sei();// To Wrie and read the same device. Need to delay. Maybe the wait state is not correct.... //  dat = 0x44;//  memaddr = 0;//  i2ceeprom_write_byte(I2C_EEPROM_SLAVE_ADDR, memaddr,dat);//  debug_value (dat,16); //  	_delay_ms(20);//  dat = i2ceeprom_read_byte(I2C_EEPROM_SLAVE_ADDR,memaddr);//  debug_value (dat,16);  					   while (1)  { 				   sw1 = _7SEGMENT_SW1_IN_PORT & _7SEGMENT_SW1;    sw2 = _7SEGMENT_SW2_IN_PORT & _7SEGMENT_SW2;         // Delay      if (!sw1) // Start copy eeprom     {   	        i = 0;		for (memaddr = 0  ; memaddr < E_24LC32_MEM_ADDR ;memaddr++)		{   			dat = i2ceeprom_read_byte(I2C_EEPROM_MASTER_ADDR,memaddr);			debug_value (dat,16);  			i2ceeprom_write_byte(I2C_EEPROM_SLAVE_ADDR, memaddr,dat);//			_delay_ms( EEPROM_DELAY);	          			if (i < 100)			{				c =0;			}			if (i > 100) 			{				c ='-';			            }						if (i > 200)				i = 0;						d7segment_display(c,1);			_delay_ms(2);			d7segment_display(c,2);			_delay_ms(2);					    i++;   		}  //		}// Finish copy   	   	d7segment_display(0,2);	_delay_ms( 10);	d7segment_display(0,1);	_delay_ms( 10);      }     }
开发者ID:wtos03,项目名称:Geartronics-Git-Sever,代码行数:89,


示例9: user_init

// initialize the custom stuff that goes beyond esp-linkvoid user_init(){	// Initialize the GPIO subsystem.	gpio_init();	/* ====================================== */	/* UART                                   */	/* ====================================== */	// Initialize UART0 and UART1	/* NOTE: UART1 and I2S share same GPIO. Cannot use simultaneously. */	uart_init( BIT_RATE_115200, BIT_RATE_115200 );//	uart0_sendStr( "/nUART0 - USED TO PROGRAM THE MODULE/n" );	os_printf("/n===================/nUART1 - DEBUG OUPUT/n===================/n");	/* NOTE: PWM CANNOT BE USED SIMULTANEOUSLY WITH HW TIMER */#if 0	/* ====================================== */	/* PWM                                    */	/* ====================================== */    uint32  pwm_period = 1000;	uint32 pwm_duty[PWM_CHANNEL] = {0};    uint32 io_info[][3] = {   {PWM_0_OUT_IO_MUX,PWM_0_OUT_IO_FUNC,PWM_0_OUT_IO_NUM},    		                  {PWM_1_OUT_IO_MUX,PWM_1_OUT_IO_FUNC,PWM_1_OUT_IO_NUM},    		              };	/* PIN FUNCTION INIT FOR PWM OUTPUT */	pwm_init(pwm_period, pwm_duty, PWM_CHANNEL, io_info);	/* set pwm_duty cycle */	pwm_set_duty (14185, 0);	pwm_set_duty (22222, 1); // todo: explain why 22222 is the highest possible value	/* start PWM */	pwm_start(); // NOTE: PWM causes spikes in other GPIOs#endif	/* ====================================== */	/* GPIO INTERRPUT                         */	/* ====================================== */	/* Set GPIO12 in GPIO mode */	PIN_FUNC_SELECT( PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12 );	/* Set GPIO12 as input */	GPIO_DIS_OUTPUT( GPIO_ID_PIN(12) );	/* Disable all GPIO interrupts */	ETS_GPIO_INTR_DISABLE();	/* Set a GPIO callback function */	ETS_GPIO_INTR_ATTACH( gpioCallback, NULL );	/* Configure the type of edge */	gpio_pin_intr_state_set( GPIO_ID_PIN(12), GPIO_PIN_INTR_ANYEDGE );	ETS_GPIO_INTR_ENABLE();	/* ====================================== */	/* SOFTWARE TIMER                         */	/* ====================================== */	// Set GPIO0 to output mode	PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);	//Set GPIO0 low	gpio_output_set(0, RELAY_PIN, RELAY_PIN, 0);	/* disarm timer */	os_timer_disarm((ETSTimer*)&some_timer);	/* set callback */	os_timer_setfn((ETSTimer*)&some_timer, (os_timer_func_t *) softwareTimerCallback, NULL);	/* arm the timer -> os_timer_arm(<pointer>, <period in ms>, <fire periodically>) */	os_timer_arm((ETSTimer*)&some_timer, 10, 1);	/* ====================================== */	/* OS TASK                                */	/* ====================================== */	/* setup OS task *///	system_os_task(user_procTask, user_procTaskPrio, user_procTaskQueue, user_procTaskQueueLen);	/* send a message to OS task (fire task) *///	system_os_post(user_procTaskPrio, 0, 0 );	/* ====================================== */	/* HARDWARE TIMER                         */	/* ====================================== *///.........这里部分代码省略.........
开发者ID:mroavi,项目名称:my-esp,代码行数:101,


示例10: main

/** * /brief Main routine for the OpenMote-CC2538 platforms */intmain(void){  nvic_init();  ioc_init();  sys_ctrl_init();  clock_init();  lpm_init();  rtimer_init();  gpio_init();  leds_init();  fade(LEDS_RED);  process_init();  watchdog_init();#if UART_CONF_ENABLE  uart_init(0);  uart_init(1);  uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte);#endif#if USB_SERIAL_CONF_ENABLE  usb_serial_init();  usb_serial_set_input(serial_line_input_byte);#endif  i2c_init(I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_PORT, I2C_SCL_PIN, I2C_SCL_NORMAL_BUS_SPEED);  serial_line_init();  INTERRUPTS_ENABLE();  fade(LEDS_BLUE);  PUTS(CONTIKI_VERSION_STRING);  PUTS(BOARD_STRING);#if STARTUP_CONF_VERBOSE  soc_print_info();#endif  random_init(0);  udma_init();  process_start(&etimer_process, NULL);  ctimer_init();  board_init();#if CRYPTO_CONF_INIT  crypto_init();  crypto_disable();#endif  netstack_init();  set_rf_params();  PRINTF("Net: ");  PRINTF("%s/n", NETSTACK_NETWORK.name);  PRINTF("MAC: ");  PRINTF("%s/n", NETSTACK_MAC.name);  PRINTF("RDC: ");  PRINTF("%s/n", NETSTACK_RDC.name);#if NETSTACK_CONF_WITH_IPV6  memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));  queuebuf_init();  process_start(&tcpip_process, NULL);#endif /* NETSTACK_CONF_WITH_IPV6 */  process_start(&sensors_process, NULL);  SENSORS_ACTIVATE(button_sensor);  energest_init();  ENERGEST_ON(ENERGEST_TYPE_CPU);  autostart_start(autostart_processes);  watchdog_start();  fade(LEDS_GREEN);  while(1) {    uint8_t r;    do {      watchdog_periodic();      r = process_run();    } while(r > 0);    lpm_enter();  }}
开发者ID:AmitSharma1094,项目名称:contiki,代码行数:95,


示例11: main

int main( int argc, char *argv[] ) {	char			*uart_device;	uint8_t			buf[BUF_SIZE+1];	int				nread;	fd_set			fds;	fsm_demo		fsm_state = FSM_INIT;	srand( time(NULL) );	if( argc==2 )		uart_device = argv[1];	else		uart_device = (char*) DEFAULT_UART_DEVICE;	// open uart device	uart_fd = open( uart_device, O_RDWR | O_NOCTTY );	if( uart_fd<0 ) {		perror( uart_device );		exit( -1 );	}	uart_init( uart_fd );	// register clean up callback	signal( SIGINT, ctrl_break );	stdin_nonblock();	atexit( restore );	// main loop	while(1) {		int	retval;		switch( fsm_state ) {			case FSM_INIT: {				tcflush( uart_fd, TCIOFLUSH );				serial_send_command( uart_fd, &cmd_stop_data_streaming, sizeof(cmd_stop_data_streaming) );				serial_send_command( uart_fd, &cmd_stop_data_streaming, sizeof(cmd_stop_data_streaming) );				serial_send_command( uart_fd, &cmd_motor_stop_hori, sizeof(cmd_motor_stop_t) );				serial_send_command( uart_fd, &cmd_motor_stop_vert, sizeof(cmd_motor_stop_t) );				fsm_state = FSM_FLUSH;				continue;			}			case FSM_FLUSH: {				int nbytes;				usleep(10000);				ioctl( uart_fd, FIONREAD, &nbytes );				if( !nbytes ) {					fsm_state = FSM_PING;					continue;				} else					break;			}			case FSM_PING:				printf( "ping.../n" );				serial_send_command( uart_fd, &cmd_ping, sizeof(cmd_ping) );				break;			case FSM_CHECK_PRESENTATION:				printf( "check presentation string.../n" );				serial_send_command( uart_fd, &cmd_read_pres_string, sizeof(cmd_read_pres_string) );				break;			case FSM_CHECK_MODE:				printf( "check mode.../n" );				serial_send_command( uart_fd, &cmd_check_mode_support, sizeof(cmd_check_mode_support) );				break;			case FSM_INIT_SENSORS:				printf( "init sensors.../n" );				if( SENSORS_ENABLED ) {					if( SENSORS_ENABLED & (SENSOR_ACCELEROMETER|SENSOR_GYROSCOPE) )						serial_send_command( uart_fd, &cmd_lsm6ds0_init, sizeof(cmd_short_t) );					if( SENSORS_ENABLED & SENSOR_MAGNETIC )						serial_send_command( uart_fd, &cmd_lis3mdl_init, sizeof(cmd_short_t) );					usleep(1000);					break;				}			case FSM_START_DATA_STREAMING:				printf( "start data streaming.../n" );				serial_send_command( uart_fd, &cmd_start_data_streaming, sizeof(cmd_start_data_streaming) );				break;			case FSM_INTERACTIVE:				printf( "> " );				fflush( stdout );				break;			case FSM_IDLE:				break;			case FSM_RUNIN:				break;			default:				fprintf( stderr, "Unknown FSM state %d/n", fsm_state );				exit(-2);		}		FD_ZERO( &fds );		FD_SET( uart_fd, &fds );		FD_SET( STDIN_FILENO, &fds );		retval = select( uart_fd+1, &fds, NULL, NULL, NULL );		if( retval<0 ) {			perror( "select" );		} else if( retval==0 ) {			fprintf( stderr, "select return 0/n" );			exit(-1);//.........这里部分代码省略.........
开发者ID:heidiao,项目名称:stm32_ctl,代码行数:101,


示例12: board_init

void board_init() {	uint16_t i,j;	//enable all port clocks.	SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK			| SIM_SCGC5_PORTB_MASK			| SIM_SCGC5_PORTC_MASK			| SIM_SCGC5_PORTD_MASK			| SIM_SCGC5_PORTE_MASK );	//init all pins for the radio	//SLPTR#ifdef TOWER_K20	PORTB_PCR3 = PORT_PCR_MUX(1);// -- PTB3 used as gpio for slptr	GPIOB_PDDR |= RADIO_SLPTR_MASK; //set as output	//RADIO RST -- TODO in the TWR change it to another pin! this is one of the leds.	PORTC_PCR9 = PORT_PCR_MUX(1);// -- PTC9 used as gpio for radio rst	GPIOC_PDDR |= RADIO_RST_MASK; //set as output#elif OPENMOTE_K20	PORTD_PCR4 = PORT_PCR_MUX(1);// -- PTD4 used as gpio for slptr	GPIOD_PDDR |= RADIO_SLPTR_MASK; //set as output	//RADIO RST 	PORTD_PCR5 = PORT_PCR_MUX(1);// -- PTD5 used as gpio for radio rst	GPIOD_PDDR |= RADIO_RST_MASK; //set as output#endif		PORT_PIN_RADIO_RESET_LOW();//activate the radio.		PORT_PIN_RADIO_SLP_TR_CNTL_LOW();		//ptc5 .. ptc5 is pin 62, irq A	enable_irq(RADIO_EXTERNAL_PORT_IRQ_NUM);//enable the irq. The function is mapped to the vector at position 105 (see manual page 69). The vector is in isr.h	//external port radio_isr.	PORTC_PCR5 = PORT_PCR_MUX(1);// -- PTC5 used as gpio for radio isr through llwu	GPIOC_PDDR &= ~1<<RADIO_ISR_PIN; //set as input ==0	PORTC_PCR5 |= PORT_PCR_IRQC(0x09); //9 interrupt on raising edge. page 249 of the manual.		PORTC_PCR5 |= PORT_PCR_ISF_MASK; //clear any pending interrupt.	llwu_init();//low leakage unit init - to recover from deep sleep	debugpins_init();	leds_init();	bsp_timer_init();	uart_init();	radiotimer_init();	spi_init();		radio_init();	leds_all_off();	leds_sync_on();	leds_radio_on();	leds_debug_on();	leds_error_on();	leds_all_off();	debugpins_fsm_clr();}
开发者ID:marcelobarrosalmeida,项目名称:cc2538em,代码行数:62,


示例13: bsp_sys_init

/** * Inicializa los dispositivos del sistema. * Esta función se debe llamar después de  bsp_int_init(). */static void bsp_sys_init( void ){	/* Inicialización de las UARTs */	uart_init(UART1_ID, UART1_BAUDRATE, UART1_NAME);	uart_init(UART2_ID, UART2_BAUDRATE, UART2_NAME);}
开发者ID:felipet,项目名称:se,代码行数:10,


示例14: nrf_log_backend_uart_init

void nrf_log_backend_uart_init(void){    bool async_mode = NRF_LOG_DEFERRED ? true : false;    uart_init(async_mode);}
开发者ID:petersonev,项目名称:keyboard,代码行数:5,


示例15: syscall

//.........这里部分代码省略.........			ret = 0;		} break;		case SYS_SCREEN_SET_LOCATE_Y: {			unsigned long int y;			y	= va_arg(ap,unsigned long int);			screen_set_locate_y(&scr,y);			ret = 0;		} break;		case SYS_SCREEN_GET_LOCATE_X: {			ret = screen_get_locate_x(&scr);		} break;		case SYS_SCREEN_GET_LOCATE_Y: {			ret = screen_get_locate_y(&scr);		} break;		case SYS_SCREEN_SET_COLOR_FG: {			unsigned long int r,g,b;			r	= va_arg(ap,unsigned long int);			g	= va_arg(ap,unsigned long int);			b	= va_arg(ap,unsigned long int);			screen_set_color_fg(&scr,r,g,b);			ret = 0;		} break;		case SYS_SCREEN_SET_COLOR_BG: {			unsigned long int r,g,b;			r	= va_arg(ap,unsigned long int);			g	= va_arg(ap,unsigned long int);			b	= va_arg(ap,unsigned long int);			screen_set_color_bg(&scr,r,g,b);			ret = 0;		} break;	// UART		case SYS_UART_INIT: {			unsigned long int base;			unsigned long int irq;			base	= va_arg(ap,unsigned long int);			irq	= va_arg(ap,unsigned long int);			uart.tx.buf		= uart_buffer_tx;			uart.tx.buf_size	= UART_TX_BUF_SIZE;			uart.rx.buf		= uart_buffer_rx;			uart.rx.buf_size	= UART_RX_BUF_SIZE;			uart_init(&uart,UART_BASE,UART_IRQ);			ret = 0;		} break;		case SYS_UART_GET: {			ret = (long int)uart_get(&uart);		} break;		case SYS_UART_GET_EXIST: {			ret = (long int)uart_get_exist(&uart);		} break;		case SYS_UART_GET_CLEAR: {			uart_get_clear(&uart);			ret = 0;		} break;		case SYS_UART_PUT: {			unsigned int data;			data	= va_arg(ap,unsigned int);			uart_put(&uart,(unsigned char)data);			ret = 0;		} break;		case SYS_UART_PUT_FULL: {			ret = uart_put_full(&uart);		} break;		case SYS_UART_PUT_CLEAR: {			uart_put_clear(&uart);			ret = 0;		} break;		case SYS_UART_PUT_STRING: {			unsigned char *string;			string	= va_arg(ap,unsigned char *);			uart_put_string(&uart,string);			ret = 0;		} break;		case SYS_UART_IS_CTS: {			ret = uart_is_cts(&uart);		} break;		case SYS_UART_IS_DSR: {			ret = uart_is_dsr(&uart);		} break;		case SYS_UART_IS_RI: {			ret = uart_is_ri(&uart);		} break;		case SYS_UART_IS_DCD: {			ret = uart_is_dcd(&uart);		} break;		case SYS_UART_DTR: {			unsigned long int data;			data = va_arg(ap,unsigned long int);			uart_dtr(&uart,data);			ret = 0;		} break;		case SYS_UART_RTS: {			unsigned long int data;			data = va_arg(ap,unsigned long int);			uart_rts(&uart,data);			ret = 0;		} break;	}	va_end(ap);	return ret;}
开发者ID:freecores,项目名称:kiss-board,代码行数:101,


示例16: main

/** * /brief Main routine for the cc2538dk platform */intmain(void){  nvic_init();  ioc_init();  sys_ctrl_init();  clock_init();  lpm_init();  rtimer_init();  gpio_init();  leds_init();  fade(LEDS_YELLOW);  process_init();  watchdog_init();  button_sensor_init();  /*   * Character I/O Initialisation.   * When the UART receives a character it will call serial_line_input_byte to   * notify the core. The same applies for the USB driver.   *   * If slip-arch is also linked in afterwards (e.g. if we are a border router)   * it will overwrite one of the two peripheral input callbacks. Characters   * received over the relevant peripheral will be handled by   * slip_input_byte instead   */#if UART_CONF_ENABLE  uart_init(0);  uart_init(1);  uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte);#endif#if USB_SERIAL_CONF_ENABLE  usb_serial_init();  usb_serial_set_input(serial_line_input_byte);#endif  serial_line_init();  INTERRUPTS_ENABLE();  fade(LEDS_GREEN);  PUTS(CONTIKI_VERSION_STRING);  PUTS(BOARD_STRING);  PRINTF(" Net: ");  PRINTF("%s/n", NETSTACK_NETWORK.name);  PRINTF(" MAC: ");  PRINTF("%s/n", NETSTACK_MAC.name);  PRINTF(" RDC: ");  PRINTF("%s/n", NETSTACK_RDC.name);  /* Initialise the H/W RNG engine. */  random_init(0);  udma_init();  process_start(&etimer_process, NULL);  ctimer_init();  set_rf_params();  netstack_init();#if NETSTACK_CONF_WITH_IPV6  memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));  queuebuf_init();  process_start(&tcpip_process, NULL);#endif /* NETSTACK_CONF_WITH_IPV6 */  process_start(&sensors_process, NULL);  energest_init();  ENERGEST_ON(ENERGEST_TYPE_CPU);  autostart_start(autostart_processes);  watchdog_start();  fade(LEDS_ORANGE);  while(1) {    uint8_t r;    do {      /* Reset watchdog and handle polls and events */      watchdog_periodic();      r = process_run();    } while(r > 0);    /* We have serviced all pending events. Enter a Low-Power mode. */    lpm_enter();  }}
开发者ID:BaliAutomation,项目名称:contiki,代码行数:98,


示例17: main

int main(void) {	/* init serial interface */	uart_init(UART_BAUD_SELECT(BAUDRATE, F_CPU)); 	/* init spi interface */	spi_init();	/* initialize LEDs */	strip_init();	timer_init();	/* enable interrupts */	sei();	/* motd */	uart_puts_P("/r/n/r/nfnordstripe 0.1/r/n");	struct hsv_color hsvd, hsv = {		.hue = 70,		.saturation = 0xff,		.value = 0xff	};	enum mode { HUE, SAT, VAL } m = HUE;	char buf[32];	while (1) {		uint16_t r = uart_getc();		char c = r & 0xff;		if (r & UART_NO_DATA) {			hsv.hue++;			hsv.hue %= 360;						for (uint8_t i = 0; i < DOTS; i++) {				hsvd = hsv;				hsvd.hue += 7*i;				hsvd.hue %= 360;				cli();				strip_setdot(hsv2rgb(hsvd), i);				sei();			}			_delay_ms(500);		}		else if (r & 0xff00) {			uart_puts_P("error/r/n");		}		else if ( c == 'h' ) m = HUE;		else if ( c == 'v' ) m = VAL;		else if ( c == 's' ) m = SAT;		else if ( c >= '0' && c <= '9') {			switch (m) {				case HUE:					hsv.hue = (c - '0') * 36;					sprintf(buf, "ok, hue: %d/r/n", hsv.hue);					break;				case SAT:					hsv.saturation = (c- '0') * 25;					sprintf(buf, "ok, saturation: %d/r/n", hsv.saturation);					break;				case VAL:					hsv.value = (c- '0') * 25;					sprintf(buf, "ok, value: %d/r/n", hsv.value);					break;			}			uart_puts(buf);		}		else {			uart_putc(c);		}	}	return 0;}
开发者ID:stv0g,项目名称:fnordstripe,代码行数:77,


示例18: cache_as_ram_main

void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx){	u32 val;	post_code(0x30);	agesawrapper_amdinitmmio();	post_code(0x31);	/* Halt if there was a built in self test failure */	post_code(0x33);	report_bist_failure(bist);	sb7xx_51xx_enable_wideio(0, 0x1600); /* though UARTs are on the NUVOTON BMC */	w83627dhg_set_clksel_48(DUMMY_DEV);	w83627dhg_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);	sb7xx_51xx_disable_wideio(0);	post_code(0x34);	uart_init();	post_code(0x35);	console_init();	val = cpuid_eax(1);	printk(BIOS_DEBUG, "BSP Family_Model: %08x /n", val);	printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx /n", cpu_init_detectedx);	post_code(0x37);	val = agesawrapper_amdinitreset();	if (val) {		printk(BIOS_DEBUG, "agesawrapper_amdinitreset failed: %x /n", val);	} else {		printk(BIOS_DEBUG, "agesawrapper_amdinitreset passed/n");	}	if (!cpu_init_detectedx && boot_cpu()) {		post_code(0x38);		/*		 * SR5650/5670/5690 RD890 chipset, read pci config space hang at POR,		 * Disable all Pcie Bridges to work around It.		 */		sr56x0_rd890_disable_pcie_bridge();		post_code(0x39);		nb_Poweron_Init();		post_code(0x3A);		sb_Poweron_Init();	}	post_code(0x3B);	val = agesawrapper_amdinitearly();	if(val) {		printk(BIOS_DEBUG, "agesawrapper_amdinitearly failed: %x /n", val);	} else {		printk(BIOS_DEBUG, "agesawrapper_amdinitearly passed/n");	}	post_code(0x3C);	/* W83627DHG pin89,90 function select is RSTOUT3#, RSTOUT2# by default.	 * In order to access W83795G/ADG HWM using I2C protocol,	 * we select function to SDA, SCL function (or GP33, GP32 function).	 */	w83627dhg_enable_i2c(PNP_DEV(0x2E, W83627DHG_SPI));	nb_Ht_Init();	post_code(0x3D);	/* Reset for HT, FIDVID, PLL and ucode patch(errata) changes to take affect. */	if (!warm_reset_detect(0)) {		print_info("...WARM RESET.../n/n/n");		distinguish_cpu_resets(0);		soft_reset();		die("After soft_reset_x - shouldn't see this message!!!/n");	}	post_code(0x40);	val = agesawrapper_amdinitpost();	if (val) {		printk(BIOS_DEBUG, "agesawrapper_amdinitpost failed: %x /n", val);	} else {		printk(BIOS_DEBUG, "agesawrapper_amdinitpost passed/n");	}	post_code(0x41);	val = agesawrapper_amdinitenv();	if(val) {		printk(BIOS_DEBUG, "agesawrapper_amdinitenv failed: %x /n", val);	}	printk(BIOS_DEBUG, "agesawrapper_amdinitenv passed/n");	post_code(0x42);	post_code(0x50);	print_debug("Disabling cache as ram ");	disable_cache_as_ram();	print_debug("done/n");	post_code(0x51);	setup_i8259 ();	setup_i8254 ();	copy_and_run();	/* We will not return,  Should never see this message and post code. */	print_debug("should not be here -/n");//.........这里部分代码省略.........
开发者ID:DarkDefender,项目名称:coreboot,代码行数:101,


示例19: SystemInit

/** **************************************************************************************** * @brief  Setup the microcontroller system. * *  Initialize the system clock and pins. ***************************************************************************************** */void SystemInit(void){    /*     **************************     * Sub module clock setting     **************************     */    // Disable all peripheral clock, will be enabled in the driver initilization.    timer_clock_off(QN_TIMER0);    timer_clock_off(QN_TIMER1);    timer_clock_off(QN_TIMER2);    timer_clock_off(QN_TIMER3);    uart_clock_off(QN_UART0);    uart_clock_off(QN_UART1);    spi_clock_off(QN_SPI0);    usart_reset((uint32_t) QN_SPI1);    spi_clock_off(QN_SPI1);    flash_clock_off();    gpio_clock_off();    adc_clock_off();    dma_clock_off();    pwm_clock_off();        // Configure sytem clock.     syscon_set_sysclk_src(CLK_XTAL, __XTAL);    syscon_set_ahb_clk(__AHB_CLK);    syscon_set_ble_clk(__BLE_CLK);    syscon_set_apb_clk(__APB_CLK);    syscon_set_timer_clk(__TIMER_CLK);    syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK);    syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK);      clk32k_enable(__32K_TYPE);        /*     **************************     * IO configuration     **************************     */    SystemIOCfg();    /*     **************************     * Peripheral setting     **************************     */    // GPIO initialization for led, button & test control pin.    gpio_init(NULL);    // LED    led_init();    // Test controll pin is input to check work mode#if (defined(QN_TEST_CTRL_PIN))    gpio_pull_set(QN_TEST_CTRL_PIN, GPIO_PULL_UP);    gpio_set_direction_field(QN_TEST_CTRL_PIN, (uint32_t)GPIO_INPUT);    #if (defined(CFG_HCI_UART))    // Initialize HCI UART port    uart_init(QN_HCI_PORT, USARTx_CLK(0), UART_9600);    uart_tx_enable(QN_HCI_PORT, MASK_ENABLE);    uart_rx_enable(QN_HCI_PORT, MASK_ENABLE);#elif (defined(CFG_HCI_SPI))    // Initialize HCI SPI port    spi_init(QN_HCI_PORT, SPI_BITRATE(1000000), SPI_8BIT, SPI_SLAVE_MOD);    gpio_set_direction_field(CFG_HCI_SPI_WR_CTRL_PIN, (uint32_t)GPIO_OUTPUT);    gpio_write_pin(CFG_HCI_SPI_WR_CTRL_PIN, GPIO_HIGH);#endif#endif#if (QN_DBG_PRINT)    uart_init(QN_DEBUG_UART, USARTx_CLK(0), UART_9600);    uart_tx_enable(QN_DEBUG_UART, MASK_ENABLE);    uart_rx_enable(QN_DEBUG_UART, MASK_ENABLE);#endif}
开发者ID:hiccchen,项目名称:d-gitku,代码行数:85,


示例20: user_init

void user_init(unsigned char init){   unsigned char i;   xdata char str[64];   SFRPAGE = ADC0_PAGE;   AMX0CF = 0x00;               // select single ended analog inputs   ADC0CF = 0xE0;               // 16 system clocks, gain 1   ADC0CN = 0x80;               // enable ADC    REF0CN = 0x00;               // use external voltage reference   SFRPAGE = LEGACY_PAGE;   REF0CN = 0x02;               // select external voltage reference   SFRPAGE = DAC0_PAGE;   DAC0CN = 0x80;               // enable DAC0   SFRPAGE = DAC1_PAGE;   DAC1CN = 0x80;               // enable DAC1   /* open drain(*) /push-pull:       P0.0 TX1      P1.0 TP6          P2.0 LED1         P3.0 RELAIS0      P0.1*RX1      P1.1 BACKLIGHT    P2.1 LCD_E        P3.1 RELAIS1      P0.2 TX2      P1.2 TP5          P2.2 LCD_RW       P3.2 RELAIS2      P0.3*RX2      P1.3 TP7          P2.3 LCD_RS       P3.3 RELAIS3                                                                            P0.4 EN1      P1.4 WATCHDOG     P2.4 LCD_DB4      P3.4 DOUT0      P0.5 EN2      P1.5 SRSTROBE     P2.5 LCD_DB5      P3.5 DOUT1      P0.6 LED2     P1.6*SRIN         P2.6 LCD_DB6      P3.6 DOUT2      P0.7 BUZZER   P1.7 SRCLK        P2.7 LCD_DB7      P3.7 DOUT3    */   SFRPAGE = CONFIG_PAGE;   P0MDOUT = 0xF5;   P1MDOUT = 0xBF;   P2MDOUT = 0xFF;   P3MDOUT = 0xFF;   /* initial EEPROM value */   if (init) {      user_data.station_on = 0;      user_data.valve_locked = 0;      user_data.vacuum_ok = 0;      user_data.man_mode = 0;      for (i=0 ; i<4 ; i++)         user_data.relais[i] = 0;      for (i=0 ; i<8 ; i++) {         user_data.aofs[i] = 0;         user_data.again[i] = 1;      }      user_data.evac_timeout = 60; // 1h to pump recipient      user_data.fp_cycle = 20;     // run fore pump for min. 20 sec.      user_data.vv_max = 4;        // start fore pump at 4 mbar           user_data.vv_min = 0.4;      // stop fore pump at 0.4 mbar      user_data.hv_thresh = 1E-3;  // vacuum ok if < 10^-3 mbar   }   /* write digital outputs */   for (i=0 ; i<20 ; i++)      user_write(i);   /* initialize UART1 for TC600 */   uart_init(1, BD_9600);   /* turn on turbo pump motor (not pump station) */   tc600_write(23, 6, 111111);   /* get parameter 315 (TMP finspd) */   tc600_read(315, str);   user_data.final_speed = atoi(str);   /* display startup screen */   lcd_goto(0, 0);   for (i=0 ; i<7-strlen(sys_info.node_name)/2 ; i++)      puts(" ");   puts("** ");   puts(sys_info.node_name);   puts(" **");   lcd_goto(0, 1);   printf("  Address:   %04X", sys_info.node_addr);   lcd_goto(0, 2);   strcpy(str, svn_revision + 21);   *strchr(str, ' ') = 0;   printf("  Revision:  %s", str);   user_data.error = 0;}
开发者ID:uwmuonlab,项目名称:gm2-nmr-daq,代码行数:89,


示例21: main_loop

void main_loop(){    uart_default_config(&current_config);    if (uart_init(&uart,                  handle_write_completed,                  handle_read_completed,                  handle_notify_read) < 0)        errx(EXIT_FAILURE, "uart_init failed");    struct erlcmd *handler = malloc(sizeof(struct erlcmd));    erlcmd_init(handler, handle_elixir_request, NULL);    bool running = true;    while (running) {        HANDLE handles[3];        handles[0] = erlcmd_wfmo_event(handler);        DWORD timeout = INFINITE;        DWORD count = 1 + uart_add_wfmo_handles(uart, &handles[1], &timeout);        debug("Calling WFMO count=%d", (int) count);        DWORD result = WaitForMultipleObjects(count,                                              handles,                                              FALSE,                                              timeout);        debug("WFMO returned %d", (int) result);        switch(result) {        case WAIT_OBJECT_0 + 0:            if (erlcmd_process(handler))                running = false;            break;        case WAIT_OBJECT_0 + 1:            uart_process_handle(uart, handles[1]);            break;        case WAIT_OBJECT_0 + 2:            uart_process_handle(uart, handles[2]);            break;        case WAIT_TIMEOUT:            uart_process_timeout(uart);            break;        case WAIT_FAILED:            debug("WFMO wait failed! %d", (int) GetLastError());            // TODO: Is this ever a transient occurrence that we            //       should ignore and retry?            running = false;            break;        default:            break;        }    }    // Exit due to Erlang trying to end the process.    if (uart_is_open(uart))        uart_flush_all(uart);}
开发者ID:nerves-project,项目名称:nerves_uart,代码行数:64,


示例22: welcome

void welcome(void){    uart_baudrate();    uart_init();    UARTSTR("c51drv/n");}
开发者ID:tpimh,项目名称:c51drv,代码行数:6,


示例23: hardware_init

void hardware_init() {//    setup_heap();    for(unsigned int i=bss_start;i<bss_end;i+=4) PUT32(i,0);    uart_init();}
开发者ID:EQ4,项目名称:pixperiments,代码行数:5,


示例24: main

int main(void){    unsigned int c;    char buffer[7];    int  num=134;        /*     *  Initialize UART library, pass baudrate and AVR cpu clock     *  with the macro      *  UART_BAUD_SELECT() (normal speed mode )     *  or      *  UART_BAUD_SELECT_DOUBLE_SPEED() ( double speed mode)     */    uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );         /*     * now enable interrupt, since UART library is interrupt controlled     */    sei();        /*     *  Transmit string to UART     *  The string is buffered by the uart library in a circular buffer     *  and one character at a time is transmitted to the UART using interrupts.     *  uart_puts() blocks if it can not write the whole string to the circular      *  buffer     */    uart_puts("String stored in SRAM/n");        /*     * Transmit string from program memory to UART     */    uart_puts_P("String stored in FLASH/n");                /*      * Use standard avr-libc functions to convert numbers into string     * before transmitting via UART     */         itoa( num, buffer, 10);   // convert interger into string (decimal format)             uart_puts(buffer);        // and transmit string to UART        /*     * Transmit single character to UART     */    uart_putc('/r');        for(;;)    {        /*         * Get received character from ringbuffer         * uart_getc() returns in the lower byte the received character and          * in the higher byte (bitmask) the last receive error         * UART_NO_DATA is returned when no data is available.         *         */        c = uart_getc();        if ( c & UART_NO_DATA )        {            /*              * no data available from UART              */        }        else        {            /*             * new data available from UART             * check for Frame or Overrun error             */            if ( c & UART_FRAME_ERROR )            {                /* Framing Error detected, i.e no stop bit detected */                uart_puts_P("UART Frame Error: ");            }            if ( c & UART_OVERRUN_ERROR )            {                /*                  * Overrun, a character already present in the UART UDR register was                  * not read by the interrupt handler before the next character arrived,                 * one or more received characters have been dropped                 */                uart_puts_P("UART Overrun Error: ");            }            if ( c & UART_BUFFER_OVERFLOW )            {                /*                  * We are not reading the receive buffer fast enough,                 * one or more received character have been dropped                  */                uart_puts_P("Buffer overflow error: ");            }            /*              * send received character back             */            uart_putc( (unsigned char)c );        }    }    //.........这里部分代码省略.........
开发者ID:alf632,项目名称:avr,代码行数:101,


示例25: stm32_debug_init

/* later in the init process */void stm32_debug_init(void){    uart_init();}
开发者ID:0xBADCA7,项目名称:lk,代码行数:5,


示例26: setup

//.........这里部分代码省略.........   RSTSRC |= 0x04;   /* default LED mode */   for (i=0 ; i<N_LED ; i++)      led_mode(i, 1);      /* initialize all memory */   CSR = 0;   addressed = 0;   flash_param = 0;   flash_program = 0;   flash_allowed = 0;   wrong_cpu = 0;   _flkey = 0;#ifdef CFG_HAVE_RTC   rtc_set = 0;#endif   i_in = i_out = n_out = 0;   _cur_sub_addr = 0;   for (i=0 ; i<sizeof(in_buf) ; i++)      in_buf[i] = 0;   for (i=0 ; i<sizeof(out_buf) ; i++)      out_buf[i] = 0;   /* check if we got reset by watchdog */#if defined(CPU_C8051F120)   SFRPAGE   = LEGACY_PAGE;#endif   WD_RESET = ((RSTSRC & 0x02) == 0 && (RSTSRC & 0x08) > 0);   /* initialize UART(s) */   uart_init(0, BD_115200);#ifdef CFG_UART1_MSCB   uart_init(1, BD_115200);#endif#ifdef CFG_DYN_VARIABLES   setup_variables();#endif   /* count variables */   for (n_variables = _var_size = 0;; n_variables++) {      _var_size += variables[n_variables].width;      if (variables[n_variables].width == 0)         break;   }   /* check if variables are in xdata and xdata is present */   if (n_variables > 0) {      p = variables[0].ud;      d = *p;      *p = 0x55;      if (*p != 0x55)         wrong_cpu = 1;      *p = 0xAA;      if (*p != 0xAA)         wrong_cpu = 1;      *p = d;   }   /* retrieve EEPROM data */#ifdef CPU_C8051F120   SFRPAGE = LEGACY_PAGE;
开发者ID:wuchen1106,项目名称:DAQ,代码行数:67,


示例27: main

void main(void) {	nvmType_t type=0;	nvmErr_t err;	volatile uint8_t c;	volatile uint32_t i;	volatile uint32_t buf[4];	volatile uint32_t len=0;	volatile uint32_t state = SCAN_X;	volatile uint32_t addr,data;	uart_init(INC, MOD, SAMP);	disable_irq(UART1);	vreg_init();	dbg_putstr("Detecting internal nvm/n/r");	err = nvm_detect(gNvmInternalInterface_c, &type);			dbg_putstr("nvm_detect returned: 0x");	dbg_put_hex(err);	dbg_putstr(" type is: 0x");	dbg_put_hex32(type);	dbg_putstr("/n/r");		/* erase the flash */	err = nvm_erase(gNvmInternalInterface_c, type, 0x7fffffff); 	dbg_putstr("nvm_erase returned: 0x");	dbg_put_hex(err);	dbg_putstr("/n/r");	dbg_putstr(" type is: 0x");	dbg_put_hex32(type);	dbg_putstr("/n/r");	/* say we are ready */	len = 0;	putstr("ready");	flushrx();	/* read the length */	for(i=0; i<4; i++) {		c = uart1_getc();		/* bail if the first byte of the length is zero */		len += (c<<(i*8));	}	dbg_putstr("len: ");	dbg_put_hex32(len);	dbg_putstr("/n/r");		/* write the OKOK magic */#if BOOT_OK	((uint8_t *)buf)[0] = 'O'; ((uint8_t *)buf)[1] = 'K'; ((uint8_t *)buf)[2] = 'O'; ((uint8_t *)buf)[3] = 'K';	#elif BOOT_SECURE	((uint8_t *)buf)[0] = 'S'; ((uint8_t *)buf)[1] = 'E'; ((uint8_t *)buf)[2] = 'C'; ((uint8_t *)buf)[3] = 'U';	#else	((uint8_t *)buf)[0] = 'N'; ((uint8_t *)buf)[1] = 'O'; ((uint8_t *)buf)[2] = 'N'; ((uint8_t *)buf)[3] = 'O';#endif	dbg_putstr(" type is: 0x");	dbg_put_hex32(type);	dbg_putstr("/n/r");	/* don't make a valid boot image if the received length is zero */	if(len == 0) {		((uint8_t *)buf)[0] = 'N'; 		((uint8_t *)buf)[1] = 'O'; 		((uint8_t *)buf)[2] = 'N'; 		((uint8_t *)buf)[3] = 'O';	}		err = nvm_write(gNvmInternalInterface_c, type, (uint8_t *)buf, 0, 4);	dbg_putstr("nvm_write returned: 0x");	dbg_put_hex(err);	dbg_putstr("/n/r");	/* write the length */	err = nvm_write(gNvmInternalInterface_c, type, (uint8_t *)&len, 4, 4);	/* read a byte, write a byte */	for(i=0; i<len; i++) {		c = getc();	       		err = nvm_write(gNvmInternalInterface_c, type, (uint8_t *)&c, 8+i, 1); 	}	putstr("flasher done/n/r");	state = SCAN_X; addr=0;	while((c=getc())) {		if(state == SCAN_X) {			/* read until we see an 'x' */			if(c==0) { break; }			if(c!='x'){ continue; } 				/* go to read_chars once we have an 'x' */			state = READ_CHARS;//.........这里部分代码省略.........
开发者ID:leoqin,项目名称:Contiki-leo,代码行数:101,


示例28: main

intmain(void){  wdt_disable();  clock_prescale_set(clock_div_1);  led_init();  LED_ON();  spi_init();//  eeprom_factory_reset("xx");  eeprom_init();// Setup OneWire and make a full search at the beginning (takes some time)#ifdef HAS_ONEWIRE  i2c_init();	onewire_Init();	onewire_FullSearch();#endif  // Setup the timers. Are needed for watchdog-reset#if defined (HAS_IRRX) || defined (HAS_IRTX)  ir_init();  // IR uses highspeed TIMER0 for sampling   OCR0A  = 1;                              // Timer0: 0.008s = 8MHz/256/2   == 15625Hz#else  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz#endif  TCCR0B = _BV(CS02);  TCCR0A = _BV(WGM01);  TIMSK0 = _BV(OCIE0A);  TCCR1A = 0;  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog  wdt_enable(WDTO_2S);  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );  fht_init();  tx_init();  input_handle_func = analyze_ttydata;  display_channel = DISPLAY_USB;#ifdef HAS_RF_ROUTER  rf_router_init();  display_channel |= DISPLAY_RFROUTER;#endif  LED_OFF();  sei();  for(;;) {    uart_task();    RfAnalyze_Task();    Minute_Task();#ifdef HAS_FASTRF    FastRF_Task();#endif#ifdef HAS_RF_ROUTER    rf_router_task();#endif#ifdef HAS_ASKSIN    rf_asksin_task();#endif#ifdef HAS_MORITZ    rf_moritz_task();#endif#ifdef HAS_RWE    rf_rwe_task();#endif#ifdef HAS_RFNATIVE    native_task();#endif#ifdef HAS_KOPP_FC    kopp_fc_task();#endif#if defined(HAS_IRRX) || defined(HAS_IRTX)    ir_task();#endif#ifdef HAS_MBUS    rf_mbus_task();#endif#ifdef HAS_ZWAVE    rf_zwave_task();#endif  }}
开发者ID:Talustus,项目名称:culfw,代码行数:93,


示例29: Initialization

//.........这里部分代码省略.........				(void)irq_setHdr( (unsigned char)IRQ_NO_TMBINT, TMRAB_ISR );  //Clear interrupt request flag					ETMA = 1;	  	// Enable timer 8 Interrupt (1=ENABLED					ETMB = 1;	  	// Enable timer 9 Interrupt (1=ENABLED)					QTMA = 0;		// timer 8 IRQ request flag; 1=REQUEST					QTMB = 0;		// timer 9 IRQ request flag; 1=REQUEST					TACS0 = 1;		// 111 => Select PLLCLK					TACS1 = 1;					TACS2 = 1;					TBCS0 = 1;		// 111 => Select PLLCLK					TBCS1 = 1;					TBCS2 = 1; 					tm_init(TM_CH_NO_AB);					tm_setABData(8192);				//A value of 1023 should yield 125us interrupts at 8.192 MHz					tm_setABSource(TM_CS_HTBCLK);					tm_startAB();					TABM16 = 1;		//1 => sets 16-bit timer mode									HTD3 = 1;	//High-Speed Time Base Counter Divide Register: 1111 = 9182kHz					HTD2 = 1;					HTD1 = 1;					HTD0 = 1; 			//----------------------------------------------------------------------------------------						//------------- SET UP TIMER E/F Interrupt to increment timers every ~X ms ---------------				(void)irq_setHdr( (unsigned char)IRQ_NO_TMFINT, TMREF_ISR );  //Clear interrupt request flag					ETME = 1;	  	// Enable timer E Interrupt (1=ENABLED					ETMF = 1;	  	// Enable timer F Interrupt (1=ENABLED)					QTME = 0;		// Timer E IRQ request flag; 1=REQUEST					QTMF = 0;		// Timer F IRQ request flag; 1=REQUEST					TECS0 = 1;		// 111 => Select PLLCLK					TECS1 = 1;					TECS2 = 1;					TFCS0 = 1;		// 111 => Select PLLCLK					TFCS1 = 1;					TFCS2 = 1;					tm_init(TM_CH_NO_EF);					tm_setEFData(8192);				//A value of 1023 should yield 125us interrupts at 8.192 MHz					tm_setEFSource(TM_CS_HTBCLK);					tm_startEF();					TEFM16 = 1;		//1 => sets 16-bit timer mode									HTD3 = 1;	//High-Speed Time Base Counter Divide Register: 1111 = 9182kHz					HTD2 = 1;					HTD1 = 1;					HTD0 = 1; 			//----------------------------------------------------------------------------------------						//------------- SET UP B.3 as an input, and prepare to use as an external interrupt ------					PB3DIR = 1;					PB3C1 = 0;					PB3C0 = 0;					PB3MD1 = 0;					PB3MD0 = 0;					PB3E1 = 1;					PB3E0 = 0;		//PBnE0-1 are used to choose the Rising-Edge Mode for this interrupt					PB3SM = 0;			// -----			//------------- SET UP EXTERNAL INTERRUPT on B.3 -----------------------------------------			//Options include following pins: A.0; A.1; A.2. B.0; B.1; B.2 & B.3			(void)irq_setHdr( (unsigned char)IRQ_NO_PB3INT, ExtInt_ISR );  //Clear interrupt request flag					EPB3 = 0;	// 1=> Enables Interrupt					QPB3 = 0;	// EXT IRQ request flag; 1=REQUEST				//----------------------------------------------------------------------------------------   					irq_ei(); // Enable Interrupts	// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII  	// ===== SET UP WATCH DOG TIMER =============================================		WDTMOD = 0x03; 	// 0x03=overflow 8sec...		main_clrWDT(); 	// Clear WDT   	//===========================================================================			// ===== UART Initialization ================================================	//	//	Pin PB0 of mcu => RX  	// 	Pin PB1 of mcu => TX 	// 		(void)uart_init( (unsigned char)UART_CS_HSCLK,	// Generator       								 (unsigned short)HSCLK_KHZ,				// HSCLK frequency 								 &_uartSetParam );						// Parameters from Structure    		uart_PortSet();									// Set UART Port Pins		_flgUartFin = 0;		uart_stop();	//		//===========================================================================	// ===== I2C Initialization =================================================	//	(void)i2c_init(I2C_MOD_FST, (unsigned short)HSCLK_KHZ, I2C_SYN_ON);	//	I20SYN = 1;		//Enable Clock Stretching		//===========================================================================				}//End Initialization
开发者ID:Jfontus,项目名称:Q111_FeRAM_Firmware,代码行数:101,


示例30: user_init

void user_init(void){	uint8_t i;	UartDev.data_bits = EIGHT_BITS;	UartDev.parity = NONE_BITS;	UartDev.stop_bits = ONE_STOP_BIT;	uart_init(BIT_RATE_9600, BIT_RATE_9600);	i2c_init();	SSD1306Init();	clearScreen();	stringDraw(5, 1, "SDK ver:");	stringDraw(5, 48, (char*)system_get_sdk_version());	ets_uart_printf("reset reason: %d/n", reset_info->reason);	ets_uart_printf("Booting.../n");	ets_uart_printf("SDK version:%s/n", system_get_sdk_version());	setup_wifi_st_mode();	if(wifi_get_phy_mode() != PHY_MODE_11N)		wifi_set_phy_mode(PHY_MODE_11N);	if(wifi_station_get_auto_connect() == 0)		wifi_station_set_auto_connect(1);#ifdef CONFIG_DYNAMIC	flash_param_t *flash_param;	flash_param_init();	flash_param = flash_param_get();	UartDev.data_bits = GETUART_DATABITS(flash_param->uartconf0);	UartDev.parity = GETUART_PARITYMODE(flash_param->uartconf0);	UartDev.stop_bits = GETUART_STOPBITS(flash_param->uartconf0);	uart_init(flash_param->baud, BIT_RATE_115200);#else#endif	serverInit_telnet();	serverInit_http();#ifdef CONFIG_GPIO	config_gpio();#endif	//		os_timer_disarm(&timer_1);	//		os_timer_setfn(&timer_1, (os_timer_func_t *)timer_1_int, NULL);	//		os_timer_arm(&timer_1, 1000, 1);	// Wait for Wi-Fi connection	os_timer_disarm(&WiFiLinker);	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);	os_timer_arm(&WiFiLinker, 1000, 0);	system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen);}
开发者ID:LeandroTE,项目名称:ESP8266,代码行数:68,



注:本文中的uart_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ uart_insert_char函数代码示例
C++ uart_handle_sysrq_char函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。