コード例 #1
0
ファイル: governorclient.cpp プロジェクト: OpenUAS/open-bldc
GovernorClient::GovernorClient()
{
    int i;
    gpc_init(gpc_output_trigger, static_cast<void *>(this), gpc_register_changed, static_cast<void *>(this));
    for(i=0; i<32; i++){
        register_map[i] = 0;
        gpc_setup_reg(i, &register_map[i]);
    }
}
コード例 #2
0
ファイル: main.c プロジェクト: shi-mo/pic12f683_gpc
int
main(int argc, char *argv[])
{
	gpc_init();

	gpc_timer_start();
	while (1) {
		gpc_update();
	}
}
コード例 #3
0
ファイル: gprot.c プロジェクト: xiserre/open-bldc
/**
 * Initialize all necessary registers and callback hooks.
 *
 * @todo All setup regs should be called from the respective module init
 * functions.
 */
void gprot_init()
{
	(void)gpc_init(gprot_trigger_output, NULL, gprot_register_changed, NULL);
	(void)gpc_set_get_version_callback(gprot_get_version, NULL);

	gprot_flag_reg = 0;
	gprot_flag_reg_old = 0;
	(void)gpc_setup_reg(GPROT_FLAG_REG_ADDR, &gprot_flag_reg);

	(void)gpc_setup_reg(GPROT_NEW_CYCLE_TIME, (u16 *) & new_cycle_time);

	(void)gpc_setup_reg(GPROT_PWM_VAL_REG_ADDR, (u16 *) & gprot_pwm_power);
}
コード例 #4
0
ファイル: gprot.c プロジェクト: tituarte/open-bldc
/* Function implementations */
void gprot_init(){
	int i;

	gpc_init(gprot_trigger_output, 0, gprot_register_changed, 0);

	for(i=0; i<32; i++){
		test_regs[i] = i*3;
		if(gpc_setup_reg(i, &test_regs[i])){
			LED_RED_ON();
		}
	}

}
コード例 #5
0
ファイル: check_gprot_suite.c プロジェクト: bobbens/open-bldc
void init_gprot_tc(void)
{
	int i;

	gpm_init(gpm_trigger_output_hook, NULL, gpm_register_changed_hook, NULL);

	gpc_init(gpc_trigger_output_hook, NULL, NULL, NULL);

	for(i=0; i<32; i++){
		gp_register_map[i] = 0xAA55+i;
		gpc_setup_reg(i, &gp_register_map[i]);
	}
}
コード例 #6
0
void init_gprotc_tc(void)
{
	int i;

	for(i=0; i<32; i++)
		gpc_dummy_register_map[i] = 0xAA55+i;

	gpc_init(gpc_dummy_trigger_output_hook, (void *)1, gpc_dummy_register_changed_hook, (void*)1);

	gpc_dummy_trigger_output_data = 0;
	gpc_dummy_trigger_output_triggered = 0;
	gpc_dummy_register_changed_data = 0;
	gpc_dummy_register_changed = 0;
	gpc_dummy_register_changed_addr = 0;
}
コード例 #7
0
/**
 * Initialize the Governor protocol subsystem.
 */
void gprot_init()
{
	int i;

	(void)gpc_init(gprot_trigger_output, 0, gprot_register_changed, 0);
	(void)gpc_set_get_version_callback(gprot_get_version, 0);

	gprot_get_version_triggered = false;

	for (i = 0; i < 32; i++) {
		test_regs[i] = (u16)(i * 3);
		if (gpc_setup_reg((u8)i, &test_regs[i]) != 0) {
			ON(LED_RED);
		}
	}

}
コード例 #8
0
ファイル: lapi.c プロジェクト: bcernohous/ga
/*\ initialization of LAPI related data structures
  \*/
void armci_init_lapi()
{
    int rc, p;
    int lapi_max_uhdr_sz;
    lapi_cmpl_t *pcntr;
    lapi_remote_cxt_t util_cxt;  /* For call to obtain rCxt */

#ifndef TCGMSG
    rc = LAPI_Init(&lapi_handle, &lapi_info);
    if(rc) ERROR("lapi_init failed",rc);
#endif

    /* set the max limit for AM header data length */
    rc = LAPI_Qenv(lapi_handle,MAX_UHDR_SZ, &lapi_max_uhdr_sz);
    if(rc) ERROR("armci_init_lapi:  LAPI_Qenv failed", rc); 

    /*     fprintf(stderr,"max header size = %d\n",lapi_max_uhdr_sz);*/

    /* how much data can fit into AM header ? */
    lapi_max_uhdr_data_sz = lapi_max_uhdr_sz - sizeof(request_header_t);

    /* allocate memory for completion state array */
    cmpl_arr = (lapi_cmpl_t*)malloc(armci_nproc*sizeof(lapi_cmpl_t));
    if(cmpl_arr==NULL) ERROR("armci_init_lapi:malloc for cmpl_arr failed",0);

    /* allocate memory for ack and get counters, 1 if not thread safe */
#ifdef THREAD_SAFE
    ack_cntr = calloc(armci_user_threads.max, sizeof(lapi_cmpl_t));
    get_cntr = calloc(armci_user_threads.max, sizeof(lapi_cmpl_t));
#else
    ack_cntr = calloc(1, sizeof(lapi_cmpl_t));
    get_cntr = calloc(1, sizeof(lapi_cmpl_t));
#endif
    if (!(ack_cntr && get_cntr))
        ERROR("armci_init_lapi:calloc for ack or get counters failed",0);

    /* initialize completion state array */
    for(p = 0; p< armci_nproc; p++){
        rc = LAPI_Setcntr(lapi_handle, &cmpl_arr[p].cntr, 0);
        if(rc) ERROR("armci_init_lapi: LAPI_Setcntr failed (arr)",rc);
        cmpl_arr[p].oper = -1;
        cmpl_arr[p].val = 0;
    }

    /* initialize ack/buf/hdr counters */
#ifdef THREAD_SAFE
#   define N armci_user_threads.max
#else
#   define N 1
#endif
    for (p = 0; p < N; p++) {
        rc = LAPI_Setcntr(lapi_handle, &(ack_cntr[p].cntr), 0);
        if(rc) ERROR("armci_init_lapi: LAPI_Setcntr failed (ack)",rc);
        ack_cntr[p].val = 0;

        rc = LAPI_Setcntr(lapi_handle, &(get_cntr[p].cntr), 0);
        if(rc) ERROR("armci_init_lapi: LAPI_Setcntr failed (get)",rc);
        get_cntr[p].val = 0;
    }
    rc = LAPI_Setcntr(lapi_handle, &hdr_cntr.cntr, 0);
    if(rc) ERROR("armci_init_lapi: LAPI_Setcntr failed (hdr)",rc);
    hdr_cntr.val = 0;
    rc = LAPI_Setcntr(lapi_handle, &buf_cntr.cntr, 0);
    if(rc) ERROR("armci_init_lapi: LAPI_Setcntr failed (buf)",rc);
    buf_cntr.val = 0;
#if 0
    pcntr = (lapi_cmpl_t*)MessageSndBuffer;
    rc = LAPI_Setcntr(lapi_handle, &pcntr->cntr, 0);
    if(rc) ERROR("armci_init_lapi: LAPI_Setcntr failed (bufcntr)",rc);
    pcntr->val = 0;
#endif

#ifdef LAPI_RDMA
    /* allocate rCxt */
    lapi_remote_cxt = (lapi_user_cxt_t*)malloc(armci_nproc *
            sizeof(lapi_user_cxt_t));
    if(lapi_remote_cxt==NULL) ERROR("armci_init_lapi: rCxt malloc failed",0);

    /* obtain remote context "rCxt" for RDMA Operation of all procs */
    for(p = 0; p< armci_nproc; p++){
        if(p==armci_me) continue;
        util_cxt.Util_type   = LAPI_REMOTE_RCXT;
        util_cxt.operation   = LAPI_RDMA_ACQUIRE;
        util_cxt.dest        = p;
        CHECK(LAPI_Util(lapi_handle, (lapi_util_t *) &util_cxt));
        lapi_remote_cxt[p]   =  util_cxt.usr_rcxt;
    }
#endif

#if  !defined(LAPI2)

    /* for high performance, disable LAPI internal error checking */
    LAPI_Senv(lapi_handle, ERROR_CHK, 0);

#endif

    /* make sure that interrupt mode is on */
    LAPI_Senv(lapi_handle, INTERRUPT_SET, 1);

    /* initialize buffer managment module */
    _armci_buf_init();

#ifdef LAPI_RDMA
    CHECK((LAPI_Gfence(lapi_handle)));
#endif
#if ARMCI_ENABLE_GPC_CALLS
    gpc_req = (gpc_buf_t *)malloc(sizeof(gpc_buf_t)*MAX_GPC_REQ);
    if(gpc_req==NULL)armci_die("malloc for gpc failed",sizeof(gpc_buf_t));
    gpc_init();
#endif
}