Esempio n. 1
0
void 
poll(struct ctx_server* hs)
{
        /* this will trigger any scheduled timer callbacks */
        timer_poll();

        /* handle console input */
        console_poll();

        /* wl api 'tick' */
        wl_tick(timer_get_ms());

        /* lwip driver poll */
        wlif_poll(hs->net_cfg.netif);

        if (initSpiComplete) spi_poll(hs->net_cfg.netif);

#ifdef WITH_GUI
        gui_exec(timer_get_ms());
#endif
}
Esempio n. 2
0
int main(void)
{
	/* Low level initialization. */
	extern uint32_t vector_table __asm__("vector_table"); /* Defined by the linker */
	SCB_VTOR = (uint32_t) &vector_table;
	rcc_clock_setup_in_hse_8mhz_out_72mhz();

	/* Enable clock for Port B used by the LED and USB pull-up transistor */
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);

	gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO8);
	gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO9);
	gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO10);

	gpio_set(DBGO, DBG_R);
	gpio_clear(DBGO, DBG_G);
	gpio_set(DBGO, DBG_B);

	/* Setup GPIOB Pin 1 for the LED */
	gpio_set(GPIOB, GPIO1);
	gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);

	rsm500_usb_init();

	systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB);
	systick_set_reload(8999999);
	systick_interrupt_enable();
	systick_counter_enable();

	cprintf("RSM-500 spectrometer ready\n");
	while (1) {
		console_poll();
	}

	return 0;
}
Esempio n. 3
0
int
main(void)
{
	wl_err_t wl_status;
	int status;
	struct ctx_server *hs;
    enum wl_host_attention_mode mode;

    startup_init();

    board_init();

    led_init();

    tc_init();

    delay_init(FOSC0);

#ifdef _TEST_SPI_
    for (;;)
    {
    	 /* handle console input */

    	console_poll();

    	spi_poll(NULL);

     }
#else
    printk("Arduino Wifi Startup... [%s]\n", timestamp);

    size_t size_ctx_server = sizeof(struct ctx_server);
	hs = calloc(1, size_ctx_server);
	ASSERT(hs, "out of memory");

	size_t size_netif = sizeof(struct netif);
	hs->net_cfg.netif = calloc(1, size_netif);
	ASSERT(hs->net_cfg.netif, "out of memory");
	hs->net_cfg.dhcp_enabled = INIT_IP_CONFIG;

	INFO_INIT("hs:%p size:0x%x netif:%p size:0x%x\n", hs, size_ctx_server,
			hs->net_cfg.netif, size_netif);
    initShell(hs);
	timer_init(NULL, NULL);
    lwip_init();
        
	status = fw_download_init();
	ASSERT(status == 0, "failed to prepare for firmware download\n");

    wl_status = wl_transport_init(fw_read_cb, hs, &mode);
    if (wl_status != WL_SUCCESS)
            goto err;
    INFO_INIT("Mode: 0x%x\n", mode);
    wl_status = wl_init(hs, wl_init_complete_cb, mode);
    if (wl_status != WL_SUCCESS)
            goto err;

    /* start main loop */
    for (;;)
            poll(hs);


err:
    /* show error message on console and display if wlan initialization fails */

#define WL_CARD_FAILURE_STR     "Could not detect wl device, aborting\n"
#define WL_FIRMWARE_INVALID_STR "Invalid firmware data, aborting\n"
#define WL_OTHER_FAILURE_STR    "Failed to start wl initialization\n"

    switch (wl_status) {
    case WL_CARD_FAILURE:
            printk(WL_CARD_FAILURE_STR);
            break;

    case WL_FIRMWARE_INVALID:
            printk(WL_FIRMWARE_INVALID_STR);
            break;

    default:
            printk(WL_OTHER_FAILURE_STR);
            break;
    }
    for (;;) {
            timer_poll();
    }
#endif
}
Esempio n. 4
0
int main(void){
	init();

	while (1){
		/*
		 * This function will look for new messages from the AFSK channel.
		 * It will call the message_callback() function when a new message is received.
		 * If there's nothing to do, this function will call cpu_relax()
		 */
		ax25_poll(&g_ax25);

		check_run_mode();

		switch(currentMode){
			case MODE_CFG:
#if MOD_CONSOLE
				console_poll();
#endif
#if MOD_BEACON
				beacon_broadcast_poll();
#endif
				break;
#if MOD_TRACKER
			case MODE_TRACKER:
				tracker_poll();
				break;
#endif

#if MOD_KISS
			case MODE_KISS:{
				kiss_poll();
				break;
			}
#endif

#if MOD_DIGI
			case MODE_DIGI:{
				console_poll();
				beacon_broadcast_poll();
				break;
			}
#endif

			default:
				break;
		}// end of switch(runMode)

#if DEBUG_FREE_RAM
		{
			static ticks_t ts = 0;

			if(timer_clock_unlocked() -  ts > ms_to_ticks(5000)){
				ts = timer_clock_unlocked();
				uint16_t ram = freeRam();
				SERIAL_PRINTF((&g_serial),"%u\r\n",ram);
			}
		}
#endif
#if DEBUG_SOFT_SER
		// Dump the isr changes
		{
			SoftSerial *softSer = radioPort;
			static uint32_t i = 0;
			//static uint32_t j = 0;
			if(i++ == 30000){
				i = 0;

				char c;
				while(softser_avail(softSer)){
					c = softser_read(softSer);
					kfile_putc(c,&(g_serial.fd));
				}
				char buf[8];
				sprintf_P(buf,PSTR("0K\n\r"));
				softser_print(softSer,buf);
			}
		}
#endif

	} // end of while(1)
	return 0;
}