예제 #1
0
파일: main.c 프로젝트: hudkmr/zephyr
static void bt_ready(int err)
{
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return;
	}

	printk("Bluetooth initialized\n");

	gap_init(DEVICE_NAME, HEART_RATE_APPEARANCE);
	hrs_init(0x01);
	bas_init();
	cts_init();
	dis_init(CONFIG_SOC, "Manufacturer");
	bt_gatt_register(vnd_attrs, ARRAY_SIZE(vnd_attrs));

	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));
	if (err) {
		printk("Advertising failed to start (err %d)\n", err);
		return;
	}

	printk("Advertising successfully started\n");
}
예제 #2
0
파일: main.c 프로젝트: bboozzoo/zephyr
void main(void)
{
	int err;

	err = bt_enable(NULL);
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return;
	}

	printk("Bluetooth initialized\n");

	gap_init(DEVICE_NAME, APPEARANCE);
	dis_init(CONFIG_SOC, "Manufacturer");

	bt_conn_cb_register(&conn_callbacks);

	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));
	if (err) {
		printk("Advertising failed to start (err %d)\n", err);
		return;
	}

	printk("Advertising successfully started\n");
}
예제 #3
0
void menu_conf_5(){
    
    switch(_uintCur){
        case 0: 
            if(_RmRead){
                eedata_write(_InverseDisEnable,utrue);
            }else{
                eedata_write(_InverseDisEnable,ufalse);
            }
            RESETB_Tris = 0;
            Nop();
            RESETB_Write = 0;
            delayus(500);
            RESETB_Write = 1;
            dis_init();
            menu_conf_exit(SAVED15,MENU_5);
            break;
        case 1: 
            eedata_write(_Code_Orde,_Menu5Count0);
            menu_conf_exit(SAVED15,MENU_5);
            break;
        case 2: 
            _uintCur = 0;
            lcd_dis_menu_50();
            break;
    }
    return;
}
예제 #4
0
void BLEStart(void)
{
	// Initialize Bluetooth Stack parameters
	g_LmxServ.conn_handle = BLE_CONN_HANDLE_INVALID;

	ble_stack_init();
	services_init();
	device_manager_init();
	gap_params_init();
    //bas_init();
    dis_init();
	advertising_init();
	conn_params_init();
	sec_params_init();

	// Start advertising
	advertising_start();
}
예제 #5
0
/**@brief Function for initializing services that will be used by the application.
 */
static void services_init(void)
{
	dis_init();
	bas_init();
	therm_init();

	// Configure the Temp. Sensor Service
	{
		srv_TempSensor_init_t tss_init;
		CLEAR(tss_init);
		tss_init.support_notification= true;
	    // Here the sec level for the Battery Service can be changed/increased.
	    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&tss_init.battery_level_char_attr_md.cccd_write_perm);
	    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&tss_init.battery_level_char_attr_md.read_perm);
	    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&tss_init.battery_level_char_attr_md.write_perm);
	    srv_TempSensor_init(&m_tss, &tss_init);
	}
}
예제 #6
0
파일: main.c 프로젝트: EricZaluzec/zephyr
static void bt_ready(int err)
{
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return;
	}

	printk("Bluetooth initialized\n");

	gap_init(DEVICE_NAME, CSC_APPEARANCE);
	bas_init();
	dis_init(CONFIG_SOC, "ACME");
	bt_gatt_register(csc_attrs, ARRAY_SIZE(csc_attrs));

	err = bt_le_adv_start(BT_LE_ADV(BT_LE_ADV_IND), ad, ARRAY_SIZE(ad),
					sd, ARRAY_SIZE(sd));
	if (err) {
		printk("Advertising failed to start (err %d)\n", err);
		return;
	}

	printk("Advertising successfully started\n");
}
예제 #7
0
/**@brief Initialize services that will be used by the application.
 */
static void services_init(void)
{
    dis_init();
    bas_init();
    hids_init();
}
예제 #8
0
파일: main.c 프로젝트: foldedtoad/eddystone
/*
 *  Function for bootloader main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool     dfu_start = false;
    bool     app_reset = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_START);

    if (app_reset) {
        NRF_POWER->GPREGRET = 0;
    }

    leds_init();

#if defined(DBGLOG_SUPPORT)
    uart_init();
#endif

    PUTS("\nBootloader *** " __DATE__ "  " __TIME__ " ***");

    // This check ensures that the defined fields in the bootloader 
    // corresponds with actual setting in the nRF51 chip.
    APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
    APP_ERROR_CHECK_BOOL(NRF_FICR->CODEPAGESIZE == CODE_PAGE_SIZE);

    // Initialize.
    timers_init();

#if defined(BUTTON_SUPPORT)
    buttons_init();
#endif

    (void)bootloader_init();

    if (bootloader_dfu_sd_in_progress()) {
        nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);

        err_code = bootloader_dfu_sd_update_continue();
        APP_ERROR_CHECK(err_code);

        ble_stack_init(!app_reset);
        scheduler_init();

        err_code = bootloader_dfu_sd_update_finalize();
        APP_ERROR_CHECK(err_code);

        nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
    }
    else {
        // If stack is present then continue initialization of bootloader.
        ble_stack_init(!app_reset);
        scheduler_init();
        dis_init();
    }

    dfu_start  = app_reset;

#if defined(BUTTON_SUPPORT)
    dfu_start |= ((nrf_gpio_pin_read(BOOTLOADER_BUTTON) == 0) ? true: false);
#endif

    if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START))) {

        nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);

        PUTS("Start DFU");

        // Initiate an update of the firmware.
        err_code = bootloader_dfu_start();
        APP_ERROR_CHECK(err_code);

        nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
    }

    if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) && !bootloader_dfu_sd_in_progress()) {

        PUTS("Start App");

        // Select a bank region to use as application region.
        // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
        bootloader_app_start(DFU_BANK_0_REGION_START);
    }

    NVIC_SystemReset();
}
예제 #9
0
/** dis_initialize:
 *    @dis: DIS context
 *    @data: initialization parameters
 *
 * This function initializes the DIS algorithm.
 *
 * Returns 0 on success.
 **/
int dis_initialize(dis_context_type *dis, is_init_data_t *data)
{
  int rc = 0;
  dis_init_type *init_param = &dis->init_data;

  frame_cfg_t *frame_cfg = &data->frame_cfg;
  rs_cs_config_t *rs_cs_config = &data->rs_cs_config;

  dis->input_data = *data;

  CDBG_HIGH("%s: Input Frame Cfg VFE WxH=%dx%d DIS WxH=%dx%d", __func__,
    frame_cfg->vfe_output_width, frame_cfg->vfe_output_height,
    frame_cfg->dis_frame_width, frame_cfg->dis_frame_height);
  CDBG_HIGH("%s: Input Rs_Cs RS#=%ld CS#=%ld", __func__,
    rs_cs_config->num_row_sum, rs_cs_config->num_col_sum);

  init_param->frame_rate = frame_cfg->frame_fps;
  init_param->input_frame_width = rs_cs_config->num_col_sum;
  init_param->input_frame_height = rs_cs_config->num_row_sum;

  init_param->margin_x = (frame_cfg->vfe_output_width -
    frame_cfg->dis_frame_width) / 2;
  init_param->margin_y = (frame_cfg->vfe_output_height -
    frame_cfg->dis_frame_height) / 2;

  CDBG_HIGH("%s: Before normalize Input margin x=%d y=%d", __func__,
    init_param->margin_x, init_param->margin_y);

  init_param->margin_x = (uint16_t) roundf((float)(init_param->margin_x *
    rs_cs_config->num_col_sum) / (float)frame_cfg->vfe_output_width);
  init_param->margin_y = (uint16_t) roundf((float)(init_param->margin_y *
    rs_cs_config->num_row_sum) / (float)frame_cfg->vfe_output_height);

  CDBG_HIGH("%s: After normalize Input margin x=%d y=%d", __func__,
    init_param->margin_x, init_param->margin_y);

  // stabilization search window in x, y direction (pixels)
  init_param->search_x = init_param->margin_x;
  init_param->search_y = init_param->margin_y;

  // scale factor to down sample input image horizaontally, vertically
  init_param->num_row_sum = rs_cs_config->num_row_sum;
  init_param->num_col_sum = rs_cs_config->num_col_sum;

  CDBG_HIGH("%s: init_param->input_frame_width = %u", __func__,
    init_param->input_frame_width);
  CDBG_HIGH("%s: init_param->input_frame_height = %u", __func__,
    init_param->input_frame_height);
  CDBG_HIGH("%s: init_param->margin_x = %u", __func__, init_param->margin_x);
  CDBG_HIGH("%s: init_param->margin_y = %u", __func__, init_param->margin_y);
  CDBG_HIGH("%s: init_param->search_x = %u", __func__, init_param->search_x);
  CDBG_HIGH("%s: init_param->search_y = %u", __func__, init_param->search_y);
  CDBG_HIGH("%s: init_param->frame_rate = %u", __func__,
    init_param->frame_rate);
  CDBG_HIGH("%s: init_param->num_row_sum = %u", __func__,
    init_param->num_row_sum);
  CDBG_HIGH("%s: init_param->num_col_sum = %u", __func__,
    init_param->num_col_sum);

  if (dis_init(init_param, dis) > 0) {
    CDBG_HIGH("%s: dis_init failed \n", __func__);
    rc = -1;
  }
  return rc;
}
예제 #10
0
void menu_conf_33(){

    if(_uintCur){
        menu_conf_exit(SAVED5, MENU_50);
        return;
    }
    eedata_write(_CL_Dir,_CL_Dir_Init);
    eedata_write(_Code_Orde,_Code_Orde_Init);
    eedata_write(_CLDir_Protect,_CLDir_Protect_Init);
    eedata_write(_OPDir_Protect,_OPDir_Protect_Init);
    eedata_write(_CL_TorProtect,_CL_TorProtect_Init);
    eedata_write(_OP_TorProtect,_OP_TorProtect_Init);
    eedata_write(_Sn_Fun[0],_S1_Fun_Init);  
    eedata_write(_Sn_Status[0],_S1_Status_Init);
    eedata_write(_Sn_Fun[1],_S2_Fun_Init);
    eedata_write(_Sn_Status[1],_S2_Status_Init);
    eedata_write(_Sn_Fun[2],_S3_Fun_Init);
    eedata_write(_Sn_Status[2],_S3_Status_Init);
    eedata_write(_Sn_Fun[3],_S4_Fun_Init);
    eedata_write(_Sn_Status[3],_S4_Status_Init);
    eedata_write(_Monitor_With_OverTorque,_Monitor_With_OverTorque_Init);
    eedata_write(_Monitor_With_Remote,_Monitor_With_Remote_Init);
    eedata_write(_Pos_BackL,_Pos_BackL_Init);
    eedata_write(_Pos_BackH,_Pos_BackH_Init);
    eedata_write(_Tor_BackL,_Tor_BackL_Init);
    eedata_write(_Tor_BackH,_Tor_BackH_Init);
    eedata_write(_LocalCtrl,_LocalCtrl_Init);
    eedata_write(_TwoLinesCtrl,_TwoLinesCtrl_Init);
    eedata_write(_IC_Dbd,_IC_Dbd_Init);
    eedata_write(_IC_Logic,_IC_Logic_Init);
    eedata_write(_IC_Low_VP,_IC_Low_VP_Init);
    eedata_write(_IC_High_VP,_IC_High_VP_Init);
    eedata_write(_Pos_BackLogic,_Pos_BackLogic_Init);
    eedata_write(_Tor_BackLogic,_Tor_BackLogic_Init);
    eedata_write(_Local_Lock,_Local_Lock_Init);
    eedata_write(_Remote_Lock,_Remote_Lock_Init);
    eedata_write(_ESD_Action,_ESD_Action_Init);
    eedata_write(_ESD_ExceedHot,_ESD_ExceedHot_Init);
    eedata_write(_ESD_ExceedSp,_ESD_ExceedSp_Init);
    eedata_write(_ESD_ExceedLock,_ESD_ExceedLock_Init);
    eedata_write(_ESD_ExceedTime,_ESD_ExceedTime_Init);
    eedata_write(_Forbid_ESD,_Forbid_ESD_Init);
    eedata_write(_Interim_Ctrl,_Interim_Ctrl_Init);
    eedata_write(_InverseDisEnable,_InverseDisEnable_Init);
    eedata_write(_DP_Adress,_DP_Adress_Init);
    eedata_write(_POSALS,_POSALS_Init);
    eedata_write(_POSMAX,_POSMAX_Init);
    eedata_write(_POSMIT,_POSMIT_Init);
    eedata_write(_DPSLTO,_DPSLTO_Init);
    eedata_write(_MODSLTO,_MODSLTO_Init);
    eedata_write(_AUXMSK,_AUXMSK_Init);
    eedata_write(_BANDRT,_BANDRT_Init);
    eedata_write(_PARITY,_PARITY_Init);
    eedata_write(_RelayControl,_RelayControl_Init);
    eedata_write(_BIG_SHUCK,_BIG_SHUCK_Init);
    _StatusBack = 0;
    _strAlarmFlag = 0;
    RESETB_Tris = 0;
    Nop();
    RESETB_Write = 0;
    delayus(500);
    RESETB_Write = 1;
    dis_init();
#ifndef LANGUAGE_EN
    menu_conf_exit(SAVED4,MENU_50);
#endif
    return;    
}