Exemplo n.º 1
0
void bios(void) {
  uart_start();
  pwm_setup(2);
  adc_start(1);
  twi_start();

  //button code
  init_buttons();

  //set the CPU_POW led pin to high to show we have power
  DDRD |= (1<<CPU_POW);
  PORTD |= (1<<CPU_POW);

  //set the status leds as outputs
  DDRD |= (1<<stat_led1);
  DDRD |= (1<<stat_led2);

  //if this is my dev board, pull them low because the leds are cathode
  #if DEV
    PORTD &= ~(1<<stat_led1)
          & ~(1<<stat_led2);
  #endif

  #if DEBUG
    uart_sendstr("0x01 - Hardware setup successful...");
    uart_sendstr("Bios complete...");
    uart_sendstr("Starting main code...");
  #endif
  return;
}
Exemplo n.º 2
0
/**
 * main() function
 * @return 0. int return type required by ANSI/ISO standard.
 */
int main(void)
{
  simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);

#ifndef ENABLE_LOOPBACK_TEST

  uart_start();
  while(true)
  {
    uint8_t cr = simple_uart_get();
    simple_uart_put(cr);

    if(cr == 'q' || cr == 'Q')
    {
      uart_quit();
      while(1){}
    }
  }

#else
  /* This part of the example is just for testing, can be removed if you do not have a loopback setup */

  // ERROR_PIN configure as output
  nrf_gpio_cfg_output(ERROR_PIN);
  while(true)
  {
    uart_loopback_test();
  }
#endif
}
Exemplo n.º 3
0
int main()
{
    struct uart_driver_t uart;

    sys_start();

    uart_module_init();
    uart_init(&uart, &uart_device[0], 38400, NULL, 0);
    uart_start(&uart);
    sys_set_stdout(&uart.chout);

    std_printf(FSTR("Hello world!\n"));
    
    return (0);
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: eerimoq/simba
static int init()
{
    struct inet_ip_addr_t ipaddr;
    struct inet_ip_addr_t netmask;
    struct inet_ip_addr_t gw;

    sys_start();

    std_printf(sys_get_info());

    uart_init(&ipuart, &uart_device[1], 115200, iprxbuf, sizeof(iprxbuf));
    uart_start(&ipuart);

    inet_module_init();
    socket_module_init();
    network_interface_slip_module_init();

    inet_aton("169.254.1.2", &ipaddr);
    inet_aton("255.255.255.0", &netmask);
    inet_aton("0.0.0.0", &gw);

    network_interface_slip_init(&slip,
                                &ipaddr,
                                &netmask,
                                &gw,
                                &ipuart.chout);
    network_interface_add(&slip.network_interface);
    network_interface_start(&slip.network_interface);

    thrd_spawn(slip_reader,
               NULL,
               0,
               stack,
               sizeof(stack));

    http_server_init(&server,
                     &listener,
                     connections,
                     NULL,
                     routes,
                     no_route);

    http_server_start(&server);

    return (0);
}
Exemplo n.º 5
0
static int uart_write(struct tty_struct *tty,
					const unsigned char *buf, int count)
{
	struct uart_state *state = tty->driver_data;
	struct uart_port *port;
	struct circ_buf *circ;
	unsigned long flags;
	int c, ret = 0;

	if (!state) {
		WARN_ON(1);
		return -EL3HLT;
	}

	port = state->uart_port;
	circ = &state->xmit;

	if (!circ->buf)
		return 0;

	spin_lock_irqsave(&port->lock, flags);
	while (1) {
		c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
		if (count < c)
			c = count;
		if (c <= 0)
			break;
		memcpy(circ->buf + circ->head, buf, c);
		circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1);
		buf += c;
		count -= c;
		ret += c;
	}
	spin_unlock_irqrestore(&port->lock, flags);

	uart_start(tty);
	return ret;
}
Exemplo n.º 6
0
Arquivo: main.c Projeto: eerimoq/simba
static void init(void)
{
    long number;
    struct fat16_dir_t dir;
    struct fat16_dir_entry_t entry;
    struct song_t *song_p;
    uint32_t seconds;
    fat16_read_t read;
    fat16_write_t write;
    void * arg_p;

    sys_start();
    uart_module_init();

    uart_init(&uart, &uart_device[0], 38400, qinbuf, sizeof(qinbuf));
    uart_start(&uart);

    sys_set_stdout(&uart.chout);

    std_printf(sys_get_info());

    fs_command_init(&cmd_list, FSTR("/list"), cmd_list_cb, NULL);
    fs_command_register(&cmd_list);
    fs_command_init(&cmd_play, FSTR("/play"), cmd_play_cb, NULL);
    fs_command_register(&cmd_play);
    fs_command_init(&cmd_pause, FSTR("/pause"), cmd_pause_cb, NULL);
    fs_command_register(&cmd_pause);
    fs_command_init(&cmd_next, FSTR("/next"), cmd_next_cb, NULL);
    fs_command_register(&cmd_next);
    fs_command_init(&cmd_prev, FSTR("/prev"), cmd_prev_cb, NULL);
    fs_command_register(&cmd_prev);
    fs_command_init(&cmd_stop, FSTR("/stop"), cmd_stop_cb, NULL);
    fs_command_register(&cmd_stop);
    fs_command_init(&cmd_repeat, FSTR("/repeat"), cmd_repeat_cb, NULL);
    fs_command_register(&cmd_repeat);
    fs_command_init(&cmd_set_bits_per_sample,
                    FSTR("/set_bits_per_sample"),
                    cmd_set_bits_per_sample_cb,
                    NULL);
    fs_command_register(&cmd_set_bits_per_sample);

    if (storage_init(&read, &write, &arg_p) != 0) {
        std_printf(FSTR("storage init failed\r\n"));
        return;
    }

    std_printf(FSTR("initializing fat16\r\n"));
    fat16_init(&fs, read, write, arg_p, 0);

    std_printf(FSTR("fat16 initialized\r\n"));

    if (fat16_mount(&fs) != 0) {
        std_printf(FSTR("failed to mount fat16\r\n"));
        return;
    }

    std_printf(FSTR("fat16 mounted\r\n"));

    event_init(&event);

    exti_module_init();

    /* Initialize the buttons. */
    exti_init(&buttons[0],
              &exti_d18_dev,
              EXTI_TRIGGER_FALLING_EDGE,
              on_button_play,
              NULL);
    exti_start(&buttons[0]);
    exti_init(&buttons[1],
              &exti_d19_dev,
              EXTI_TRIGGER_FALLING_EDGE,
              on_button_prev,
              NULL);
    exti_start(&buttons[1]);
    exti_init(&buttons[2],
              &exti_d20_dev,
              EXTI_TRIGGER_FALLING_EDGE,
              on_button_next,
              NULL);
    exti_start(&buttons[2]);
    exti_init(&buttons[3],
              &exti_d21_dev,
              EXTI_TRIGGER_FALLING_EDGE,
              on_button_stop,
              NULL);
    exti_start(&buttons[3]);

    dac_init(&dac,
             &dac_0_dev,
             &pin_dac0_dev,
             &pin_dac1_dev,
             2 * SAMPLES_PER_SOCOND);

    hash_map_init(&song_map,
                  buckets,
                  membersof(buckets),
                  entries,
                  membersof(entries),
                  hash_number);

    sem_init(&sem, 0, 1);

    music_player_init(&music_player,
                      &fs,
                      &dac,
                      get_current_song_path,
                      get_next_song_path,
                      NULL);

    /* Initialize the song number. */
    current_song = FIRST_SONG_NUMBER;
    number = FIRST_SONG_NUMBER;

    /* Add songs to the hash map. */
    fat16_dir_open(&fs, &dir, ".", O_READ);

    while (fat16_dir_read(&dir, &entry) == 1) {
        if (number - FIRST_SONG_NUMBER == membersof(songs)) {
            std_printf("Maximum number of songs already added. "
                       "Skipping the rest of the songs.\r\n");
            break;
        }

        /* Skip folders. */
        if (entry.is_dir == 1) {
            continue;
        }

        song_p = &songs[number - FIRST_SONG_NUMBER];

        /* Initialize the song entry. */
        song_p->number = number;
        strcpy(song_p->name, entry.name);
        seconds = (entry.size / 4 / SAMPLES_PER_SOCOND);
        song_p->minutes = (seconds / 60);
        song_p->seconds = (seconds % 60);

        std_printf("Adding song %s to playlist.\r\n",
                   entry.name);

        hash_map_add(&song_map, number, song_p);
        number++;
    }

    fat16_dir_close(&dir);

    last_song_number = (number - 1);

    music_player_start(&music_player);
}
Exemplo n.º 7
0
void init_combuf()
{
    uart_start();
}
Exemplo n.º 8
0
static int uart_write(struct tty_struct *tty,
					const unsigned char *buf, int count)
{
	struct uart_state *state = tty->driver_data;
	struct uart_port *port;
	struct circ_buf *circ;
	unsigned long flags;
	int c, ret = 0;
#ifdef CONFIG_IMC_UART2DM_HANDSHAKE
	u8 retries=0;
#endif

	if (!state) {
		WARN_ON(1);
		return -EL3HLT;
	}

	port = state->uart_port;
	circ = &state->xmit;

#ifdef CONFIG_IMC_UART2DM_HANDSHAKE
	
	if (!strcmp(tty->name,"ttyHS1") && !modem_fatal) {
		if (!radio_state) {
			printk("[GSM_RADIO] %s %s radio is off \n",__func__, tty->name);
			return -EINVAL;
		}

		imc_msm_hs_request_clock_on(port);

		pr_uartdm_debug("%s %s PDA_INT_BB + \n",__func__, tty->name);
		gpio_set_value(JEL_DD_GPIO_GSM_AP_XMM_WAKE, 1);
		mdelay(1);
		while(!gpio_get_value(JEL_DD_GPIO_GSM_XMM_AP_STATUS)){
			gpio_set_value(JEL_DD_GPIO_GSM_AP_XMM_STATUS, 0);
			msleep(5);
			gpio_set_value(JEL_DD_GPIO_GSM_AP_XMM_STATUS, 1);
			msleep(20);
			if (retries>40){
				printk("[GSM_RADIO] %s %s wait for BB_STATUS + timeout \n",__func__, tty->name);
				return -EAGAIN;
			}
			retries++;
		}
	}
#endif

	if (!circ->buf)
		return 0;

	spin_lock_irqsave(&port->lock, flags);
	while (1) {
		c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
		if (count < c)
			c = count;
		if (c <= 0)
			break;
		memcpy(circ->buf + circ->head, buf, c);
		circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1);
		buf += c;
		count -= c;
		ret += c;
	}
	spin_unlock_irqrestore(&port->lock, flags);

	uart_start(tty);
	return ret;
}
Exemplo n.º 9
0
static void uart_flush_chars(struct tty_struct *tty)
{
	uart_start(tty);
}
Exemplo n.º 10
0
Arquivo: console.c Projeto: wuwx/simba
int console_start(void)
{
    return (uart_start(&module.console.uart));
}