int main() { int first; t_ipc my_ipc; first = 0; my_ipc.shm_id = shmget(KEY, 100, SHM_R | SHM_W); my_ipc.sem_id = semget(KEY, 100, SHM_R | SHM_W); printf("%d, %d\n", my_ipc.shm_id, my_ipc.sem_id); if (my_ipc.shm_id == -1 && my_ipc.sem_id == -1) { init_ipc(&my_ipc); first = 1; wait_for_player(&my_ipc); } if (first) { while (!finish(&my_ipc)) new_turn(&my_ipc); shmctl(my_ipc.shm_id, IPC_RMID, NULL); semctl(my_ipc.sem_id, IPC_RMID, 1); } else { my_ipc.addr = shmat(my_ipc.shm_id, NULL, SHM_R | SHM_W); player_func(&my_ipc); } return (0); }
void kernel_main() { init_process(); init_dispatcher(); init_ipc(); init_interrupts(); init_null_process(); init_timer(); init_com(); init_keyb(); init_ne2k(); init_shell(); while (1); }
void kernel_main() { init_process(); init_dispatcher(); init_ipc(); init_interrupts(); init_null_process(); init_timer(); #if VGA_MODE_ENABLED init_vga_mode(); #endif init_com(); init_keyb(); clear_kernel_window(); init_ne_driver(); init_em(); init_shell(); while (1); }
void init_with_mpi(int argc, char ** argv) { mpi_mode = true; XDEBUG(std::cout << "adaptor: started in mpi mode" << std::endl); if(argc != 5) { std::cerr << "adaptor: wrong number of arguments" << std::endl; exit(1); } std::string ipc_file(argv[2]); if(*argv[4] == 'm') // Master process { master_instance = true; std::cout << "adaptor: master process started" << std::endl; parse_config(argv[3]); zmq_responder = zmq_socket (zmq_context, ZMQ_REP); zmq_connect(zmq_responder, ("ipc://" + ipc_file).c_str()); // Spit all actions out on request execute([&] () { // Wait for next request from client wait_for_request(); reply_config(); }); wait_for_request(); reply(); finalize(0); } else { std::cout << "adaptor: worker process started" << std::endl; init_ipc(ipc_file); parse_config(argv[3]); } }
void init(int argc, char ** argv) { if(argc < 4) { std::cerr << "adaptor: wrong number of arguments" << std::endl; exit(1); } if(argv[1][0] == 'm') { init_with_mpi(argc, argv); } else { XDEBUG(std::cout << "adaptor: started" << std::endl); std::string ipc_file(argv[2]); init_ipc(ipc_file); parse_config(argv[3]); } }
void test_reset() { asm("cli"); interrupts_initialized = FALSE; lib_clear_window(kernel_window); test_result = 0; init_process(); init_dispatcher(); init_ipc(); /* * Normally we would call the following init_*(), but the way some * test cases are written, this would disrupt them. So we manually * call them when we know it is OK. */ // init_interrupts(); // init_null_process(); // init_timer(); // init_com(); }
int main(int argc, char **argv) { QPEApplication app(argc, argv); walker_gui = new WalkerGui(); carmen_initialize_ipc(argv[0]); carmen_param_check_version(argv[0]); init_roomnav(); init_ipc(); signal(SIGINT, shutdown); app.showMainWidget(walker_gui); while (1) { app.processEvents(); update_ipc(); usleep(10000); } return 0; }
int main( int argc, char *argv[] ){ char *progname = argv[0]; char conffile[255]; if( argc > 1 ){ if(strcmp(argv[1], "-h") == 0){ print_help(progname); exit(0); } else if(get_conf_name( argv, conffile ) == 0){ print_help(progname); exit(1); } } else{ print_help(progname); exit(1); } csector = 0; cdir = in; confname = argv[argc - 1]; conf_t conf; confresult_t confresult = get_conf(conffile, confname, &conf); // verificação de erros de get_conf if(confresult != ok){ if(confresult == filenotfound) fprintf(stderr, "ficheiro não encontrado\n"); else if(confresult == confnotfound) fprintf(stderr, "configuração não encontrada\n"); else if(confresult == disknotfound) fprintf(stderr, "disco não encontrado\n"); else fprintf(stderr, "erro no ficheiro\n"); exit(1); } // tamanho do disco struct stat st; if(stat(conf.imagefile, &st) == -1){ perror("tamanho do disco"); exit(1); } disksize = st.st_size; // verificar tamanho do ficheiro de imagem com número de // setores dos discos. Só é necessário verificar com um // disco porque a função get_conf verifica o tamanho dos discos. if(disksize != conf.disk[0].sectors){ fprintf(stderr, "Não conseguio carregar o disco\n"); exit(1); } // carregar para memória o ficheiro contendo imagem do disco int fd = open(conf.imagefile, O_RDONLY); if(fd == -1){ perror(conf.imagefile); exit(1); } secdata_t disk[disksize]; if(read (fd, disk, disksize) == -1){ perror("ler ficheiro img"); exit(1); } reqpool_t reqpool; ipc_t ipc; ipc.reqpool = &reqpool; // inicializar e associar o processo aos mecanismos de comunicação if(init_ipc(progname, confname, &ipc) == -1) exit(1); // criar o processo filho int indice = setup_disks(ipc.reqpool->disks); strcpy(diskname, conf.disk[indice].name); vsslog(confname,diskname, DS, cdir, disksize, ipc.reqpool->policy); vsslog(confname,diskname, ER, csector, cdir); // arma o sinal SIGUSR1 signal(SIGUSR1, estaciona_disco); // atender pedidos request_t req; while(1){ if(ipc.reqpool->policy == FCFS){ if(take_request(&ipc, &req, select_request_FCFS) != 1){ perror("carregar pedido"); exit(1); } }else{ if(take_request(&ipc, &req, select_request_LOOK) != 1){ perror("carregar pedido"); exit(1); } } vsslog(confname,diskname, OR, req.sector); secdata_t sect; if(move_and_read(&req, §,disk) == 0){ perror("ler pedido"); exit(1); } put_sector(csector, §); vsslog(confname,diskname, RS, csector, cdir); vsslog(confname,diskname, ER, csector, cdir); } }
int main(int argc, const char *argv[]) { // connect to IPC int quit = 0; int connection_status = init_ipc("darwin_command_ipc",argv[1]); // subscribe to relevant IPC messages IPC_subscribeData(SVM_DATA_RESPONSE, svmDataHandler, NULL); // ball data // listen to robot information messages // listen to messages sent by other robots printf("Start main loop.\n"); // send messages to darwin-nav on own robot Darwin_Nav_Command command; int publish_command = 0; // set to 0 for no, 1 to send out command next loop double t0 = ftime(); //start timer for find_ball in demo state machine State state = FIND_BALL; //TODO: sharing states between machines is very bad :( State state_find_ball = TURN_HEAD_SIDE_TO_SIDE; State state_chase_ball = BALL_CENTERED; // start walking (NOTE: arrange so this is not necessary TODO: may want to remove) command.mode = DARWIN_NAV_START; IPC_publishData(DARWIN_NAV_COMMAND, &command); while( quit == 0 ) { //print_svm_data(); // check IPC connection status // break if we're not connected for now //TODO: reconnect or wait? Or, only send while connected? if( connection_status != 0 ) { printf( "IPC connection disrupted, disconnecting...\n"); //TODO: realtime break; } IPC_listenClear(10); //listen for messages // run demo state machine here... search_and_chase_ball(&publish_command, &command, &t0, &state, &state_find_ball, &state_chase_ball); // comment out search_and_chase_ball to try this other state machine: /* turn_head_towards_ball(&publish_command, &command, &state_chase_ball);*/ // if we have a new command to publish, do so if( publish_command == 1 ) { IPC_publishData(DARWIN_NAV_COMMAND, &command); publish_command = 0; } // TODO: any state machine in a function that wants to send nav commands // needs to take in &command_changed and &command /* state machine stuff // decide role Role role = ATTACKER; // things that decide role: // ball distance // if we're the goalie or not // is another robot in a better position? // are we trying to pass? // state machine switch( role ) { } Mode mode = FIND_BALL; // psedocode for finding, then kicking ball if( ball_seen ) { if( ball_within_reach ) { if( kick_places_ball_near_goal ) { kick_ball(); } else { move_ball_near_goal(); } } else { turn_toward_ball(); forward(); } } else { find_ball(); } switch( mode ) { // demo state machine: // if we don't see the ball, find the ball // else if we see the ball, track the ball // follow and kick the ball: // if we're near the ball and TODO ball kicked would be favorable... // align self with ball (sidestep if necessary) // kick ball // else if we're not near the ball // turn toward ball // walk toward ball UNTIL // (different mode: walk to the goalposts and align kick between? // case FIND_BALL: break; case FOUND_BALL: break; }*/ }// end main loop TODO: make more robust? // disconnect from IPC after quitting... IPC_disconnect(); }// end main //
/** Main loop; gets keyboard input and sends IPC messages out accordingly. */ int main(int argc, char *argv[]) { int quit = 0; char input; int connectionStatus = init_ipc("darwin_nav_ipc","localhost"); if( connectionStatus == 0 ) { // connect to IPC and register handlers //IPC_subscribeData(DARWIN_NAV_COMMAND, navStateHandler, NULL); // TODO: should the walk engine startup be controlled from here? // send ourselves some messages through Central to test Darwin_Nav_Command command; //command.data[0] = 1.0; //command.data[1] = 0.5; //command.data[2] = 0.6; //command.mode = DARWIN_NAV_STOP; //IPC_publishData(DARWIN_NAV_COMMAND, &command); //command.mode = DARWIN_NAV_KICK; //IPC_publishData(DARWIN_NAV_COMMAND, &command); //command.mode = DARWIN_NAV_SET_RELATIVE_VELOCITY; //IPC_publishData(DARWIN_NAV_COMMAND, &command); // print help printf("Drive the robot with IPC!\n"); printf("i j k l (u p) or 8 4 5 6 (7 9) to steer\n"); printf("z x to kick"); printf(""); float yaw=0.0f,pitch=0.0f; printf(" q to quit\n"); // control robot with input while( quit==0 ) { input = getchar(); switch(input) { // TODO: turning should be zeroed before I try to use it like this // TODO: have separate messages for sidestep and turn; 1 and 2 do different things // TODO: write a left kick and a right kick message // TODO: write a sit/stand message? also, manage walk better, a bug // directional input // TODO: tie to frequency... // turn left case '4': case 'j': command.mode = DARWIN_NAV_SET_RELATIVE_VELOCITY; command.data[0] = 0.0; // forwards / backwards command.data[1] = 0.0; // sidestep left and right command.data[2] = DARWIN_TURN_INCREMENT; // turn left and right TODO: still backward break; // turn right case '6': case 'l': command.mode = DARWIN_NAV_SET_RELATIVE_VELOCITY; command.data[0] = 0.0; command.data[1] = 0.0; command.data[2] = -DARWIN_TURN_INCREMENT; break; // sidestep left case '7': case 'u': command.mode = DARWIN_NAV_SET_RELATIVE_VELOCITY; command.data[0] = 0.0; command.data[1] = DARWIN_TURN_INCREMENT; command.data[2] = 0.0; break; // sidestep right case '9': case 'o': command.mode = DARWIN_NAV_SET_RELATIVE_VELOCITY; command.data[0] = 0.0; command.data[1] = -DARWIN_TURN_INCREMENT; command.data[2] = 0.0; break; // go forward case '8': case 'i': command.mode = DARWIN_NAV_SET_RELATIVE_VELOCITY; command.data[0] = DARWIN_WALK_INCREMENT; command.data[1] = 0.0; command.data[2] = 0.0; break; // kick left foot case 'z': command.mode = DARWIN_NAV_KICK_LEFT; break; // kick right foot case 'x': command.mode = DARWIN_NAV_KICK_RIGHT; break; // stop TODO: slow down case '5': case 'k': command.mode = DARWIN_NAV_SET_ABSOLUTE_VELOCITY; //TODO: may not work? fix command.data[0] = 0.0; command.data[1] = 0.0; command.data[2] = 0.0; //command.mode = DARWIN_NAV_STOP; break; case '1': command.mode = DARWIN_NAV_STOP; break; case '2': command.mode = DARWIN_NAV_SIT; break; case '3': command.mode = DARWIN_NAV_START; break; case 'q': printf("Quitting...\n"); command.mode = DARWIN_NAV_QUIT; quit=1; break; case 'r': //new head turn entry added 6/15; command.mode=DARWIN_NAV_SET_RELATIVE_HEAD; command.data[0]=(1)*(PI/180); yaw+=command.data[0]; break; case 't': command.mode=DARWIN_NAV_SET_RELATIVE_HEAD; command.data[0]=-(1)*(PI/180); yaw+=command.data[0]; break; case 'f': command.mode=DARWIN_NAV_SET_RELATIVE_HEAD; command.data[0]=0.0; command.data[1]=((1)*(PI/180)); pitch+=command.data[1]; break; case 'g': command.mode=DARWIN_NAV_SET_RELATIVE_HEAD; command.data[0]=0.0; command.data[1]=-(1)*(PI/180); pitch+=command.data[1]; break; } IPC_publishData(DARWIN_NAV_COMMAND, &command); printf("yaw=%f,pitch=%f\n",yaw,pitch); }// end while loop } else { printf("IPC connect failed, quitting...\n"); return 0; } IPC_disconnect(); }
static void init_controller(void) { /** * TODO: initialize WfmRef and Samples Buffer */ init_ps_module(&g_ipc_ctom.ps_module[0], g_ipc_mtoc.ps_module[0].ps_status.bit.model, &turn_on, &turn_off, &isr_soft_interlock, &isr_hard_interlock, &reset_interlocks); init_ps_module(&g_ipc_ctom.ps_module[1], g_ipc_mtoc.ps_module[1].ps_status.bit.model, &turn_on, &turn_off, &isr_soft_interlock, &isr_hard_interlock, &reset_interlocks); g_ipc_ctom.ps_module[2].ps_status.all = 0; g_ipc_ctom.ps_module[3].ps_status.all = 0; init_ipc(); init_control_framework(&g_controller_ctom); /*************************************/ /** INITIALIZATION OF DSP FRAMEWORK **/ /*************************************/ /** * name: SRLIM_V_CAPBANK_REFERENCE * description: Capacitor bank voltage reference slew-rate limiter * DP class: DSP_SRLim * in: V_CAPBANK_SETPOINT * out: V_CAPBANK_REFERENCE */ init_dsp_srlim(SRLIM_V_CAPBANK_REFERENCE, MAX_REF_SLEWRATE, CONTROLLER_FREQ_SAMP, &V_CAPBANK_SETPOINT, &V_CAPBANK_REFERENCE); init_controller_module_A(); init_controller_module_B(); /***********************************************/ /** INITIALIZATION OF SIGNAL GENERATOR MODULE **/ /***********************************************/ disable_siggen(&SIGGEN); init_siggen(&SIGGEN, CONTROLLER_FREQ_SAMP, &V_CAPBANK_REFERENCE); cfg_siggen(&SIGGEN, g_ipc_mtoc.siggen.type, g_ipc_mtoc.siggen.num_cycles, g_ipc_mtoc.siggen.freq, g_ipc_mtoc.siggen.amplitude, g_ipc_mtoc.siggen.offset, g_ipc_mtoc.siggen.aux_param); /** * name: SRLIM_SIGGEN_AMP * description: Signal generator amplitude slew-rate limiter * DP class: DSP_SRLim * in: g_ipc_mtoc.siggen.amplitude * out: g_ipc_ctom.siggen.amplitude */ init_dsp_srlim(SRLIM_SIGGEN_AMP, MAX_SR_SIGGEN_AMP, CONTROLLER_FREQ_SAMP, &g_ipc_mtoc.siggen.amplitude, &g_ipc_ctom.siggen.amplitude); /** * name: SRLIM_SIGGEN_OFFSET * description: Signal generator offset slew-rate limiter * DP class: DSP_SRLim * in: g_ipc_mtoc.siggen.offset * out: g_ipc_ctom.siggen.offset */ init_dsp_srlim(SRLIM_SIGGEN_OFFSET, MAX_SR_SIGGEN_OFFSET, CONTROLLER_FREQ_SAMP, &g_ipc_mtoc.siggen.offset, &g_ipc_ctom.siggen.offset); /************************************/ /** INITIALIZATION OF TIME SLICERS **/ /************************************/ /** * Time-slicer for WfmRef sweep decimation */ cfg_timeslicer(TIMESLICER_WFMREF, WFMREF_DECIMATION); /** * Time-slicer for SamplesBuffer */ cfg_timeslicer(TIMESLICER_BUFFER, BUFFER_DECIMATION); /** * Time-slicer for controller */ cfg_timeslicer(TIMESLICER_CONTROLLER, CONTROLLER_DECIMATION); init_buffer(BUF_SAMPLES, &g_buf_samples_ctom, SIZE_BUF_SAMPLES_CTOM); enable_buffer(BUF_SAMPLES); /** * Reset all internal variables */ reset_controller(); }
void entry(struct Multiboot_Info_dec * old_mbinfo) { // This function is entered into by the kernel header // which sets up some basic tables for use and passes on // the multiboot info structure struct Multiboot_Info_dec mbinfo; #ifdef DEBUG U8 * screen = (U8 *)0xB8000; U16 i; // Clear the screen so debug messages are more visible for (i = 0; i < 160; i+=2) { screen[i] = ' '; screen[i+1] = 0x17; } for (i = 160; i < 7840; i+=2) { screen[i] = ' '; screen[i+1] = 0x07; } dprint("\t\t\tThe Poseidon Project Kernel.\n\n"); dprint("The Poseidon Project (c) Copyright 1998, 1999 John Barker\n"); dprint("All rights reserved. 32 bit message based real time operating system.\n\n"); #endif // Copy the old table to a local one for safe keeping // because once memory is initialized the old one may be wiped memcpy(&mbinfo,old_mbinfo,sizeof(struct Multiboot_Info_dec)); // Set up the exception traps init_traps(); // Allocate the irq routines init_irqs(); // Initialize memory management so we can use kmalloc and other // memory based functions init_mm(&mbinfo); // Initialize the object manager so we can start using it init_obj(); // Initialize the module/driver interface so modules can be loaded init_mdi(); // Set up the clocks and timers init_time(); // Set up tables and data for the executive init_executive(); // Initialize IPC and message buffers for all objects init_ipc(); // Initialize the system calls (system call interface) init_sci(); // Load all the modules passed to us at boot time, one of these // should be init or main load_modules(&mbinfo); // Start the executive scheduler, will boot the init module start_executive(); // The idle function - just loop, should be run in user mode idle(); }
/** Carries out simulation setup and management. @param argc The number of arguments @param argv The array of arguments */ int main(int argc, char *argv[]) { int *results, *shm_states; int i, op_count, proc_id; char *tmp_operator, *cmd; list *commands; operation *shm_operations; if(signal(SIGTERM, &stop_execution) == SIG_ERR) { write_to_fd(2, "Failed to register signal\n"); exit(1); } if(argc != 3) { write_to_fd(2, "Usage: main.x <source file> <results file>\n"); exit(1); } commands = parse_file(argv[1]); processors = atoi(list_extract(commands)); if (processors <= 0) { write_to_fd(2, "Invalid number of processors\n"); exit(1); } write_with_int(1, "Number of processors: ", processors); op_count = list_count(commands); if (op_count == 0) { write_to_fd(2, "No operations provided\n"); exit(1); } write_with_int(1, "Number of operations: ", op_count); results = (int *) malloc(op_count * sizeof(int)); if (results == NULL) { write_to_fd(2, "Failed to allocate results array\n"); exit(1); } init_ipc(2 * processors + 2, processors * sizeof(operation), processors * sizeof(int), 0666 | IPC_CREAT | IPC_EXCL); write_with_int(1, "Created semaphore set with ID ", ipc_id[0]); write_with_int(1, "Created shm for operations with ID ", ipc_id[1]); write_with_int(1, "Created shm for states with ID ", ipc_id[2]); init_sems(processors); shm_operations = (operation *) shm_attach(ipc_id[1]); shm_states = (int *) shm_attach(ipc_id[2]); for (i = 0; i < processors; ++i) shm_states[i] = 0; start_processors(); for (i = 1; list_count(commands) > 0; ++i) { cmd = list_extract(commands); write_with_int(1, "\nOperation #", i); proc_id = atoi(strtok(cmd, " ")); sem_p(2 * processors + 1); if (proc_id-- == 0) { proc_id = find_proc(shm_states); } write_with_int(1, "Waiting for processor ", proc_id + 1); sem_p(2 * proc_id); write_with_int(1, "Delivering operation to processor ", proc_id + 1); if (shm_states[proc_id] != 0) { results[(shm_states[proc_id] + 1) * -1] = shm_operations[proc_id].num1; write_with_int(1, "Previous result: ", shm_operations[proc_id].num1); } shm_operations[proc_id].num1 = atoi(strtok(NULL, " ")); tmp_operator = strtok(NULL, " "); shm_operations[proc_id].op = *tmp_operator; shm_operations[proc_id].num2 = atoi(strtok(NULL, " ")); shm_states[proc_id] = i; write_with_int(1, "Operation delivered. Unblocking processor ", proc_id + 1); sem_v((2 * proc_id) + 1); free(cmd); } list_destruct(commands); for (i = 0; i < processors; ++i) { sem_p(2 * i); write_with_int(1, "\nPassing termination command to processor #", i + 1); if (shm_states[i] != 0) { results[(shm_states[i] + 1) * -1] = shm_operations[i].num1; write_with_int(1, "Last result: ", shm_operations[i].num1); } shm_operations[i].op = 'K'; sem_v((2 * i) + 1); } for (i = 0; i < processors; ++i) if(wait(NULL) == -1) write_to_fd(2, "Wait failed\n"); write_to_fd(1, "\nAll processors exited. Writing output file\n"); write_results(argv[2], results, op_count); free(results); write_to_fd(1, "Closing IPCs\n"); shm_detach((void *) shm_operations); shm_detach((void *) shm_states); close_ipc(); exit(0); }
static void init_controller(void) { /** * TODO: initialize WfmRef and Samples Buffer */ init_ps_module(&g_ipc_ctom.ps_module[0], g_ipc_mtoc.ps_module[0].ps_status.bit.model, &turn_on, &turn_off, &isr_soft_interlock, &isr_hard_interlock, &reset_interlocks); g_ipc_ctom.ps_module[1].ps_status.all = 0; g_ipc_ctom.ps_module[2].ps_status.all = 0; g_ipc_ctom.ps_module[3].ps_status.all = 0; init_ipc(); init_control_framework(&g_controller_ctom); /***********************************************/ /** INITIALIZATION OF SIGNAL GENERATOR MODULE **/ /***********************************************/ disable_siggen(&SIGGEN); init_siggen(&SIGGEN, ISR_CONTROL_FREQ, &g_ipc_ctom.ps_module[0].ps_reference); cfg_siggen(&SIGGEN, g_ipc_mtoc.siggen.type, g_ipc_mtoc.siggen.num_cycles, g_ipc_mtoc.siggen.freq, g_ipc_mtoc.siggen.amplitude, g_ipc_mtoc.siggen.offset, g_ipc_mtoc.siggen.aux_param); /** * name: SRLIM_SIGGEN_AMP * description: Signal generator amplitude slew-rate limiter * DP class: DSP_SRLim * in: g_ipc_mtoc.siggen.amplitude * out: g_ipc_ctom.siggen.amplitude */ init_dsp_srlim(SRLIM_SIGGEN_AMP, MAX_SR_SIGGEN_AMP, ISR_CONTROL_FREQ, &g_ipc_mtoc.siggen.amplitude, &g_ipc_ctom.siggen.amplitude); /** * name: SRLIM_SIGGEN_OFFSET * description: Signal generator offset slew-rate limiter * DP class: DSP_SRLim * in: g_ipc_mtoc.siggen.offset * out: g_ipc_ctom.siggen.offset */ init_dsp_srlim(SRLIM_SIGGEN_OFFSET, MAX_SR_SIGGEN_OFFSET, ISR_CONTROL_FREQ, &g_ipc_mtoc.siggen.offset, &g_ipc_ctom.siggen.offset); /*************************************************/ /** INITIALIZATION OF LOAD CURRENT CONTROL LOOP **/ /*************************************************/ /** * name: SRLIM_I_LOAD_REFERENCE * description: Load current slew-rate limiter * DP class: DSP_SRLim * in: I_LOAD_SETPOINT * out: I_LOAD_REFERENCE */ init_dsp_srlim(SRLIM_I_LOAD_REFERENCE, MAX_REF_SLEWRATE, ISR_CONTROL_FREQ, &I_LOAD_SETPOINT, &I_LOAD_REFERENCE); /** * name: ERROR_I_LOAD * description: Load current reference error * dsp module: DSP_Error * +: I_LOAD_REFERENCE * -: I_LOAD_MEAN * out: I_LOAD_ERROR */ init_dsp_error(ERROR_I_LOAD, &I_LOAD_REFERENCE, &I_LOAD_MEAN, &I_LOAD_ERROR); /** * name: PI_CONTROLLER_I_LOAD * description: Capacitor bank voltage PI controller * dsp module: DSP_PI * in: I_LOAD_ERROR * out: DUTY_CYCLE */ init_dsp_pi(PI_CONTROLLER_I_LOAD, KP_I_LOAD, KI_I_LOAD, ISR_CONTROL_FREQ, PWM_MAX_DUTY, PWM_MIN_DUTY, &I_LOAD_ERROR, &DUTY_CYCLE_MOD_1); /** * name: IIR_2P2Z_CONTROLLER_I_LOAD * description: Load current IIR 2P2Z controller * DP class: DSP_IIR_2P2Z * in: net_signals[4] * out: DUTY_CYCLE */ init_dsp_iir_2p2z(IIR_2P2Z_CONTROLLER_I_LOAD, IIR_2P2Z_CONTROLLER_I_LOAD_COEFFS.b0, IIR_2P2Z_CONTROLLER_I_LOAD_COEFFS.b1, IIR_2P2Z_CONTROLLER_I_LOAD_COEFFS.b2, IIR_2P2Z_CONTROLLER_I_LOAD_COEFFS.a1, IIR_2P2Z_CONTROLLER_I_LOAD_COEFFS.a2, PWM_MAX_DUTY, PWM_MIN_DUTY, &I_LOAD_ERROR, &DUTY_CYCLE_MOD_1); /************************************/ /** INITIALIZATION OF TIME SLICERS **/ /************************************/ /** * Time-slicer for WfmRef sweep decimation */ cfg_timeslicer(TIMESLICER_WFMREF, WFMREF_DECIMATION); /** * Time-slicer for SamplesBuffer */ cfg_timeslicer(TIMESLICER_BUFFER, BUFFER_DECIMATION); /** * Samples buffer initialization */ init_buffer(BUF_SAMPLES, &g_buf_samples_ctom, SIZE_BUF_SAMPLES_CTOM); enable_buffer(BUF_SAMPLES); /** * Reset all internal variables */ reset_controller(); }