예제 #1
0
/// @brief  disnable ILI9341 reset 
/// return: void
void tft_reset_disable()
{
#ifdef ILI9341_RESET
	chip_disable(ILI9341_RESET);
#endif
}
예제 #2
0
파일: nrf_scan.c 프로젝트: pstolarz/librasp
int main(void)
{
    int ch;
    bool_t eol=FALSE, spi_ini=FALSE, gpio_ini=FALSE;

    spi_hndl_t spi_h;
    gpio_hndl_t gpio_h;

    if (gpio_init(&gpio_h, gpio_drv_io)!=LREC_SUCCESS) goto finish;
    else gpio_ini=TRUE;

    gpio_direction_output(&gpio_h, GPIO_CE, 0);

    if (spi_init(&spi_h, 0, SPI_CS, SPI_MODE_0, FALSE, 8,
        SPI_USE_DEF, SPI_USE_DEF, SPI_USE_DEF)!=LREC_SUCCESS) goto finish;
    else spi_ini=TRUE;

    signal(SIGINT, term_handler);
    signal(SIGTERM, term_handler);

    errno = 0;
    hal_nrf_set_spi_hndl(&spi_h);

    hal_nrf_set_power_mode(HAL_NRF_PWR_UP);
    usleep(1500);

    NRF_EXEC(hal_nrf_set_operation_mode(HAL_NRF_PRX));

    for (ch=0; ch<128 && !scan_finish; ch++)
    {
        int i;

        if (eol) printf("\n");

        NRF_EXEC(hal_nrf_set_rf_channel(ch));
        assert(hal_nrf_get_rf_channel()==ch);

        chip_enable();

        for (i=0; i<500; i++) {
            if (hal_nrf_get_carrier_detect()) break;
            usleep(1000);
        }

        if (i<500) {
            if (!eol) printf("\n");
            printf("Carrier detected on channel %d", ch);
            eol=TRUE;
        } else {
            printf(".");
            fflush(stdout);
            eol = (!((ch+1)%10) ? TRUE : FALSE);
        }

        chip_disable();
    }
    if (!eol) printf("\n");

finish:
    if (errno==ECOMM) printf("SPI communication error\n");
    if (spi_ini) spi_free(&spi_h);
    if (gpio_ini) gpio_free(&gpio_h);

    return 0;
}