Example #1
0
int uart_write (void *_u, const char *ptr, int sz)
{
	struct uart_dev *u = _u;
	if (sz == 0) return 0;

	for (u->written=0; u->written < sz; u->written++){
		u->tx_tail = (u->tx_tail+1) & (UART_RX_BUFF_SZ-1);
		u->tx_buff[u->tx_tail] = *ptr++;
	}

	if (tx_is_ready (u->u)){
		/* Send the first byte. */
		u->tx_head = (u->tx_head+1) & (UART_RX_BUFF_SZ-1);
		u->u->udr = u->tx_buff[u->tx_head];
	}
	while (u->tx_head != u->tx_tail){
		cpu_sleep (sleep_mode_iddle);
	}

	return u->written;
}
Example #2
0
void
call_transmit_if_needed (void)
{
  NVIC_DisableIRQ (TIMER_32_0_IRQn);

  if (transmit_call) {
    DBG (DBG_LEVEL_INFO, "Transmitting station ID (%s)", CALL_STRING);
    tx_enable ();
    while (!tx_is_ready ());
    morse_send (CALL_STRING, strlen (CALL_STRING));
    systick_delay (CALL_POST_DELAY_MS);
    tx_disable ();

    transmit_call = false;

    Chip_TIMER_Reset (LPC_TIMER32_0);
    Chip_TIMER_ClearMatch(LPC_TIMER32_0, 0);
    Chip_TIMER_SetMatch (LPC_TIMER32_0, 0, CALL_INTERVAL_SEC);
    NVIC_ClearPendingIRQ (TIMER_32_0_IRQn);
  }

  NVIC_EnableIRQ (TIMER_32_0_IRQn);
}