Beispiel #1
0
int radio_setup_2g()
{
	gpio_pin_output(RADIO_GPIO_BB_MUX_SEL, OFF);

	gpio_pulldown_configure(RADIO_BB_PULLDOWN, GPIOPDDown);

	gpio_pin_output(RADIO_GPIO_BB_ON, OFF);
	udelay(100000);
	gpio_pin_output(RADIO_GPIO_RADIO_ON, ON);
	udelay(100000);
	gpio_pin_output(RADIO_GPIO_BB_RESET, ON);
	udelay(100000);
	gpio_pin_output(RADIO_GPIO_BB_RESET, OFF);
	udelay(100000);

	gpio_pin_use_as_input(RADIO_GPIO_BB_DETECT);
	if(gpio_pin_state(RADIO_GPIO_BB_DETECT) != 0)
	{
		bufferPrintf("radio: comm board not present, powered on, or at+xdrv=10,2 had been issued.\r\n");
		return -1;
	}

	bufferPrintf("radio: comm board detected.\r\n");

    
	if(!radio_wait_for_ok(10))
	{
		bufferPrintf("radio: no response from baseband!\r\n");
		return -1;
	}
  

	bufferPrintf("radio: setting speed to 750000 baud.\r\n");

	radio_write("at+ipr=750000\r\n");

	// wait a millisecond for the command to totally clear uart
	// I wasn't able to detect this condition with uart registers (looking at FIFO count, transmitter empty)
	udelay(1000);

	uart_set_baud_rate(RADIO_UART, 750000);

	if(!radio_wait_for_ok(10))
	{
		bufferPrintf("radio: no response from baseband!\r\n");
		return -1;
	}

	RadioAvailable = TRUE;

	bufferPrintf("radio: ready.\r\n");

	speaker_setup();

	return 0;
}
Beispiel #2
0
int gpio_setup() {
	// Initialise it
	uint8_t v[8];
	if (!(GET_REG(POWER + POWER_ID) & 1)) {
		gpio_custom_io(0x502, 0);
		gpio_custom_io(0x503, 0);
		gpio_custom_io(0x504, 0);
		gpio_pulldown_configure(0x502, GPIOPDDown);
		gpio_pulldown_configure(0x503, GPIOPDDown);
		gpio_pulldown_configure(0x504, GPIOPDDown);
		gpio_custom_io(0x202, 0);
		gpio_custom_io(0x301, 0);
		gpio_custom_io(0x304, 0);
		gpio_custom_io(0x305, 0);
		gpio_pulldown_configure(0x202, GPIOPDDown);
		gpio_pulldown_configure(0x301, GPIOPDDown);
		gpio_pulldown_configure(0x304, GPIOPDDown);
		gpio_pulldown_configure(0x305, GPIOPDDown);
		udelay(100);
		v[0] = chipid_get_gpio_epoch();
		v[1] = gpio_pin_state(0x504);
		v[2] = gpio_pin_state(0x503);
		v[3] = gpio_pin_state(0x502);
		v[4] = gpio_pin_state(0x305);
		v[5] = gpio_pin_state(0x304);
		v[6] = gpio_pin_state(0x301);
		v[7] = gpio_pin_state(0x202);
		gpio_custom_io(0x502, 4);
		gpio_custom_io(0x503, 4);
		gpio_custom_io(0x504, 4);
		gpio_custom_io(0x202, 4);
		gpio_custom_io(0x301, 4);
		gpio_custom_io(0x304, 4);
		gpio_custom_io(0x305, 4);
		uint32_t new_status = ((v[0] << 3 | v[1] << 2 | v[2] << 1 | v[3]) << 16) | ((v[4] << 3 | v[5] << 2 | v[6] << 1 | v[7]) << 8) | 1;
		SET_REG(POWER + POWER_ID, (GET_REG(POWER + POWER_ID) & 0xFF000000) | (new_status & 0xFFFFFF));
	}

	interrupt_install(GPIO_INTERRUPT, gpio_handle_interrupt, 0);
	interrupt_enable(GPIO_INTERRUPT);

	return 0;
}
Beispiel #3
0
int radio_setup_3g()
{
	gpio_pulldown_configure(RADIO_BB_PULLDOWN, GPIOPDDown);

	pmu_gpio(RADIO_GPIO_BB_ON, TRUE, OFF);
	udelay(100000);
	gpio_pin_output(RADIO_GPIO_RADIO_ON, ON);
	udelay(100000);
	gpio_pin_output(RADIO_GPIO_BB_RESET, ON);
	udelay(100000);
	gpio_pin_output(RADIO_GPIO_BB_RESET, OFF);
	udelay(100000);

	gpio_pin_use_as_input(RADIO_GPIO_RESET_DETECT);
	if(gpio_pin_state(RADIO_GPIO_RESET_DETECT) != 1)
	{
		bufferPrintf("radio: comm board not present, powered on, or at+xdrv=10,2 had been issued.\r\n");
		return -1;
	}

	bufferPrintf("radio: comm board detected.\r\n");

	if(!radio_wait_for_ok(10))
	{
		bufferPrintf("radio: no response from baseband!\r\n");
		return -1;
	}

	RadioAvailable = TRUE;

	bufferPrintf("radio: ready.\r\n");

	speaker_setup();

	return 0;
}