Ejemplo n.º 1
0
/*! initialize

*/
void mrbc_init(uint8_t *ptr, unsigned int size )
{
  mrbc_init_alloc(ptr, size);
  init_static();
  hal_init();


  // TODO 関数呼び出しが、c_XXX => mrbc_XXX の daisy chain になっている。
  //      不要な複雑さかもしれない。要リファクタリング。
  mrbc_define_method(0, mrbc_class_object, "sleep",           c_sleep);
  mrbc_define_method(0, mrbc_class_object, "sleep_ms",        c_sleep_ms);
  mrbc_define_method(0, mrbc_class_object, "relinquish",      c_relinquish);
  mrbc_define_method(0, mrbc_class_object, "change_priority", c_change_priority);
  mrbc_define_method(0, mrbc_class_object, "suspend_task",    c_suspend_task);
  mrbc_define_method(0, mrbc_class_object, "resume_task",     c_resume_task);
  mrbc_define_method(0, mrbc_class_object, "get_tcb",	      c_get_tcb);


  mrbc_class *c_mutex;
  c_mutex = mrbc_define_class(0, "Mutex", mrbc_class_object);
  mrbc_define_method(0, c_mutex, "new", c_mutex_new);
  mrbc_define_method(0, c_mutex, "lock", c_mutex_lock);
  mrbc_define_method(0, c_mutex, "unlock", c_mutex_unlock);
  mrbc_define_method(0, c_mutex, "try_lock", c_mutex_trylock);

  mrbc_class *c_vm;
  c_vm = mrbc_define_class(0, "VM", mrbc_class_object);
  mrbc_define_method(0, c_vm, "tick", c_vm_tick);
}
Ejemplo n.º 2
0
void USART_Config(void)
{
    hal_init();
    irq_init();
    tasks_init();

}
Ejemplo n.º 3
0
int rtapi_app_main(void) {
    int result;
    comp_id = hal_init(name);
    if(comp_id < 0) return comp_id;

    vtable_id = hal_export_vtable(name, VTVERSION, &vtk, comp_id);
    if (vtable_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"%s: ERROR: hal_export_vtable(%s,%d,%p) failed: %d\n",
			name, name, VTVERSION, &vtk, vtable_id );
	return -ENOENT;
    }

    haldata = hal_malloc(sizeof(struct haldata));

    result = hal_pin_float_new("maxkins.pivot-length", HAL_IO, &(haldata->pivot_length), comp_id);
    if(result < 0) goto error;

    *(haldata->pivot_length) = 0.666;

    hal_ready(comp_id);
    return 0;

error:
    hal_exit(comp_id);
    return result;
}
Ejemplo n.º 4
0
//#--------------------------------------------------------------------------------------------#//
//# hm2_test:
// .c:
int rtapi_app_main(void) {
    hm2_test_t *me;
    hm2_lowlevel_io_t *this;
    int r = 0;
    LL_PRINT("loading HostMot2 test driver with test pattern %d\n", test_pattern);
    comp_id = hal_init(HM2_LLIO_NAME);
}
Ejemplo n.º 5
0
int rtapi_app_main(void) {
    int res = 0;

    comp_id = hal_init(name);
    if(comp_id < 0) return comp_id;

    vtable_id = hal_export_vtable(name, VTVERSION, &vtk, comp_id);
    if (vtable_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"%s: ERROR: hal_export_vtable(%s,%d,%p) failed: %d\n",
			name, name, VTVERSION, &vtk, vtable_id );
	return -ENOENT;
    }

    haldata = hal_malloc(sizeof(struct haldata));
    if(!haldata) goto error;

    if((res = hal_pin_float_new("tripodkins.Bx", HAL_IO, &(haldata->bx), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("tripodkins.Cx", HAL_IO, &(haldata->cx), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("tripodkins.Cy", HAL_IO, &(haldata->cy), comp_id)) < 0) goto error;

    Bx = Cx = Cy = 1.0;
    hal_ready(comp_id);
    return 0;

error:
    hal_exit(comp_id);
    return res;
}
Ejemplo n.º 6
0
/**
 * @fn halBoardInit
 * @brief
 * Initialize the hardware target board. After this initialization, you can run your 
 * application or startup the operating system(OS).
 *
 * @param   none
 * @return  none
 */
void target_init(void)
{
    /* @todo I think you should place disable interrupts here. */

	hal_init( NULL, NULL );
    mcu_init();
    hal_disable_interrupts();
    
    rtl_init( (void*)dbio_open(9600), (TiFunDebugIoPutChar)dbio_putchar, (TiFunDebugIoGetChar)dbio_getchar, 
        hal_assert_report );

	/*
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_1_PORT, HAL_BOARD_IO_LED_1_PIN, 0);
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_2_PORT, HAL_BOARD_IO_LED_2_PIN, 0);
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_3_PORT, HAL_BOARD_IO_LED_3_PIN, 0);
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_4_PORT, HAL_BOARD_IO_LED_4_PIN, 0);

    MCU_IO_INPUT(HAL_BOARD_IO_BTN_1_PORT, HAL_BOARD_IO_BTN_1_PIN, MCU_IO_TRISTATE);
    MCU_IO_INPUT(HAL_BOARD_IO_BTN_2_PORT, HAL_BOARD_IO_BTN_2_PIN, MCU_IO_TRISTATE);

    halLcdSpiInit();
    halLcdInit();
    halAssyInit();
				  
	*/
}
Ejemplo n.º 7
0
int init(void)
{
  /* Wait in case VCC just applied */
  delay_us(100);
  /* Initialize Hardware Abstraction Layer */
  hal_init();

  /* Do uwb-phy Reset */
  HAL_ASSERT_RST();
  uwb_fsm = UWB_STATE_OFF;
  PRINTF("uwb: Reset\r\n");

  if (run_tests() == 0)
    PRINTF("uwb: ALL TESTS PASSED *****************\r\n");
  else
    PRINTF("uwb: AT LEAST ONE TEST FAILED *****************\r\n");


 /* Start the packet receive process */
  process_start(&uwb_process, NULL);

 /* Leave radio in on state (?)*/
  on();

  return 1;
}
Ejemplo n.º 8
0
int rtapi_app_main(void)
{
    int res = 0;
    comp_id = hal_init(name);
    if (comp_id < 0) return comp_id;

    haldata = hal_malloc(sizeof(struct haldata));

    if (((res = hal_pin_newf(HAL_FLOAT, HAL_IN, (void **) &(haldata->Tool_offset),
			     comp_id, "%s.Tool-offset", name)) < 0) ||
	((res = hal_pin_newf(HAL_FLOAT, HAL_IN, (void **)  &(haldata->Y_offset),
			     comp_id, "%s.Y-offset", name)) < 0) ||
	((res = hal_pin_newf(HAL_FLOAT, HAL_IN, (void **)  &(haldata->Z_offset),
			     comp_id, "%s.Z-offset", name)) < 0))
	goto error;

    vtable_id = hal_export_vtable(name, VTVERSION, &vtk, comp_id);

    if (vtable_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"%s: ERROR: hal_export_vtable(%s,%d,%p) failed: %d\n",
			name, name, VTVERSION, &vtk, vtable_id );
	return -ENOENT;
    }

    hal_ready(comp_id);
    return 0;
 error:
    hal_exit(comp_id);
    return res;
}
Ejemplo n.º 9
0
int rtapi_app_main(void) {
    int res=0;
    
    comp_id = hal_init("pumakins");
    if (comp_id < 0) return comp_id;
    
    haldata = hal_malloc(sizeof(struct haldata));
    if (!haldata) goto error;

    if((res = hal_pin_float_new("pumakins.A2", HAL_IO, &(haldata->a2), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("pumakins.A3", HAL_IO, &(haldata->a3), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("pumakins.D3", HAL_IO, &(haldata->d3), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("pumakins.D4", HAL_IO, &(haldata->d4), comp_id)) < 0) goto error;
    
    PUMA_A2 = DEFAULT_PUMA560_A2;
    PUMA_A3 = DEFAULT_PUMA560_A3;
    PUMA_D3 = DEFAULT_PUMA560_D3;
    PUMA_D4 = DEFAULT_PUMA560_D4;
    hal_ready(comp_id);
    return 0;
    
error:
    hal_exit(comp_id);
    return res;
}
Ejemplo n.º 10
0
/**
 * \brief Configure the hardware.
 */
static void prvSetupHardware(void)
{
#ifdef EXAMPLE_LCD_SIGNALLING_ENABLE
	status_code_t status;
#endif

	/* ASF function to setup clocking. */
	sysclk_init();

	/* Ensure all priority bits are assigned as preemption priority bits. */
	NVIC_SetPriorityGrouping(__NVIC_PRIO_BITS);

	/* Atmel library function to setup for the evaluation kit being used. */
	board_init();

	/* PLC HAL service initialization */
	hal_init();
	hal_start();

#ifdef EXAMPLE_LCD_SIGNALLING_ENABLE
	/* Initialize the C42364A LCD glass component. */
	status = c42364a_init();
	if (status != STATUS_OK) {
		puts("-- LCD Initialization fails! --\r\n");
		while (1) {
		}
	}

	c42364a_set_contrast(15);
	c42364a_clear_all();
	c42364a_show_icon(C42364A_ICON_ATMEL);
	c42364a_show_icon(C42364A_ICON_WLESS);
	c42364a_show_text((const uint8_t *)"SERV  ");
#endif
}
Ejemplo n.º 11
0
int rtapi_app_main(void)
{
    int retval = 0;

    comp_id = hal_init("lineardeltakins");
    if(comp_id < 0) retval = comp_id;

    if(retval == 0)
    {
        haldata = hal_malloc(sizeof(struct haldata));
        retval = !haldata;
    }

    if(retval == 0)
        retval = hal_pin_float_newf(HAL_IN, &haldata->r, comp_id,
                "lineardeltakins.R");
    if(retval == 0)
        retval = hal_pin_float_newf(HAL_IN, &haldata->l, comp_id,
                "lineardeltakins.L");

    if(retval == 0)
    {
        *haldata->r = DELTA_RADIUS;
        *haldata->l = DELTA_DIAGONAL_ROD;
    }

    if(retval == 0)
    {
        hal_ready(comp_id);
    }

    return retval;
}
Ejemplo n.º 12
0
int rtapi_app_main(void)
{
    int n, retval, i;

    if(num_chan && names[0]) {
        rtapi_print_msg(RTAPI_MSG_ERR,"num_chan= and names= are mutually exclusive\n");
        return -EINVAL;
    }
    if(!num_chan && !names[0]) num_chan = default_num_chan;

    if(num_chan) {
        howmany = num_chan;
    } else {
        for(i=0; names[i]; i++) {howmany = i+1;}
    }

    /* test for number of channels */
    if ((howmany <= 0) || (howmany > MAX_CHAN)) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SIGGEN: ERROR: invalid number of channels: %d\n", howmany);
	return -1;
    }
    /* have good config info, connect to the HAL */
    comp_id = hal_init("siggen");
    if (comp_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR, "SIGGEN: ERROR: hal_init() failed\n");
	return -1;
    }
    /* allocate shared memory for siggen data */
    siggen_array = hal_malloc(howmany * sizeof(hal_siggen_t));
    if (siggen_array == 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SIGGEN: ERROR: hal_malloc() failed\n");
	hal_exit(comp_id);
	return -1;
    }
    /* export variables and functions for each siggen */
    i = 0; // for names= items
    for (n = 0; n < howmany; n++) {
	/* export everything for this loop */
        if(num_chan) {
            char buf[HAL_NAME_LEN + 1];
            rtapi_snprintf(buf, sizeof(buf), "siggen.%d", n);
	    retval = export_siggen(n, &(siggen_array[n]),buf);
        } else {
	    retval = export_siggen(n, &(siggen_array[n]),names[i++]);
        }

	if (retval != 0) {
	    rtapi_print_msg(RTAPI_MSG_ERR,
		"SIGGEN: ERROR: siggen %d var export failed\n", n);
	    hal_exit(comp_id);
	    return -1;
	}
    }
    rtapi_print_msg(RTAPI_MSG_INFO,
	"SIGGEN: installed %d signal generators\n", howmany);
    hal_ready(comp_id);
    return 0;
}
Ejemplo n.º 13
0
/*******************************************************************************
*
* 函数名  : cmos_kernel_init
* 负责人  : 彭鹏
* 创建日期: 20150321
* 函数功能: CMOS 初始化
*
* 输入参数: 无
*
* 输出参数: 无
*
* 返回值  : 函数执行状态
*
* 调用关系: 无
* 其 它   : 无
*
******************************************************************************/
void cmos_kernel_init(void)
{
    cmos_status_T status = cmos_ERR_E;

    /* 关闭任务切换 保证初始化的串行完成 */
    cmos_hal_cortex_cortex_disalbe_switch();
	
    /* cmos hal vfs初始化 */
    status = vfs_init();
    cmos_assert(cmos_OK_E == status, __FILE__, __LINE__);

    /* cmos hal 硬件底层初始化 */
    status = hal_init();
    cmos_assert(cmos_OK_E == status, __FILE__, __LINE__);

    /* 初始化用户内存 便于调试 */
#if (CMOS_DEBUG_LEVEL > 0) 
    cmos_int32_T *sp = NULL;
    cmos_int32_T i = 0;
    cmos_int32_T iMax = 1024 * 10; /* 10kword 40kbyte */
    sp = (int *)CMOS_TASK_STACK_BASE;
    for(i = 1; i <= iMax; i++)
    {
        sp -= 1;
        *sp = 0xA5A5A5A5;
    }
#endif
    return;
}
Ejemplo n.º 14
0
int rtapi_app_main(void) {
    comp_id = hal_init("scorbot-kins");
    if (comp_id < 0) {
        return comp_id;
    }
    hal_ready(comp_id);
    return 0;
}
Ejemplo n.º 15
0
 void sys_init_func(void)
{
    //test_case_task_start();
    hal_init();
    board_cli_init();
    aos_kernel_init(&kinit);

}
Ejemplo n.º 16
0
int rtapi_app_main(void) {
    comp_id = hal_init("miller_kins");
    if(comp_id > 0) {
	hal_ready(comp_id);
	return 0;
    }
    return comp_id;
}
Ejemplo n.º 17
0
int rtapi_app_main(void)
{
    int n, numchan, max_depth, retval;
    fifo_t tmp_fifo[MAX_SAMPLERS];

    /* validate config info */
    for ( n = 0 ; n < MAX_SAMPLERS ; n++ ) {
	if (( cfg[n] == NULL ) || ( *cfg == '\0' ) || ( depth[n] <= 0 )) {
	    break;
	}
	tmp_fifo[n].num_pins = parse_types(&(tmp_fifo[n]), cfg[n]);
	if ( tmp_fifo[n].num_pins == 0 ) {
	    rtapi_print_msg(RTAPI_MSG_ERR,
		"SAMPLER: ERROR: bad config string '%s'\n", cfg[n]);
	    return -EINVAL;
	}
	/* allow one extra "slot" for the sample number */
	max_depth = MAX_SHMEM / (sizeof(shmem_data_t) * (tmp_fifo[n].num_pins + 1));
	if ( depth[n] > max_depth ) {
	    rtapi_print_msg(RTAPI_MSG_ERR,
		"SAMPLER: ERROR: depth too large, max is %d\n", max_depth);
	    return -ENOMEM;
	}
	tmp_fifo[n].depth = depth[n];
    }
    if ( n == 0 ) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SAMPLER: ERROR: no channels specified\n");
	return -EINVAL;
    }
    numchan = n;
    /* clear shmem IDs */
    for ( n = 0 ; n < MAX_SAMPLERS ; n++ ) {
	shmem_id[n] = -1;
    }

    /* have good config info, connect to the HAL */
    comp_id = hal_init("sampler");
    if (comp_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR, "SAMPLER: ERROR: hal_init() failed\n");
	return -EINVAL;
    }

    /* create the samplers - allocate memory, export pins, etc. */
    for (n = 0; n < numchan; n++) {
	retval = init_sampler(n, &(tmp_fifo[n]));
	if (retval != 0) {
	    rtapi_print_msg(RTAPI_MSG_ERR,
		"SAMPLER: ERROR: sampler %d init failed\n", n);
	    hal_exit(comp_id);
	    return retval;
	}
    }
    rtapi_print_msg(RTAPI_MSG_INFO,
	"SAMPLER: installed %d data samplers\n", numchan);
    hal_ready(comp_id);
    return 0;
}
Ejemplo n.º 18
0
void os_init () {
    memset(&OS, 0x00, sizeof(OS));
    hal_init();
    radio_init();
    LMIC_init();

	// Run os_runloop in a FreeRTOS task
	xTaskCreate(os_runloop, "lmic", tskDEFStack * 10, NULL, tskIDLE_PRIORITY, &xRunLoop);
}
Ejemplo n.º 19
0
int rtapi_app_main(void)
{
    char name[HAL_NAME_LEN + 2];
    int n, retval;

    /* only one port at the moment */
    num_ports = 1;
    n = 0; /* port number */

    /* STEP 1: initialise the driver */
    comp_id = hal_init("hal_skeleton");
    if (comp_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SKELETON: ERROR: hal_init() failed\n");
	return -1;
    }

    /* STEP 2: allocate shared memory for skeleton data */
    port_data_array = hal_malloc(num_ports * sizeof(skeleton_t));
    if (port_data_array == 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SKELETON: ERROR: hal_malloc() failed\n");
	hal_exit(comp_id);
	return -1;
    }

    /* STEP 3: export the pin(s) */
    rtapi_snprintf(name, HAL_NAME_LEN, "skeleton.%d.pin-%02d-out", n, 1);
    retval =
	hal_pin_u32_new(name, HAL_IN, &(port_data_array->data_out), comp_id);
    if (retval < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SKELETON: ERROR: port %d var export failed with err=%i\n", n,
	    retval);
	hal_exit(comp_id);
	return -1;
    }

    /* STEP 4: export write function */
    rtapi_snprintf(name, HAL_NAME_LEN, "skeleton.%d.write", n);
    retval =
	hal_export_funct(name, write_port, &(port_data_array[n]), 0, 0,
	comp_id);
    if (retval < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SKELETON: ERROR: port %d write funct export failed\n", n);
	hal_exit(comp_id);
	return -1;
    }

    rtapi_print_msg(RTAPI_MSG_INFO,
	"SKELETON: installed driver for %d ports\n", num_ports);
    hal_ready(comp_id);
    return 0;
}
Ejemplo n.º 20
0
/**
 * @fn halBoardInit
 * @brief
 * Initialize the hardware target board. After this initialization, you can run your
 * application or startup the operating system(OS).
 *
 * @param   none
 * @return  none
 */
void target_init(void)
{
    /* @todo I think you should place disable interrupts here. */

    hal_init( NULL, NULL );
    mcu_init();
    hal_disable_interrupts();

    rtl_init( (void*)dbio_open(9600), (TiFunDebugIoPutChar)dbio_putchar, (TiFunDebugIoGetChar)dbio_getchar,
              hal_assert_report );
}
Ejemplo n.º 21
0
void emu_init(char* args){
	hal_init();
//	mem_init();
// init the ppu before rom otherwise set_mirroring will not work
	ppu_init();
	rom_init();
	readrom(args);
	cpu_init(&cpu);
	
	cpu_reset(&cpu);
	emu_running = true;
}
Ejemplo n.º 22
0
void os_init () {

    memset(&OS, 0x00, sizeof(OS));

    hal_init();

	//Serial.println("os_init:: Starting radio_init"); 
	//delay(1);
    radio_init();

    LMIC_init();
}
Ejemplo n.º 23
0
void main() {
	hal_init();  // Setup IO pins and defaults
	while (1) {  // Repeatedly play games
		wait_start();
		play_start();
		if (single_game()) {
			play_winner();
			game_level++; // Next level
		} else {
			play_loser();
		}
	}
}
Ejemplo n.º 24
0
Archivo: init.c Proyecto: herumi/kernel
void init_base (struct hal_mmmap *mmmap){

  INFO("Resea " VERSION_STR);

  init_memory(mmmap);
  hal_init();
  init_res();
  add_memory_res();
  init_thread();
  init_msg();

  // start_builtin_servers()
}
Ejemplo n.º 25
0
int rtapi_app_main(void)
{
    if ((comp_id = hal_init(name)) < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"%s: ERROR: hal_init() failed: %d\n",
			name, comp_id);
	return -1;
    }
    hal_ready(comp_id);
    rtapi_print_msg(RTAPI_MSG_DBG,
		    "%s git=" GIT_VERSION " nanopb=" VERSION "\n", name);
    return 0;
}
Ejemplo n.º 26
0
int rtapi_app_main(void)
{
    int n, retval;

    /* test for too many delays asked for */
    if ((num_delays <= 0) || (num_delays > MAX_DELAYS)) {
	rtapi_print_msg(RTAPI_MSG_ERR, "TIMEDELAY: ERROR: Invalid number of bit delays\n");
	return -1;
    }
    
    /* have good config info, connect to the HAL */
    comp_id = hal_init("timedelay");
    if (comp_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "TIMEDELAY: ERROR: hal_init() failed\n");
	return -1;
    }
    /* allocate shared memory for delay array */
    delay_array = hal_malloc(num_delays * sizeof(bit_delay_t));
    if (delay_array == 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "TIMEDELAY: ERROR: hal_malloc() failed\n");
	hal_exit(comp_id);
	return -1;
    }
    /* export pins/params for all delays */
    for (n = 0; n < num_delays; n++) {
	/* export all vars */
	retval = export_delay(n, &(delay_array[n]));
	if (retval != 0) {
	    rtapi_print_msg(RTAPI_MSG_ERR,
		"TIMEDELAY: ERROR: group %d export failed\n", n);
	    hal_exit(comp_id);
	    return -1;
	}
    }

    /* export update function */
    retval = hal_export_funct("process_delays", process_delays, delay_array, 1, 0, comp_id);
    if (retval != 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "TIMEDELAY: ERROR: process_delays funct export failed\n");
	return -1;
    }

    rtapi_print_msg(RTAPI_MSG_INFO,
	"TIMEDELAY: installed %d time delays\n", num_delays);
    hal_ready(comp_id);
    return 0;
}
Ejemplo n.º 27
0
int rtapi_app_main(void)
{
    int retval;
    void *shm_base;
    long skip;
    /* connect to the HAL */
    comp_id = hal_init("scope_rt");
    if (comp_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR, "SCOPE: ERROR: hal_init() failed\n");
	return -1;
    }
    /* connect to scope shared memory block */
    skip = (sizeof(scope_shm_control_t) + 3) & ~3;
    shm_size = skip + num_samples * sizeof(scope_data_t);
    shm_id = rtapi_shmem_new(SCOPE_SHM_KEY, comp_id, shm_size);
    if (shm_id < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SCOPE RT: ERROR: failed to get shared memory (key=0x%x, size=%lu)\n",
            SCOPE_SHM_KEY,
            shm_size
        );
	hal_exit(comp_id);
	return -1;
    }
    retval = rtapi_shmem_getptr(shm_id, &shm_base);
    if (retval < 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SCOPE: ERROR: failed to map shared memory\n");
	rtapi_shmem_delete(shm_id, comp_id);
	hal_exit(comp_id);
	return -1;
    }

    /* init control structure */
    ctrl_rt = &ctrl_struct;
    init_rt_control_struct(shm_base);

    /* export scope data sampling function */
    retval = hal_export_funct("scope.sample", sample, NULL, 0, 0, comp_id);
    if (retval != 0) {
	rtapi_print_msg(RTAPI_MSG_ERR,
	    "SCOPE_RT: ERROR: sample funct export failed\n");
	hal_exit(comp_id);
	return -1;
    }
    rtapi_print_msg(RTAPI_MSG_DBG, "SCOPE_RT: installed sample function\n");
    hal_ready(comp_id);
    return 0;
}
Ejemplo n.º 28
0
int
rtapi_app_main(void)
{
    int                         i;
    Plc                         *pComp;

    // Connect to the HAL.
    component.id = hal_init("boss_plc");
    if (component.id < 0) {
        rtapi_print_msg(RTAPI_MSG_ERR, "BOSS_PLC: ERROR: hal_init() failed\n");
        return(-1);
    }

    for(i = 0; i < MAX_DEVICES; i++){
        component.plcTable[i] = NULL;
    }

    if(count > MAX_DEVICES)
        count = MAX_DEVICES;

    for(i = 0; i < count; i++){
        // Allocate memory for device object.
        pComp = hal_malloc(sizeof(Plc));

        if (pComp == NULL) {
            rtapi_print_msg(RTAPI_MSG_ERR, "BOSS_PLC: ERROR: hal_malloc() failed\n");
            hal_exit(component.id);
            return(-1);
        }

        // Save pointer to device object.
        component.plcTable[i] = pComp;

        // Initialize device.
        if(Plc_Init(pComp)){
            hal_exit(component.id);
            return(-1);
        }

        // Export pins, parameters, and functions.
        if(Plc_Export(pComp, component.id, i)){
            hal_exit(component.id);
            return(-1);
        }
    }

    hal_ready(component.id);
    return(0);
}
Ejemplo n.º 29
0
/*============================================================================*/
uint8_t bsp_init (s_ns_t * ps_ns)
{
	/* Initialize hardware */
	if (!hal_init())
		return 0;

	/* Configure board */
	if (!board_conf(ps_ns))
	    return 0;

	random_init(hal_getrand());

	/* Normal exit*/
	return 1;
}/* bsp_init() */
Ejemplo n.º 30
0
int rtapi_app_main(void) {
    int res=0;

#if (TRACE!=0)
    dptrace = fopen("art_scarakins.log","w");
#endif
    DP ("begin\n");
    comp_id = hal_init("art_scarakins");
    if (comp_id < 0) return comp_id;

    haldata = hal_malloc(sizeof(*haldata));
    if (!haldata) goto error;
    if((res = hal_pin_float_new("scarakins.D1", HAL_IO, &(haldata->d1), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("scarakins.D2", HAL_IO, &(haldata->d2), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("scarakins.D3", HAL_IO, &(haldata->d3), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("scarakins.D4", HAL_IO, &(haldata->d4), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("scarakins.D5", HAL_IO, &(haldata->d5), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("scarakins.D6", HAL_IO, &(haldata->d6), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("scarakins.PPD", HAL_IO, &(haldata->ppd), comp_id)) < 0) goto error;
    if((res = hal_pin_float_new("scarakins.SING", HAL_IO, &(haldata->sing), comp_id)) < 0) goto error;

    DPS("D1=%f ", D1);
    DPS("D2=%f ", D2);
    DPS("D3=%f ", D3);
    DPS("D4=%f ", D4);
    DPS("D5=%f ", D5);
    DPS("D6=%f ", D6);
    DPS("PPD=%f ", PPD);
    DPS("SINGU=%f ", SINGU);
    DPS("\n");
    // D1 = DEFAULT_D1;
    // D2 = DEFAULT_D2;
    // D3 = DEFAULT_D3;
    // D4 = DEFAULT_D4;
    // D5 = DEFAULT_D5;
    // D6 = DEFAULT_D6;

    hal_ready(comp_id);
    DP ("success\n");
    return 0;

error:
    hal_exit(comp_id);
#if (TRACE!=0)
    fclose(dptrace);
#endif
    return res;
}