// Read RF h/w switch (GPIOC3) to see if need to disable/enable wlan interface static int poll_rf_switch(void) { static int rf_enabled=2; static int is_wlan_enabled=-1; int temp, wlan_disabled; temp = test_gpio(); if (rf_enabled == 2) { // first time rf_enabled = temp; if(rf_enabled ==1) return 1; if(rf_enabled ==0) return 2; } if (temp != rf_enabled) { rf_enabled = temp; if (!get_flash_int_value("WLAN_DISABLED", &wlan_disabled)) return -1; if (rf_enabled && !wlan_disabled){ // enable_wlan(); return 1; //WLAN is enabled, but we should check the time match in advance } else { pre_enable_state = 0; disable_wlan(); return 2; //WLAN disabled } } #if 0 ///GPIO state no change, we donot modify wlan0 interface state, let schedule to modify the state else { if (is_wlan_enabled < 0) { // first time is_wlan_enabled = is_wlan0_exist(); get_flash_int_value("WLAN_DISABLED", &wlan_disabled); printf("is wlan_enabled==%d\n", is_wlan_enabled); if (!wlan_disabled && is_wlan_enabled && temp == 0) disable_wlan(); if(is_wlan_enabled==0) return 0; //first time check gpio status, but we check wlan by scheduld if(is_wlan_enabled ==1) return 1; } //gpio status is not changed if(temp ==1) return 1; else if(temp ==0) return 2; } #endif // gpio status is not changed if (temp == 1) return 1; else if (temp == 0) return 2; else return 0; //for compile warning only }
int self_test(usbthing_t usbthing, int interactive) { int res; res = test_gpio(usbthing, interactive); if (res < 0) { printf("GPIO test failed: %d\r\n", res); } else { printf("GPIO test OK\r\n"); } res = test_spi(usbthing, interactive); if (res < 0) { printf("SPI test failed: %d\r\n", res); } else { printf("SPI test OK\r\n"); } res = test_spi_bulk(usbthing, interactive); if (res < 0) { printf("SPI bulk test failed: %d\r\n", res); } else { printf("SPI test OK\r\n"); } res = test_adc(usbthing, interactive); if (res < 0) { printf("ADC test failed: %d\r\n", res); } else { printf("ADC test OK\r\n"); } res = test_dac_adc(usbthing, interactive); if (res < 0) { printf("DAC -> ADC test failed: %d\r\n", res); return -1; } return 0; }
void test_pinmux_gpio(void) { zassert_true(test_gpio(PIN_IN, PINMUX_FUNC_A) == TC_PASS, NULL); zassert_true(test_gpio(PIN_IN, PINMUX_FUNC_B) == TC_FAIL, NULL); }