int main(int argc, char ** argv) { int board, i, j; int retSize = -1; char *devName = GPIO_IR_DEV; int pin = GPIO_PIN(7); char modStr[BUF_SIZE]; struct input_event evKey; if ((board = boardInit()) < 0) printf("Fail to init board\n"); if (board == BOARD_NANOPI_T2) pin = GPIO_PIN(15); sprintf(modStr, "modprobe %s gpio=%d", IR_DRIVER_MODULE, pintoGPIO(pin)); system(modStr); signal(SIGINT, IRIntHandler); sleep(1); irFD = openHW(devName, O_RDWR); if (irFD < 0) { printf("Fail to open GPIO IR device\n"); return -1; } printf("Press the IR remoter\n"); for (i=0; i<IR_EVENT_TIMES; i++) { if (selectHW(irFD, 0, 0) == 1) { retSize = readHW(irFD, &evKey, sizeof(struct input_event)); for (j=0; j<(int) retSize / sizeof(struct input_event); j++) printf("%2d: Type=%d, Code=%d, Value=%x\n", i, evKey.type, evKey.code, evKey.value); } } closeHW(irFD); system("rmmod "IR_DRIVER_MODULE); return 0; }
//**************************************************************************************** int main(void) { boardInit(); // Board peripherals initialization systemStart(); // Infinite loop }
int main(void) { #if defined(__AVR_ATmega644P__) // Wiring specific boardInit(); #else init(); #if defined(USBCON) // Arduino 1.0 specific USBDevice.attach(); #endif #endif setup(); for (;;) { loop(); #if defined(ARDUINO) && (ARDUINO >= 100) // Arduino 1.0 specific if (serialEventRun) serialEventRun(); #endif } return 0; }
int main(void) { uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; /* Configure the HW */ boardInit(); while (1) { /* Blinky (1Hz) */ currentSecond = delayGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; //boardLED(lastSecond % 2); } #ifdef CFG_ERPC erpc_task(NULL); #endif /* Check for binary protocol input if CFG_PROTOCOL is enabled */ #ifdef CFG_PROTOCOL prot_task(NULL); #endif /* Poll for CLI input if CFG_INTERFACE is enabled */ #ifdef CFG_INTERFACE cliPoll(); #endif } }
int main(void) { // Important for setting interrupts NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // initialize the hardware boardInit(); /* -------------------------------------------------------------------- */ /* Start the communication task routine */ /* -------------------------------------------------------------------- */ xTaskCreate(commTask, (char*) "commTask", 4092, NULL, 2, NULL); /* -------------------------------------------------------------------- */ /* Start the kalman filter task */ /* -------------------------------------------------------------------- */ xTaskCreate(kalmanTask, (char*) "kalman", 4092, NULL, 2, NULL); /* -------------------------------------------------------------------- */ /* Start the mpc task filter task */ /* -------------------------------------------------------------------- */ xTaskCreate(mpcTask, (char*) "mpcTask", 4092, NULL, 2, NULL); /* -------------------------------------------------------------------- */ /* Start the FreeRTOS scheduler */ /* -------------------------------------------------------------------- */ vTaskStartScheduler(); return 0; }
int main(int argc, char ** argv) { int ret = -1; int dhtTemp=0, dhtHdty=0, board; char modStr[BUF_SIZE]; int pin = GPIO_PIN(7); if ((board = boardInit()) < 0) { printf("Fail to init board\n"); return -1; } if (board == BOARD_NANOPI_T2) pin = GPIO_PIN(15); sprintf(modStr, "modprobe %s gpio=%d", DRIVER_MODULE, pintoGPIO(pin)); system(modStr); if ((ret = dht11Read(DHT_HUMIDITY, &dhtHdty)) != -1) { printf("The humidity is %d\n", dhtHdty); } else { printf("Faided to get humidity\n"); } if ((ret = dht11Read(DHT_TEMP, &dhtTemp)) != -1) { printf("The temperature is %d\n", dhtTemp); } else { printf("Faided to get temperature\n"); } system("rmmod "DRIVER_MODULE); return ret; }
int main(void) { uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; /* Configure the HW */ boardInit(); #if defined CFG_CMSIS_RTOS tid_blinkthread = osThreadCreate(osThread(blink_thread), NULL); tid_mainthread = osThreadGetId(); for (;;) { osDelay(1000); boardLED((currentSecond++) & 1); } #endif while (1) { currentSecond = delayGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; /* Blinky */ boardLED(lastSecond % 2); } /* Poll for CLI input if CFG_INTERFACE is enabled */ #ifdef CFG_INTERFACE cliPoll(); #endif } }
int main(int argc, char ** argv) { char *status = "off"; if (argc != 2) { printf("Set relay on\n"); } else { status = argv[1]; printf("Set relay %s\n", argv[1]); } int pin = GPIO_PIN(7); int ret = -1; boardInit(); if ((ret = exportGPIOPin(pin)) == -1) { printf("exportGPIOPin(%d) failed!", pin); } if ((ret = setGPIODirection(pin, GPIO_OUT)) != 0) { printf("setGPIODirection(%d) failed", pin); } if (strcmp(status, "on") == 0) { ret = setGPIOValue(pin, GPIO_HIGH); } else if (strcmp(status, "off") == 0) { ret = setGPIOValue(pin, GPIO_LOW); } return ret; }
int main(void) { // initialize the hardware boardInit(); /* -------------------------------------------------------------------- */ /* Start the communication task routine */ /* -------------------------------------------------------------------- */ xTaskCreate(commTask, (signed char*) "commTask", 650, NULL, 2, NULL); /* -------------------------------------------------------------------- */ /* Start the main task routine */ /* -------------------------------------------------------------------- */ xTaskCreate(mainTask, (signed char*) "mainTask", 750, NULL, 2, NULL); /* -------------------------------------------------------------------- */ /* Start the controllers task routine */ /* -------------------------------------------------------------------- */ xTaskCreate(controllersTask, (signed char*) "conTask", 512, NULL, 2, NULL); /* -------------------------------------------------------------------- */ /* Start the data logging task routine */ /* -------------------------------------------------------------------- */ xTaskCreate(logTask, (signed char*) "logTask", 1024, NULL, 2, NULL); /* -------------------------------------------------------------------- */ /* Start the FreeRTOS scheduler */ /* -------------------------------------------------------------------- */ vTaskStartScheduler(); return 0; }
int main(int argc, char ** argv) { int devFD; double angle; int i2cDev = 0; if (boardInit() < 0) { printf("Fail to init board\n"); return -1; } if (argc == 2) i2cDev = atoi(argv[1]); if ((devFD = hmc5883Init(i2cDev)) == -1) { printf("Fail to init hmc5883\n"); return -1; } if ((angle = hmc5883Read(devFD)) != -1) { printf("The angle is %.1f\n", angle); } else { printf("Fail to read hmc5883\n"); } hmc5883DeInit(devFD); return 0; }
/** \brief Main function * * This is the main entry point of the software. * * \returns 0 * * \remarks This function never returns. Return value is only to avoid compiler * warnings or errors. */ int main(void) { /* perform the needed initialization here */ boardInit(); while(1) { /* add your code here */ /* Read TEC1 */ if( !(Chip_GPIO_ReadPortBit( LPC_GPIO_PORT, TEC1_GPIO, TEC1_PIN )) ){ /* Write LED with 1 */ Chip_GPIO_SetPinState( LPC_GPIO_PORT, gpioLed1.gpioNumber, gpioLed1.gpioPin, 1); Chip_GPIO_SetPinState( LPC_GPIO_PORT, gpioLed2.gpioNumber, gpioLed2.gpioPin, 0); } else{ /* Write LED with 0 */ Chip_GPIO_SetPinState( LPC_GPIO_PORT, gpioLed1.gpioNumber, gpioLed1.gpioPin, 0); Chip_GPIO_SetPinState( LPC_GPIO_PORT, gpioLed2.gpioNumber, gpioLed2.gpioPin, 1); } } return 0; }
int main(int argc, char ** argv) { int i = 0; int value = 0; int channel = 0; if (boardInit() < 0) { printf("Fail to init board\n"); return -1; } if (argc == 2) channel = atoi(argv[1]); system("modprobe "DRIVER_MODULE); signal(SIGINT, intHandler); for (i=0; i<ADC_READ_TIMES; i++) { if (pcf8591Read(channel, &value) != -1) { printf("The channel%d value is %d\n", channel, value); } else { printf("Fail to get channel%d value\n", channel); } } system("rmmod "DRIVER_MODULE); return 0; }
static void loadState() { r800LoadState(r800); boardInit(&r800->systemTime); deviceManagerLoadState(); slotLoadState(); sn76489LoadState(sn76489); }
int main(void) { /* Configure the HW */ boardInit(); while (1) { /* ToDo: Do something! */ } }
void init(void) { wirish::priv::board_setup_flash(); wirish::priv::board_setup_clocks(); wirish::priv::board_setup_gpio(); wirish::priv::board_setup_adcs(); wirish::priv::board_setup_timers(); wirish::priv::board_setup_usb(); wirish::priv::series_init(); boardInit(); }
int main(void) { // Hardware specific initializations. boardInit(); // User defined setup routine setup(); // User defined loop routine for (;;) loop(); }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); setupUSB(); boardInit(); }
int main(void) { #if defined(__AVR_ATmega644P__) // Wiring specific boardInit(); #else init(); #endif setup(); for (;;) loop(); return 0; }
void init(void) { setup_flash(); setup_clocks(); setup_nvic(); systick_init(SYSTICK_RELOAD_VAL); wirish::priv::board_setup_gpio(); setup_adcs(); setup_timers(); wirish::priv::board_setup_usb(); wirish::priv::series_init(); boardInit(); }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); // usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); boardInit(); }
int main(int argc, char ** argv) { int devFD; double angle; int i2cDev = 0; if (boardInit() < 0) printf("Fail to init board\n"); if (argc == 2) i2cDev = atoi(argv[1]); if ((devFD = hmc5883Init(i2cDev)) == -1) { printf("Fail to init hmc5883\n"); return -1; } if ((angle = hmc5883Read(devFD)) == -1) { printf("Fail to read hmc5883\n"); hmc5883DeInit(devFD); return -1; } printf("The angle is %.1f\n", angle); printf("You are heading "); if((angle < 22.5) || (angle > 337.5 )) { printf("South\n"); } else if((angle > 22.5) && (angle < 67.5 )) { printf("South-West\n"); } else if((angle > 67.5) && (angle < 112.5 )) { printf("West\n"); } else if((angle > 112.5) && (angle < 157.5 )) { printf("North-West\n"); } else if((angle > 157.5) && (angle < 202.5 )) { printf("North\n"); } else if((angle > 202.5) && (angle < 247.5 )) { printf("NorthEast\n"); } else if((angle > 247.5) && (angle < 292.5 )) { printf("East\n"); } else if((angle > 292.5) && (angle < 337.5 )) { printf("SouthEast\n"); } hmc5883DeInit(devFD); return 0; }
int main(int argc, char ** argv) { int i = 0; int x, y; x = y = 0; boardInit(); for (i=0; i<PS2_READ_TIMES; i++) { if (pcf8591Read(1, &x) != -1 && pcf8591Read(2, &y) != -1) { printf("x=%4d y=%4d\n", x, y); } } return 0; }
static void loadState() { SaveState* state = saveStateOpenForRead("svi"); svi80ColEnabled = saveStateGet(state, "svi80ColEnabled", 0); psgAYReg15 = (UInt8)saveStateGet(state, "psgAYReg15", 0); saveStateClose(state); r800LoadState(r800); boardInit(&r800->systemTime); deviceManagerLoadState(); slotLoadState(); ay8910LoadState(ay8910); }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); // setupUSB(); #if !defined(BOARD_STM32VLD) setupUSB(); #endif boardInit(); }
int main(void) { uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; /* Configure the HW */ boardInit(); while (1) { /* Blinky (1Hz) */ currentSecond = delayGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; boardLED(lastSecond % 2); } /* Check for binary protocol input if CFG_PROTOCOL is enabled */ #ifdef CFG_PROTOCOL prot_task(NULL); #endif /* Poll for CLI input if CFG_INTERFACE is enabled */ #ifdef CFG_INTERFACE cliPoll(); #endif // if ( usb_custom_is_ready_to_send() ) // { // static uint32_t magic_number = 0; // uint32_t buffer[2][16]; // 2x64 byte in size // buffer[0][0] = magic_number++; // buffer[1][0] = magic_number++; // usb_custom_send(buffer, 64*2); // } // // if (custom_recv_magic_number != 0) // { // printf("%d\n", custom_recv_magic_number); // custom_recv_magic_number = 0; // } /* Optionally enter high level sleep mode here via WFI */ } }
int main(void) { app_timer_id_t blinky_timer_id; /* Initialize the target HW */ boardInit(); /* Initialise BLE and start advertising as an iBeacon */ btle_init(); /* Initialise a 1 second blinky timer to show that we're alive */ ASSERT_STATUS ( app_timer_create(&blinky_timer_id, APP_TIMER_MODE_REPEATED, blinky_handler) ); ASSERT_STATUS ( app_timer_start (blinky_timer_id, APP_TIMER_TICKS(1000, CFG_TIMER_PRESCALER), NULL) ); while(true) { } }
int main(void) { /* Initiaise the HW */ boardInit(); /* Initialise the RTX kernel */ osKernelInitialize(); /* Create out threads */ tid_mainthread = osThreadCreate(osThread(main_thread), NULL); tid_blinkythread = osThreadCreate(osThread(blinky_thread), NULL); /* Start the kernel and then go into an endless loop */ osKernelStart(); /* No return */ while(1); return 1; }
int main(int argc, char *argv[]) { PIOS_SYS_Args(argc, argv); #else int main() { #endif /* NOTE: Do NOT modify the following start-up sequence */ /* Any new initialization functions should be added in OpenPilotInit() */ PIOS_heap_initialize_blocks(); #if defined(PIOS_INCLUDE_CHIBIOS) halInit(); chSysInit(); boardInit(); #endif /* defined(PIOS_INCLUDE_CHIBIOS) */ /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); /* For Revolution we use a FreeRTOS task to bring up the system so we can */ /* always rely on FreeRTOS primitive */ initTaskHandle = PIOS_Thread_Create(initTask, "init", INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY); PIOS_Assert(initTaskHandle != NULL); #if defined(PIOS_INCLUDE_FREERTOS) /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); /* If all is well we will never reach here as the scheduler will now be running. */ /* Do some PIOS_LED_HEARTBEAT to user that something bad just happened */ PIOS_LED_Off(PIOS_LED_HEARTBEAT); \ for(;;) { \ PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); \ PIOS_DELAY_WaitmS(100); \ }; #elif defined(PIOS_INCLUDE_CHIBIOS) PIOS_Thread_Sleep(PIOS_THREAD_TIMEOUT_MAX); #endif /* defined(PIOS_INCLUDE_CHIBIOS) */ return 0; }
static UINT32 sysCoreInit( void ) { #if 0 // gp_board static linked with kernel /* board core init */ boardCoreInit(); #endif apbdma0Init(); if( gp_ver.major == MACH_GPL32900 ) { i2cInit(); } if( gp_ver.major == MACH_GPL32900B ) { i2cInit(); ti2cInit(); } timerInit(); pwmInit(); adcInit(); dc2dcInit(); /* board config and board init */ boardInit(); /* display init */ displayInit(); // storageInit(); sysMknod("board", S_IFCHR); sysMknod("chunkmem", S_IFCHR); mknod("/dev/null", S_IFCHR|0660, makedev(MEM_MAJOR, 3)); return SP_OK; }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); setupUSB(); boardInit(); //for debug gpio_set_mode(GPIOA, 2, GPIO_AF_OUTPUT_PP); gpio_set_mode(GPIOA, 3, GPIO_INPUT_FLOATING); usart_init(USART2); usart_set_baud_rate(USART2, STM32_PCLK1, 57600); usart_enable(USART2); /*delay(1000); TxDString("hello pandora\r\n");*/ }