int main(void) { // init clocks clock_init(); // init GPIO pin states gpio_init(); // init serial console console_init(); // wait for RTC to start up delay_ms(1000); // init RTC rtc_init(); // init calibration cal_init(); // init display (rtc_init(), cal_init() must must be called first!) display_init(); // call menu menu(); }
int main(int argc, char **argv) { struct frame_type frame; struct camera_control_block ccb; ccb.device.category = tir4_camera; ccb.diag = true; /* ccb.mode = operational_1dot; */ /* ccb.mode = operational_3dot; */ cal_init(&ccb); /* loop forever reading and printing results */ /* while (true) { */ /* cal_get_frame(&ccb, &frame); */ /* frame_print(frame); */ /* frame_free(&ccb, &frame); */ /* } */ int i; for(i=0; i<2000; i++) { cal_get_frame(&ccb, &frame); frame_print(frame); frame_free(&ccb, &frame); } /* call disconnects, turns all LEDs off */ cal_shutdown(&ccb); return 0; }
CK_RV C_Initialize(CK_VOID_PTR pReserved) { int ret = CKR_OK; CK_C_INITIALIZE_ARGS_PTR p_args; unsigned char initial_state = p11_get_init(); #if _DEBUG log_init(DEFAULT_LOG_FILE, LOG_LEVEL_PKCS11_INFO); #else log_init(DEFAULT_LOG_FILE, LOG_LEVEL_PKCS11_NONE); #endif log_trace(WHERE, "I: enter pReserved = %p",pReserved); if (p11_get_init() != BEIDP11_NOT_INITIALIZED) { ret = CKR_CRYPTOKI_ALREADY_INITIALIZED; log_trace(WHERE, "I: Module is allready initialized"); } else { //g_init = BEIDP11_INITIALIZED; p11_set_init(BEIDP11_INITIALIZING); if (pReserved != NULL) { p_args = (CK_C_INITIALIZE_ARGS *)pReserved; if(p_args->pReserved != NULL) { ret = CKR_ARGUMENTS_BAD; goto cleanup; } if( (p_args->CreateMutex == NULL) || (p_args->DestroyMutex == NULL) || \ (p_args->LockMutex == NULL) || (p_args->UnlockMutex == NULL) ) { log_trace(WHERE, "S: use supplied locking mechanism"); //If some, but not all, of the supplied function pointers to C_Initialize are non-NULL_PTR, //then C_Initialize should return with the value CKR_ARGUMENTS_BAD. if(!((p_args->CreateMutex == NULL) && (p_args->DestroyMutex == NULL) && \ (p_args->LockMutex == NULL) && (p_args->UnlockMutex == NULL))) { ret = CKR_ARGUMENTS_BAD; goto cleanup; } } log_trace(WHERE, "S: p11_init_lock"); p11_init_lock(p_args); } cal_init(); p11_set_init(BEIDP11_INITIALIZED); log_trace(WHERE, "S: Initialize this PKCS11 Module"); log_trace(WHERE, "S: ============================="); /*#ifdef PKCS11_FF cal_init_pcsc(); #endif*/ } cleanup: log_trace(WHERE, "I: leave, ret = %i",ret); if (ret != CKR_OK) { p11_set_init(initial_state); } return ret; }
int main(int argc, char **argv) { struct frame_type frame; struct camera_control_block ccb; struct transform t; struct reflector_model_type rm; if(get_device(&ccb) == false){ log_message("Can't get device category!\n"); return 1; } /* ccb.mode = diagnostic; */ /* ccb.mode = operational_1dot; */ ccb.mode = operational_3dot; if(cal_init(&ccb) < 0){ log_message("Initialization unsuccessfull!\n"); return 1; } bool changed; if(get_pose_setup(&rm, &changed) == false){ log_message("Can't get pose setup!\n"); return 1; } /* rm.p1[0] = -35.0; rm.p1[1] = -50.0; rm.p1[2] = -92.5; rm.p2[0] = +35.0; rm.p2[1] = -50.0; rm.p2[2] = -92.5; rm.hc[0] = +0.0; rm.hc[1] = -100.0; rm.hc[2] = +90.0; */ pose_init(rm); /* loop forever reading and printing results */ /* while (true) { */ /* cal_get_frame(&ccb, &frame); */ /* frame_print(frame); */ /* frame_free(&ccb, &frame); */ /* } */ /* /\* NEW PLAN *\/ */ /* /\* NEW PLAN *\/ */ /* /\* NEW PLAN *\/ */ /* /\* going to read in from stdin simulated blobs. */ /* * echoing input blob out, along with alter92 */ /* * estimates *\/ */ /* struct bloblist_type working_bloblist; */ /* struct blob_type wba[3]; */ /* bool force_recenter = false; */ /* int force_recenter_int; */ /* int scanf_result; */ /* working_bloblist.num_blobs = 3; */ /* working_bloblist.blobs = wba; */ /* while (!feof(stdin)) { */ /* /\* printf("Enter blobs: "); *\/ */ /* scanf_result=scanf("%f,%f,%f,%f,%f,%f,%d", */ /* &(wba[0].x), &(wba[0].y), */ /* &(wba[1].x), &(wba[1].y), */ /* &(wba[2].x), &(wba[2].y), */ /* &force_recenter_int); */ /* if (scanf_result == 7) { */ /* /\* printf("Received: "); *\/ */ /* /\* printf("%f,%f,", (wba[0].x), (wba[0].y)); *\/ */ /* /\* printf("%f,%f,", (wba[1].x), (wba[1].y)); *\/ */ /* /\* printf("%f,%f,", (wba[2].x), (wba[2].y)); *\/ */ /* /\* printf("%d\n", force_recenter_int); *\/ */ /* pose_process_blobs(working_bloblist, &t); */ /* transform_print(t); */ /* } */ /* } */ /* int i; */ /* for(i=0; i<2000; i++) { */ cal_get_frame(&ccb, &frame); frame_print(frame); pose_recenter(); pose_process_blobs(frame.bloblist, &t); transform_print(t); frame_free(&ccb, &frame); while (true) { cal_get_frame(&ccb, &frame); frame_print(frame); pose_process_blobs(frame.bloblist, &t); transform_print(t); frame_free(&ccb, &frame); } /* call disconnects, turns all LEDs off */ cal_shutdown(&ccb); return 0; }
void main_init(int argc, char *argv[]) { bool override_hw = false; if (argc > 1) { if (strcmp(argv[1], "calibrate") == 0) calibrate = true; else override_hw = true; } /* init data structures: */ memset(&pos_in, 0, sizeof(pos_in_t)); vec3_init(&pos_in.acc); /* init SCL subsystem: */ syslog(LOG_INFO, "initializing signaling and communication link (SCL)"); if (scl_init("pilot") != 0) { syslog(LOG_CRIT, "could not init scl module"); die(); } /* init params subsystem: */ syslog(LOG_INFO, "initializing opcd interface"); opcd_params_init("pilot.", 1); /* initialize logger: */ syslog(LOG_INFO, "opening logger"); if (logger_open() != 0) { syslog(LOG_CRIT, "could not open logger"); die(); } syslog(LOG_CRIT, "logger opened"); LOG(LL_INFO, "initializing platform"); if (arcade_quad_init(&platform, override_hw) < 0) { LOG(LL_ERROR, "could not initialize platform"); die(); } acc_mag_cal_init(); cmc_init(); const size_t array_len = sizeof(float) * platform.n_motors; setpoints = malloc(array_len); ASSERT_NOT_NULL(setpoints); memset(setpoints, 0, array_len); rpm_square = malloc(array_len); ASSERT_NOT_NULL(rpm_square); memset(rpm_square, 0, array_len); LOG(LL_INFO, "initializing model/controller"); pos_init(); ne_speed_ctrl_init(REALTIME_PERIOD); att_ctrl_init(); yaw_ctrl_init(); u_ctrl_init(); u_speed_init(); navi_init(); LOG(LL_INFO, "initializing command interface"); cmd_init(); motors_state_init(); blackbox_init(); /* init flight logic: */ flight_logic_init(); /* init calibration data: */ cal_init(&gyro_cal, 3, 1000); cal_ahrs_init(); flight_state_init(50, 150, 4.0); piid_init(REALTIME_PERIOD); interval_init(&gyro_move_interval); gps_data_init(&gps_data); mag_decl_init(); cal_init(&rc_cal, 3, 500); tsfloat_t acc_fg; opcd_param_t params[] = { {"acc_fg", &acc_fg}, OPCD_PARAMS_END }; opcd_params_apply("main.", params); filter1_lp_init(&lp_filter, tsfloat_get(&acc_fg), 0.06, 3); cm_init(); mon_init(); LOG(LL_INFO, "entering main loop"); }
int main(const int argc, const char **argv) { int version = 0; int rd_mode = 0; int rd_flags = 0; int get_root_device = 0; int usb_host_mode = 0; char *get_value = NULL; char *root_device = NULL; const struct poptOption options[] = { {"get-rd-mode", 'd', POPT_ARG_NONE, &rd_mode, 0, "Get R&D mode status", NULL}, {"get-rd-flags", 'f', POPT_ARG_NONE, &rd_flags, 0, "Get R&D mode flags", NULL}, {"get-root-device", 'r', POPT_ARG_NONE, &get_root_device, 0, "Get root device", NULL}, {"set-root-device", 'R', POPT_ARG_STRING, &root_device, 0, "Set root device", NULL}, {"get-block", 'G', POPT_ARG_STRING, &get_value, 0, "Print block data to stdout", NULL}, {"get-usb-host-mode", 'u', POPT_ARG_NONE, &usb_host_mode, 0, "Get USB host mode flag", NULL}, {"version", 0, POPT_ARG_NONE, &version, 0, "Output version", NULL}, POPT_TABLEEND }; const struct poptOption popts[] = { {NULL, 0, POPT_ARG_INCLUDE_TABLE, &options, 0, "Options:", NULL}, POPT_AUTOHELP POPT_TABLEEND }; poptContext ctx = poptGetContext(NULL, argc, argv, popts, POPT_CONTEXT_NO_EXEC); poptSetOtherOptionHelp(ctx, "OPTION"); const int rc = poptGetNextOpt(ctx); const int option_sum = version + rd_mode + rd_flags + get_root_device + usb_host_mode + (root_device == NULL ? 0 : 1) + (get_value == NULL ? 0 : 1); cal c; int ret = EXIT_FAILURE; if (rc != -1) { /* Invalid option */ fprintf(stderr, "%s: %s\n", poptBadOption(ctx, POPT_BADOPTION_NOALIAS), poptStrerror(rc)); } else if (option_sum > 1) { fputs("Only one option can be given\n", stderr); } else if (option_sum == 0) { /* No action given */ poptPrintHelp(ctx, stdout, 0); } else if (version) { printf("open-cal-tool %s\n\n", VERSION); puts("Copyright (C) 2009 Marat Radchenko <*****@*****.**>\n" "License GPLv3+: GNU GPL version 3 or later" " <http://gnu.org/licenses/gpl.html>\n" "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law."); ret = EXIT_SUCCESS; } else if ((c = cal_init(CAL_DEFAULT_PATH)) != NULL) { void *data; size_t len; if (rd_mode && !cal_read_block(c, "r&d_mode", &data, &len, 0)) { /* TODO: r&d flags are stored in same block. There might be more that one byte when they're set. */ assert(len == 1); puts(((char *)data)[0] ? "enabled" : "disabled"); ret = EXIT_SUCCESS; } else if (rd_flags && !cal_read_block(c, "r&d_mode", &data, &len, 0)) { /* TODO: implement this */ fputs("not implemented yet\n", stderr); } else if (get_root_device && !cal_read_block(c, "root_device", &data, &len, 0)) { char buf[len + 1]; memcpy(buf, data, len); buf[len] = '\0'; puts(buf); ret = EXIT_SUCCESS; } else if (root_device && !cal_write_block(c, "root_device", root_device, strlen(root_device), 0)) { ret = EXIT_SUCCESS; } else if (usb_host_mode && !cal_read_block(c, "usb_host_mode", &data, &len, 0)) { /* TODO: implement this */ fputs("not implemented yet\n", stderr); } else if (get_value && !cal_read_block(c, get_value, &data, &len, 0)) { ret = fwrite(data, 1, len, stdout) == len; } cal_destroy(c); } poptFreeContext(ctx); return ret; }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /* Initialize. */ hil_init(); cal_init(); /* Which kind of reset was it? */ int8_t resettype; resettype = hil_isSWreset(); cal_SENDLOG("\r\n"); cal_SENDLOG("=========CBBL Log=========\r\n"); cal_SENDLOG("Marco Zavatta, Yin Zhining\r\n"); cal_SENDLOG("POLIMI, 2011/2012\r\n"); cal_SENDLOG("==========================\r\n"); cal_SENDLOG("\r\n"); //CanStat = CAN1; // NEED TO SAVE THE STATE TO RE-ENTER THE SAME COMMUNICATION DEVICE AFTER THE SW-TRIGGERED RESET /* Test if button on the board is pressed during reset or if it was a sw-triggered reset. */ if (((GPIOB->IDR & GPIO_IDR_IDR1) == 0x00 && resettype == 0) || resettype == 1) { //comm_peripheral = USART; if (resettype==1) { GPIOA->BSRR |= GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BS2 | GPIO_BSRR_BR3; cal_SENDLOG("-> software reset occured \r\n"); } else { GPIOA->BSRR |= GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BR2 | GPIO_BSRR_BR3; cal_SENDLOG("-> button pressed \r\n"); } command_receiveinit(); } /*else*/ /*if (((GPIOB->IDR & GPIO_IDR_IDR2) == 0x00 && resettype == 0) || resettype == 1) { comm_peripheral = CAN; if (resettype==1) { GPIOA->BSRR |= GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BS2 | GPIO_BSRR_BR3; cal_SENDLOG("-> software reset occured \r\n"); } else { GPIOA->BSRR |= GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BR2 | GPIO_BSRR_BR3; cal_SENDLOG("-> button pressed \r\n"); } command_receiveinit(); }*/ /* Keep the user application running */ else { cal_SENDLOG("-> button not pressed, jumping to app\r\n"); /* Jump to pre-loaded application. */ jumptoapp(FLASHbase); } while (1) { cal_SENDLOG("-> !!! main function fail !!!\r\n"); uint32_t i; while (1) { i=0; while (i<0xFFFFF) i++; GPIOA->BSRR |= GPIO_BSRR_BS0 | GPIO_BSRR_BR1 | GPIO_BSRR_BR2 | GPIO_BSRR_BR3; i=0; while (i<0xFFFFF) i++; GPIOA->BSRR |= GPIO_BSRR_BR0 | GPIO_BSRR_BR1 | GPIO_BSRR_BR2 | GPIO_BSRR_BS3; } } }