Exemple #1
0
void ICACHE_FLASH_ATTR
user_init(void)
{
	gpio_init();
	gpio_output_set(0, 0, 0, 0xFFFFFFFF);

	//init software uart
	Softuart_SetPinRx(&softuart,13); 	
	Softuart_SetPinTx(&softuart,15);

	gpio_pin_wakeup_disable();
	PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U,FUNC_GPIO12);

	UART_SetPrintPort(UART1);
	UartDev.data_bits = EIGHT_BITS;
	UartDev.parity = NONE_BITS;
	UartDev.stop_bits = ONE_STOP_BIT;
	uart_init(BIT_RATE_9600, BIT_RATE_115200);


	//clear noise
	uart0_sendStr("\r\n\r\n\r\n");

	//wifi_set_phy_mode(3);
	system_phy_set_powerup_option(3);
	wifi_set_opmode(STATION_MODE); //Set station mode
	system_phy_set_max_tpw(82); //MAX POWERR!
	system_phy_set_tpw_via_vdd33(system_get_vdd33());
	user_set_station_config();

	os_timer_disarm(&init_timer);
	os_timer_setfn(&init_timer, (os_timer_func_t *)gps_uart_init, NULL);
	os_timer_arm(&init_timer, 1000, 0); 
}
/**
 * set the output power of WiFi
 * @param dBm max: +20.5dBm  min: 0dBm
 */
void ESP8266WiFiGenericClass::setOutputPower(float dBm) {

    if(dBm > 20.5) {
        dBm = 20.5;
    } else if(dBm < 0) {
        dBm = 0;
    }

    uint8_t val = (dBm*4.0f);
    system_phy_set_max_tpw(val);
}
user_rf_pre_init(void)
{
    // Warning: IF YOU DON'T KNOW WHAT YOU ARE DOING, DON'T TOUCH THESE CODE

    // Control RF_CAL by esp_init_data_default.bin(0~127byte) 108 byte when wakeup
    // Will low current
    // system_phy_set_rfoption(0);

    // Process RF_CAL when wakeup.
    // Will high current
    system_phy_set_rfoption(1);

    // Set Wi-Fi Tx Power, Unit: 0.25dBm, Range: [0, 82]
    system_phy_set_max_tpw(82);
}