bool threewire_pin_init(t_hydra_console *con)
{
	mode_config_proto_t* proto = &con->mode->proto;

	bsp_gpio_init(BSP_GPIO_PORTB, proto->config.rawwire.clk_pin,
		      proto->config.rawwire.dev_gpio_mode, proto->config.rawwire.dev_gpio_pull);
	bsp_gpio_init(BSP_GPIO_PORTB, proto->config.rawwire.sdi_pin,
		      MODE_CONFIG_DEV_GPIO_IN, proto->config.rawwire.dev_gpio_pull);
	bsp_gpio_init(BSP_GPIO_PORTB, proto->config.rawwire.sdo_pin,
		      proto->config.rawwire.dev_gpio_mode, proto->config.rawwire.dev_gpio_pull);
	return true;
}
Example #2
0
void sysHwInit0(void)
{
    intLock();

#if PLL_EN == 0
    /*  Not use PLL  不使用PLL      */
    SysCtlClockSet(CCLK_DIV
            | SYSCTL_USE_OSC
            | SYSCTL_OSC_MAIN
            | EXT_CLK);
 #else
    /*  Use PLL  使用PLL            */
    SysCtlClockSet(CCLK_DIV
            | SYSCTL_USE_PLL
            | SYSCTL_OSC_MAIN
            | EXT_CLK);
#endif

    intLibInit();

    //系统IO初始化
    bsp_gpio_init();

    //系统串口初始化
    sysSerialHwInit();

    intUnlock();

}
Example #3
0
File: main.c Project: saiyn/OSAL
static void hal_init(void)
{
	 gSysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); 
	 //gSysClock = SysCtlClockFreqSet((SYSCTL_OSC_INT | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_320), 120000000);
	
	 //SysCtlDeepSleep();
	
	 /*systick = 1ms*/
	 SysTickPeriodSet(gSysClock / 1000);
   SysTickEnable();
   SysTickIntEnable();
	
	 bsp_gpio_init();
	 uart_hal_init();
	
	 bsp_adc_init();
	 bsp_spi0_init();
	 bsp_timer0_init();
	 bsp_timer1_init();
	 bsp_bt_uart_init();
	 bsp_nad_app_uart_init();
   
	 //bsp_pwm1_init();
	 IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
	 IntMasterEnable();
}
Example #4
0
int main( void )
{
  bsp_gpio_init();
  bsp_exit_lk_state_init(exit_lk_state_event);

  while (1) {
//    LED_R_Toggle();
//    delay_ms(100);
  }
}
Example #5
0
int main( void )
{
  bsp_gpio_init();
  bsp_temp_init();
  bsp_serial_init(NULL);

  while (1) {
    LED_Toggle();
    delay_ms(100);

    printf("chip temperature : %.2f degC\r\n", TEMP_GetTemperature());
  }
}
Example #6
0
int main( void )
{
  bsp_gpio_init();

  while (1) {
    LED_Toggle();
    delay_ms(100);
    while (KEY_Read()) {
      LED_Toggle();
      delay_ms(50);
    }
  }
}
Example #7
0
/**
 ******************************************************************************
 * @brief      硬件初始化
 * @param[in]  None
 * @param[out] None
 * @retval     None
 *
 * @details
 *
 * @note
 ******************************************************************************
 */
void sysHwInit0(void)
{
    intLock();

    SystemInit();

    intLibInit();

    //使能外设
    sysRccInit();

    //系统IO初始化
    bsp_gpio_init();

    //系统串口初始化
    sysSerialHwInit();

    intUnlock();

}
Example #8
0
int cmd_gpio(t_hydra_console *con, t_tokenline_parsed *p)
{
	uint16_t gpio[3] = { 0 };

	int mode, pull, state, port, pin, read, period, continuous, t, max;
	bool mode_changed, pull_changed;
	char *str, *s;

	mode_changed = false;
	pull_changed = false;
	t = 1;
	mode = MODE_CONFIG_DEV_GPIO_IN;
	pull = MODE_CONFIG_DEV_GPIO_NOPULL;
	state = 0;
	period = 100;
	read = FALSE;
	continuous = FALSE;
	while (p->tokens[t]) {
		switch (p->tokens[t]) {
		case T_MODE:
			switch (p->tokens[++t]) {
			case T_IN:
				mode = MODE_CONFIG_DEV_GPIO_IN;
				break;
			case T_OUT:
				mode = MODE_CONFIG_DEV_GPIO_OUT_PUSHPULL;
				break;
			case T_OPEN_DRAIN:
				mode = MODE_CONFIG_DEV_GPIO_OUT_OPENDRAIN;
				break;
			}
			mode_changed = true;
			break;
		case T_PULL:
			switch (p->tokens[++t]) {
			case T_UP:
				pull = MODE_CONFIG_DEV_GPIO_PULLUP;
				break;
			case T_DOWN:
				pull = MODE_CONFIG_DEV_GPIO_PULLDOWN;
				break;
			case T_FLOATING:
				pull = MODE_CONFIG_DEV_GPIO_NOPULL;
				break;
			}
			pull_changed = true;
			break;
		case T_ON:
		case T_OFF:
			if (state) {
				cprintf(con, "Please choose one of 'on' or 'off'.\r\n");
				return FALSE;
			}
			state = p->tokens[t];
			break;
		case T_READ:
			read = TRUE;
			break;
		case T_PERIOD:
			t += 2;
			memcpy(&period, p->buf + p->tokens[t], sizeof(int));
			break;
		case T_CONTINUOUS:
			continuous = TRUE;
			break;
		case T_ARG_STRING:
			str = p->buf + p->tokens[++t];
			if (strlen(str) < 3) {
				cprintf(con, str_pin_error, str);
				return FALSE;
			}
			/* Allow case-insensitive pin names. */
			if (str[0] > 0x60)
				str[0] -= 0x20;
			if (str[1] > 0x60)
				str[1] -= 0x20;
			if (str[0] != 'P') {
				cprintf(con, str_pin_error, str);
				return FALSE;
			}
			if (str[1] < 'A' || str[1] > 'C') {
				cprintf(con, str_pin_error, str);
				return FALSE;
			}
			port = str[1] - 'A';
			if (str[2] == '*') {
				if (port == 1)
					 /* 0 to 11 for port B */
					gpio[port] = 0x0FFF;
				else
					 /* 0 to 15 */
					gpio[port] = 0xFFFF;
			} else {
				pin = strtoul(str + 2, &s, 10);
				if ((*s != 0 && *s != '-') || pin < 0 || pin > 15
				    || (port == 1 && pin > 11)) {
					cprintf(con, str_pin_error, str);
					return FALSE;
				}
				gpio[port] |= 1 << pin;
				if (*s == '-') {
					/* Range */
					max = strtoul(s + 1, &s, 10);
					if (max <= pin || max > 15 ||
							(port == 1 && max > 11)) {
						cprintf(con, str_pin_error, str);
						return FALSE;
					}
					while (pin <= max)
						gpio[port] |= 1 << pin++;
				}
			}
			break;
		}
		t++;
	}

	if (!gpio[0] && !gpio[1] && !gpio[2]) {
		cprintf(con, "Please select at least one GPIO pin.\r\n");
		return FALSE;
	}

	if (!state && !read) {
		cprintf(con, "Please select either 'read' or on/off.\r\n");
		return FALSE;
	}

	if((mode_changed == true) || (pull_changed == true)) {
		for (port = 0; port < 3; port++) {
			for (pin = 0; pin < 16; pin++) {
				if (!(gpio[port] & (1 << pin)))
					continue;
				bsp_gpio_init(ports[port], pin, mode, pull);
			}
		}
	}

	if (!state) {
		if (continuous)
			read_continuous(con, gpio, period);
		else
			read_once(con, gpio);
	} else {
		if (state == T_ON)
			cprintf(con, "Setting ");
		else
			cprintf(con, "Clearing ");
		for (port = 0; port < 3; port++) {
			if (!gpio[port])
				continue;
			for (pin = 0; pin < 16; pin++) {
				if (!(gpio[port] & (1 << pin)))
					continue;
				if (state == T_ON)
					bsp_gpio_set(ports[port], pin);
				else
					bsp_gpio_clr(ports[port], pin);
				cprintf(con, "P%c%d ", port + 'A', pin);
			}
		}
		cprint(con, "\r\n", 2);
	}

	return TRUE;
}
Example #9
0
void BSP_DRV_Init()
{
#ifdef CONFIG_MODULE_VIC
    s32 ret = 0;
#endif

/***********************基础模块初始化***************************/
#ifdef CONFIG_BALONG_CCLK
    hi6930_clock_init();
#endif
#ifdef CONFIG_CCORE_PM
		 bsp_dpm_init();
#endif
#ifdef K3_TIMER_FEATURE
	k3_timer_init();
#endif
    adp_timer_init();
    timer_dpm_init();

    if(0 != BSP_UDI_Init())
        logMsg("BSP_UDI_Init fail\n",0,0,0,0,0,0);

    bsp_ipc_init();

	bsp_icc_init();

#ifdef CONFIG_K3V3_CLK_CRG /*CONFIG_K3V3_CLK_CRG*/
    gps_refclk_icc_read_cb_init();
#endif
	/* Cshell init if magic number is set to PRT_FLAG_EN_MAGIC_M */
#ifdef CONFIG_CSHELL
    if(0 != cshell_init())
    {
            logMsg("cshell init fail\n",0,0,0,0,0,0);
    }
#endif

#ifdef CONFIG_NVIM
     if(0 != bsp_nvm_init())
        logMsg("nv init fail\n",0,0,0,0,0,0);
#endif

    /* axi monitor监控初始化 */
    (void)bsp_amon_init();

	/*此初始化必须放置在MSP/OAM/PS初始化之前,请不要随意改动顺序*/
    tcxo_init_configure();

    if(0 != bsp_rfile_init())
        logMsg("rfile init fail\n",0,0,0,0,0,0);

	/* version inits */
    bsp_productinfo_init();

    hwspinlock_init();

    bsp_hkadc_init();

    bsp_version_init();
    bsp_lowpower_mntn_init();

#ifdef CONFIG_MODULE_VIC
    ret = bsp_vic_init();
    if(ret != OK)
    {
        logMsg("bsp_vic_init error\n", 0, 0, 0, 0, 0, 0);
    }
#endif

	(void)bsp_softtimer_init();

#ifdef CONFIG_BALONG_EDMA
    if(0 != bsp_edma_init())
    {
        logMsg("edma init fail \n",0,0,0,0,0,0);
    }
#endif

    /*C core init ipc module*/
    if(0 != socp_init())
        logMsg("socp init fail\n",0,0,0,0,0,0);

     if(0 != bsp_om_server_init())
        logMsg("om init fail\n",0,0,0,0,0,0);
	 if(0 != bsp_dual_modem_init())
	     logMsg("dual modem uart init fail\n",0,0,0,0,0,0);

/***********************外设模块初始化***************************/
    bsp_dsp_init();

#ifdef CONFIG_BBP_INT
	bbp_int_init();/*此处需要放在dsp初始化之后,放在pastar/abb之前*/
#endif

    bsp_spi_init();
    bsp_pmu_init();
	regulator_init();

#if defined(CONFIG_PMIC_HI6559)
    if(bsp_pa_rf_init())   /* 依赖于regulator_init */
    {
        logMsg("bsp_pa_rf_init fail\n",0,0,0,0,0,0);
    }
#endif

	/*init mipi*/
#ifdef CONFIG_MIPI
	bsp_mipi_init();
#endif

#ifdef CONFIG_TUNER
    bsp_tuner_init();
#endif

#ifdef CONFIG_PASTAR
	/*此函数的位置不可以向后移动,为pastar上电后,提供足够的稳定时间*/
    pmu_hi6561_init_phase1();
#endif

     if(0 != hi6930_wdt_init())
        logMsg("wdt init fail\n",0,0,0,0,0,0);

#ifdef CONFIG_CCORE_I2C

	if(0!=bsp_i2c_initial())
		logMsg("i2c init fail\n",0,0,0,0,0,0);
#endif


    if(0 != bsp_gpio_init())
        logMsg("gpio init fail\n",0,0,0,0,0,0);
#ifdef CONFIG_EFUSE
	if(0 != efuse_init())
	{
		logMsg("efuse init fail \n",0,0,0,0,0,0);
    }
#endif

#ifdef CONFIG_LEDS_CCORE
    if(0 != bsp_led_init())
    {
        logMsg("led init fail\n",0,0,0,0,0,0);
    }
#endif

/***********************通信支撑模块初始化***************************/
#ifdef CONFIG_CIPHER
    if(0 != cipher_init())
    {
        logMsg("cipher init fail \n",0,0,0,0,0,0);
    }
	if(0 != bsp_acc_init())
	{
		logMsg("acc init fail \n",0,0,0,0,0,0);
	}
#endif

#ifdef CONFIG_IPF
    if(0 != ipf_init())
        logMsg("ipf init fail\n",0,0,0,0,0,0);
#endif

#ifdef CONFIG_MODULE_BUSSTRESS
	 ipf_ul_stress_test_start(10);
#endif

#ifdef FEATURE_TLPHY_MAILBOX
    bsp_mailbox_init();
#endif

    mailbox_init();

#ifdef CONFIG_ANTEN
    if(0 != bsp_anten_init())
        logMsg("anten init fail.\n",0,0,0,0,0,0);
#endif

	bsp_sci_cfg_init();

    bsp_abb_init();

    bsp_on_off_init();

	cpufreq_init();

    /*初始化醒来的时间戳*/
    update_awake_time_stamp();

#ifdef CONFIG_CCORE_BALONG_PM
    balong_pm_init();
#endif

#ifdef CONFIG_AUDIO
    audio_init();
#endif

#ifdef CONFIG_BALONG_MODEM_RESET
	bsp_reset_init();
#endif

    (void)bsp_rf_rse_init();
#ifdef CONFIG_PASTAR
	/*勿动!此处需要放置在该函数最后,确保pastar上电后稳定后,进行初始化配置*/
	pmu_hi6561_init_phase2();
#endif

	(void)bsp_antn_sw_init();

}