/******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { GPIO_InitTypeDef GPIO_InitStructure; NAND_IDTypeDef NAND_Id; NAND_ADDRESS NAND_Address; int i=0; #ifdef DEBUG debug(); #endif Set_System(); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); Serial_Init(); NAND_Init(); NAND_Reset(); NAND_ReadID(&NAND_Id); Get_Medium_Characteristics(); Set_USBClock(); USB_Interrupts_Config(); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(GPIOC, &GPIO_InitStructure); USB_Init(); while (1) { } }
int main(void) { char *utemp1, *ptemp1; unsigned char ret1; Serial_Init(); print_string("\t Welcome to uNiBash enviroment"); print_string("\r Username:"******"\r Password:"******"\rInvalid username or password"); return 0; } else OSInit(); //required for generating the idle task and statistic task //Creating tasks OSTaskCreate( Task1, (void *)0, &Task1Stack[ TASK_STACK - 1 ], 0 ); OSTaskCreate( Task2, (void *)0, &Task2Stack[ TASK_STACK - 1 ], 1 ); OSStart(); //Start multi-tasking return 0; }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Hardware Initialization */ Serial_Init(115200, false); LEDs_Init(); USB_Init(); /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ TCCR0B = (1 << CS02); /* Must turn off USART before reconfiguring it, otherwise incorrect operation may occur */ UCSR1B = 0; UCSR1A = 0; UCSR1C = 0; UBRR1 = SERIAL_2X_UBBRVAL(115200); UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10)); UCSR1A = (1 << U2X1); UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1)); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { PINSEL_CFG_Type PinCfg; PinCfg.Funcnum = 0; PinCfg.OpenDrain = 0; PinCfg.Pinmode = 0; PinCfg.Portnum = 2; PinCfg.Pinnum = 10; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 11; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 12; PINSEL_ConfigPin(&PinCfg); /* is Input */ GPIO_SetDir(2, (1<<10), 0); GPIO_SetDir(2, (1<<11), 0); GPIO_SetDir(2, (1<<12), 0); /* Enable system update tick timer */ GPIO_SetDir(LED1_GPIO_PORT_NUM,(1<<LED1_GPIO_BIT_NUM),1); // output GPIO_SetDir(LED2_GPIO_PORT_NUM,(1<<LED2_GPIO_BIT_NUM),1); // output init_timer( 0, TIMER0_INTERVAL ); Serial_Init(115200, false); LEDs_Init(); USB_Init(); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); //USB_Init(); }
void api_init(void) { CILCR_LVL = 0; interrupts_init(); // button PIER07_IE0 = 1; PIER07_IE1 = 1; PIER07 |= 0x0c; PUCR07 |= 0x0c; Sema = 0; vSemaphoreCreateBinary(Sema); //Seg_Init(); Drive_Init(); //FRAM_Init(); Us_Init(); //CarId_Init(); ADC_Init(); Battery_Init(); Linesensor_Init(); //wirelessInit(); Serial_Init(); __EI(); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { #if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); #elif (ARCH == ARCH_XMEGA) /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; #endif /* Hardware Initialization */ LEDs_Init(); Serial_Init(9600, false); USB_Init(); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); }
int main(int argc, char **argv) { INT8 port_fd = 0; msg_que msg_buf; int err = 0; rev_pthread_param rev_param; pthread_t rev_pthid,read_msg_pthid; //pthread; port_fd = Open_Port(DEV_PORT0); Serial_Init(port_fd, 115200, 8, 'N', 1); rev_param.port_id = port_fd;// Init port_id Create_MSG_QUE("./term.c",6); //Create message queue attention the path err = pthread_create(&rev_pthid, NULL,(void *(*)(void *))Data_Rev, (void *)&rev_param); if(err != 0 ) printf("Create Data_Rev pthread error!\n"); else printf("Create Data_Rev pthread success!\n"); err = pthread_create(&read_msg_pthid, NULL,(void *(*)(void *))Read_MSG_QUE, (void *)NULL); if(err != 0 ) printf("Create Read_MSG_QUE pthread error!\n"); else printf("Create Read_MSG_QUE pthread success!\n"); while(1); }
void SetupHardware(void) { // Disable watchdog if enabled by bootloader/fuses MCUSR &= ~(1 << WDRF); wdt_disable(); Serial_Init(31250, false); // Start the flush timer so that overflows occur rapidly to // push received bytes to the USB interface TCCR0B = (1 << CS02); // Serial Interrupts UCSR1B = 0; UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1)); // https://github.com/ddiakopoulos/hiduino/issues/13 /* Target /ERASE line is active HIGH: there is a mosfet that inverts logic */ // These are defined in the makefile... AVR_ERASE_LINE_PORT |= AVR_ERASE_LINE_MASK; AVR_ERASE_LINE_DDR |= AVR_ERASE_LINE_MASK; // Disable clock division //clock_prescale_set(clock_div_1); CLKPR = (1 << CLKPCE); CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); LEDs_Init(); USB_Init(); LEDs_TurnOffLEDs(LEDS_LED1); LEDs_TurnOffLEDs(LEDS_LED2); }
int main(void) { unsigned char Mystring[20]; Serial_Init(); lcd_init(); print_string("\nSTART MAIN TIMER TEST"); Timer0_Init(); sei(); while(1) { if(Update_flag) { sprintf(Mystring,"%02d %02d %02d",(unsigned char)HRS_var,(unsigned char)MIN_var,(unsigned char)SEC_var); print_string("\n\r"); print_string(Mystring); lcd_gotoxy1(0); lcd_string(Mystring); Update_flag = 0; } } }
int main(int argc,char *argv[]) { int nTmp = 0,nTmp_1; unsigned char Buf[1024]; unsigned char Buf_1[1024]; Serial_Init(); #if 1 send_data_tty(SerFd,"hello serial\n",sizeof("hello serial\n")); send_data_tty(SerFd_1,"hello serial\n",sizeof("hello serial\n")); while(1){ nTmp_1 = read_datas_tty(SerFd_1,Buf_1,100,1024); if(nTmp){ printf("%s",Buf_1); } if(nTmp_1 > 0){ send_data_tty(SerFd_1,Buf_1,nTmp_1); } nTmp = read_datas_tty(SerFd,Buf,100,1024); if(nTmp){ printf("%s",Buf); } if(nTmp > 0){ send_data_tty(SerFd,Buf,nTmp); } } #endif }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); DDRC |= _BV(PC3); // Hold PWR On PORTC &= ~_BV(PC3); // . DDRE |= 1<<7; //Set UVconn HIGH PORTE |= 1<<7; /* Hold AUX PWR On */ // DDRC |= _BV(PC4); // PORTC &= ~_BV(PC4); /* Select USB Port BA */ DDRF |= _BV(PF4); PORTF |= _BV(PF4); /* Hardware Initialization */ Serial_Init(115200, true); // LEDs_Init(); // USB_Init(); USB_Init(USB_MODE_Host); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); // Camera_Enable(); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ #if defined(USB_CAN_BE_BOTH) USB_Init(USB_MODE_UID); #else USB_Init(); #endif LEDs_Init(); SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); Dataflash_Init(); Buttons_Init(); Serial_Init(9600, true); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); #if defined(USB_CAN_BE_DEVICE) /* Clear Dataflash sector protections, if enabled */ DataflashManager_ResetDataflashProtections(); #endif }
void main() { Serial_Init(9600); while(1) { putchar('D'); } }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void Camera_Enable(void) { /* Hardware Initialization */ Serial_Init(115200, true); USB_Init(USB_MODE_Host); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); }
/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* Write your local variable definition here */ uint16 countServo; int i; /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); ADC0_CFG2 |= ADC_CFG2_MUXSEL_MASK; /*** End of Processor Expert internal initialization. ***/ /* Write your code here */ /* For example: for(;;) { } */ /* * Motores são setados com valores de 0 a 255, 2o argumento resolve o sentido. */ cameraSIBit_ClrVal(); sMachine_Init(); Serial_Init(); enableMotor(); setMotor(0,1,0); setMotor(1,1,0); servoPWM_Enable(servoPWM_DeviceData); countServo = 19000; servoPWM_SetDutyUS(servoPWM_DeviceData,countServo); cameraCLK_Enable(); cameraCLK_EnableEvent(); cameraCLKBit_ClrVal(); while(1){ for (i=0; i < 128; i++){ vetorCamera[i] = getCamPixel(i); } for (i=0; i < 128; i++){ itoa(vetorCamera[i], buffer0); Send_String(buffer0); Send_String(" "); } Send_String("\r\n"); } /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
int main(void) { // Enable interrupts as early as possible sei(); Timer_Init(); Serial_Init(); uint8_t returnval = Can_Init(); if (returnval != CAN_OK) { } Can_Message_t txMsg; txMsg.Id = (CAN_NMT_APP_START << CAN_SHIFT_NMT_TYPE) | (NODE_ID << CAN_SHIFT_NMT_SID); txMsg.DataLength = 4; txMsg.RemoteFlag = 0; txMsg.ExtendedFlag = 1; txMsg.Data.words[0] = APP_TYPE; txMsg.Data.words[1] = APP_VERSION; // Set up callback for CAN reception, this is optional if only sending is required. BIOS_CanCallback = &can_receive; // Send CAN_NMT_APP_START BIOS_CanSend(&txMsg); while (1) { if (extRxMsgFull) { txMsg.Id = extRxMsg.Id; txMsg.DataLength = extRxMsg.DataLength; txMsg.RemoteFlag = extRxMsg.RemoteFlag; txMsg.ExtendedFlag = extRxMsg.ExtendedFlag; for (uint8_t i = 0; i < txMsg.DataLength; i++) { txMsg.Data.bytes[i] = extRxMsg.Data.bytes[i]; } BIOS_CanSend(&txMsg); extRxMsgFull = 0; // } if (rxMsgFull) { extTxMsg.Id = rxMsg.Id; extTxMsg.DataLength = rxMsg.DataLength; extTxMsg.RemoteFlag = rxMsg.RemoteFlag; extTxMsg.ExtendedFlag = rxMsg.ExtendedFlag; for (uint8_t i = 0; i < extTxMsg.DataLength; i++) { extTxMsg.Data.bytes[i] = rxMsg.Data.bytes[i]; } Can_Send(&extTxMsg); rxMsgFull = 0; // } } return 0; }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardwareKeyboard(void) { //bsp_init(); Serial_Init(9600, false); //LEDs_Init(); USB_Disable(); USB_CurrentMode = USB_MODE_Host; USB_Init(); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Hardware Initialization */ Serial_Init(115200, true); LEDs_Init(); USB_Init(); UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1)); }
/** Set the active state of a serial port. This is automatically set to true by any call to Serial_Write or Serial_Read. @param index Which serial port - SERIAL_0 or SERIAL_1 @param state An integer specifying the active state - 1 (on) or 0 (off). @return CONTROLLER_OK (=0) on success. */ int Serial_SetActive( int index, int state ) { if ( index < 0 || index >= SERIAL_PORTS ) return CONTROLLER_ERROR_ILLEGAL_INDEX; Serial_* sp = &Serial[ index ]; if ( state && !sp->active ) return Serial_Init( index ); else if( !state && sp->active ) return Serial_Deinit( index ); return CONTROLLER_OK; }
CPU_BOOLEAN App_SerialInit (void) { SERIAL_ERR err; #if (APP_SERIAL_CFG_TRACE_EN == DEF_ENABLED) SERIAL_IF_CFG uart_cfg; #endif Serial_Init(); /* Initial Serial module */ Serial_DevDrvAdd((CPU_CHAR *)"USART3", /* Add serial interface/device. */ (SERIAL_DEV_CFG *)&SerialDevCfg_STM32_USART3, (CPU_SIZE_T ) 52u, (CPU_SIZE_T ) 52u, (SERIAL_ERR *)&err); if (err != SERIAL_ERR_NONE) { return (DEF_FAIL); } #if (APP_SERIAL_CFG_TRACE_EN == DEF_ENABLED) uart_cfg.Baudrate = SERIAL_BAUDRATE_115200; uart_cfg.DataBits = SERIAL_DATABITS_8; uart_cfg.StopBits = SERIAL_STOPBITS_1; uart_cfg.Parity = SERIAL_PARITY_NONE; uart_cfg.FlowCtrl = SERIAL_FLOW_CTRL_NONE; App_SerTraceIF_Nbr = Serial_Open((CPU_CHAR *)APP_SERIAL_CFG_TRACE_PORT_NAME, (SERIAL_IF_CFG *)&uart_cfg, (SERIAL_ERR *)&err); if (err != SERIAL_ERR_NONE) { return (DEF_FAIL); } Serial_SetLineDrv((SERIAL_IF_NBR ) App_SerTraceIF_Nbr, (SERIAL_LINE_DRV_API *)&SerialLine_TTY , (SERIAL_ERR *)&err); Serial_Wr((SERIAL_IF_NBR )App_SerTraceIF_Nbr, (void *)"\n\n", (CPU_SIZE_T )2u, (CPU_INT32U )0u, (SERIAL_ERR *)&err); if (err != SERIAL_ERR_NONE) { return (DEF_FAIL); } #endif return (DEF_OK); }
int Device_init(void) { int i = 0; printf("Initial Sensor Host.\r\n"); //char *strDeviceName = "Temperature Sensor"; // //int rc = sqlite3_open(dbPath, &db); // //if (rc) { //fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); //exit(0); //} pthread_mutex_init(&device_control_access, NULL); pthread_mutex_init(&serial_access, NULL); #if DATABASE pthread_mutex_init(&db_token, NULL); if (sqlite3_open(dbPath, &db)) { printf("Can't open database: %s\n", sqlite3_errmsg(db)); db = NULL; // hold the token pthread_mutex_lock(&db_token); } #endif RaspiExt_Init(); Serial_Init(); for (i = 0; i < DEV_HOST_NUMBER; i++) { printf("Initial Sensor Host %d parameters.\r\n", i); dev_host[i].data_type = DATA_TYPE_FLOAT; dev_host[i].number = DEV_NUMBER_UNKNOWN; // unknown dev_host[i].type = DEV_UNKNOWN; // unknown dev_host[i].data = NULL; dev_host[i].polling_control.enable = 0; dev_host[i].polling_control.time_poll_ms = 200; dev_host[i].polling_control.destroy = 0; printf("Create thread poll for Sensor Host %d.\r\n", i); pthread_create(&polling_thread[i], NULL, &DevicePolling, (void *)i); } // create database push polling db_com_init(dev_host); return 0; }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ LEDs_Init(); USB_Init(); Serial_Init(9600, false); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); }
int main(void) { Serial_Init(); print_string("\n\r START MAIN"); //PORTD = 0x00; SW_DIR; while(1) { if(!(EXSW1)) /* check for pin for low */ print_string("\nSW1 PRESSED"); if(!(EXSW2)) /* check for pin for low */ print_string("\nSW2 PRESSED"); } }
void PTP_Enable(void) { configured = 0; /* Hardware Initialization */ USB_Init();//USB_MODE_Host); /* Create a stdio stream for the serial port for stdin and stdout */ #if defined(PTP_DEBUG) || defined(PTP_DEBUG_SELECTIVE) Serial_Init(115200, true); Serial_CreateStream(NULL); puts_P(PSTR("Camera Enabled.\r\n")); #endif PTP_Bytes_Remaining = 0; PTP_Ready = 0; PTP_Error = 0; PTP_Run_Task = 1; }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); Serial_Init(115200, true); /* Hardware Initialization */ LEDs_Init(); USB_Init(); UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Hardware Initialization */ Serial_Init(9600, false); LEDs_Init(); USB_Init(); /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ TCCR0B = (1 << CS02); /* Pull target /RESET line high */ AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK; }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable Clock Division */ CLKPR = (1 << CLKPCE); CLKPR = 0; /* Hardware Initialization */ Serial_Init(9600, false); LEDs_Init(); USB_Init(); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); }
void SetupHardware(void) { MY_SetLedAll(true); MY_Setup(); USB_Init(); LCD_Setup(); TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 400000)); Serial_Init(2000000, true); // noisy thing PORTC &= ~(1 << 6); DDRC |= (1 << 6); // don't txen PORTD &= ~(1 << 4); PORTD |= (1 << 2); // pull-up DDRD |= (1 << 4); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ Serial_Init(9600, false); LEDs_Init(); Buttons_Init(); ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32); ADC_SetupChannel(MIC_IN_ADC_CHANNEL); USB_Init(); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); setResetPin(false); /* Target /ERASE line is active HIGH: there is a mosfet that inverts logic */ AVR_ERASE_LINE_PORT |= AVR_ERASE_LINE_MASK; AVR_ERASE_LINE_DDR |= AVR_ERASE_LINE_MASK; /* Hardware Initialization */ Serial_Init(9600, false); LEDs_Init(); USB_Init(); /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ TCCR0B = (1 << CS02); }