Exemple #1
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Activates the serial driver 2 using the driver default configuration.
   */
  uartStart(&UARTD2, &uart_cfg_1);

  /*
   * Starts the transmission, it will be handled entirely in background.
   */
  uartStartSend(&UARTD2, 13, "Starting...\r\n");

  /*
   * Normal main() thread activity, in this demo it does nothing.
   */
  while (TRUE) {
    chThdSleepMilliseconds(500);
  }
  return 0;
}
Exemple #2
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Activates the serial driver 1, PA9 and PA10 are routed to USART1.
   */
  uartStart(&UARTD1, &uart_cfg_1);
  palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1));       /* USART1 TX.       */
  palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1));      /* USART1 RX.       */

  /*
   * Starts the transmission, it will be handled entirely in background.
   */
  uartStartSend(&UARTD1, 13, "Starting...\r\n");

  /*
   * Normal main() thread activity, in this demo it does nothing.
   */
  while (TRUE) {
    chThdSleepMilliseconds(500);
  }
}
Exemple #3
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Set the TX and the RX pin to use the USARTC0 module.
   * PIN3 (TXD0) as output for USARTC0.
   * PIN2 (RXD0) as input for USARTC0.
   */
  palSetPadMode(IOPORT3, PIN3, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(IOPORT3, PIN2, PAL_MODE_INPUT_PULLUP);

  /* Start the USART1 (USARTC0). */
  uartStart(&USART1D, &usart1cfg);

  /*
   * Starts the LED blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  while (TRUE) {
    uartStartSend(&USART1D,14, (const uint8_t *)"Hello world!\r\n");
    chThdSleepMilliseconds(2000);
  }
}
Exemple #4
0
static THD_FUNCTION(Thread1, arg) {

  (void)arg;
  chRegSetThreadName("Blinker");
  while (true) {
    palTogglePad(IOPORT2, PORTB_LED1);
    uartStartSend(&UARTD1, 30, (const void *) "ChibiOS PORT on ATtiny-167!.\n\r");
    chThdSleepMilliseconds(1000);
  }
}
Exemple #5
0
static void send_packet(unsigned char *data, unsigned char len) {
	// Wait for the previous transmission to finish.
	while (HW_UART_DEV.txstate == UART_TX_ACTIVE) {
		chThdSleep(1);
	}

	// Copy this data to a new buffer in case the provided one is re-used
	// after this function returns.
	static uint8_t buffer[300];
	memcpy(buffer, data, len);

	uartStartSend(&HW_UART_DEV, len, buffer);
}
Exemple #6
0
void dma_storm_uart_start(void){

  uint32_t i;

  for (i=0; i<STORM_BUF_LEN; i++){
    txbuf[i] = 0x55;
    rxbuf[i] = 0;
  }

  its = 0;
  uartStart(&UARTD6, &uart_cfg);
  uartStartReceive(&UARTD6, STORM_BUF_LEN, rxbuf);
  uartStartSend(&UARTD6, STORM_BUF_LEN, txbuf);
}
Exemple #7
0
void uart_printf(const char *format, ...)
{
	va_list ap; 
	va_start (ap, format);

	chSemWait(&uart_sem);

	/* 
	 * Build string to send to the buffer.
	 */
	vsnprintf(uart_print_buf, PRINTF_BUF_SIZE, format, ap);

	/*
	 * Print stuff UART
	 */
	uartStartSend(&UARTD3, strlen(uart_print_buf), uart_print_buf);
}
/**
 * Callback that the packet handler uses to send an assembled packet.
 *
 * @param data
 * Data array pointer
 * @param len
 * Data array length
 */
static void send_packet(unsigned char *data, unsigned int len) {
	if (len > (PACKET_MAX_PL_LEN + 5)) {
		return;
	}

	// Wait for the previous transmission to finish.
	while (UART_DEV.txstate == UART_TX_ACTIVE) {
		chThdSleep(1);
	}

	// Copy this data to a new buffer in case the provided one is re-used
	// after this function returns.
	static uint8_t buffer[PACKET_MAX_PL_LEN + 5];
	memcpy(buffer, data, len);

	// Send the data over UART
	uartStartSend(&UART_DEV, len, buffer);
}
Exemple #9
0
void glcd_spi_write_multibyte(const uint16_t length, const uint8_t *source_buffer)
{
#if GLCD_USE_SPI_UART
  if( (CHIBIOS_UART_SPI_PEREPHERIAL)->state == UART_READY ) {
    uartStartSend(CHIBIOS_UART_SPI_PEREPHERIAL, length, source_buffer);
    spi_uart_wait_callback();
  }

#else
  extern const SPIConfig lcd_spi_cfg;
  //spiStart(CHIBIOS_SPI_PEREPHERIAL, &lcd_spi_cfg);
  //spiSend(CHIBIOS_SPI_PEREPHERIAL, length, source_buffer);//chibios function call

  if( (CHIBIOS_SPI_PEREPHERIAL)->state != SPI_READY ) {
    spiTxOnlyStart(CHIBIOS_SPI_PEREPHERIAL, &lcd_spi_cfg);
  }
  spiTxOnlySend(CHIBIOS_SPI_PEREPHERIAL, length, source_buffer);//chibios function call
#endif
}
Exemple #10
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Activates the UART driver 2, PA2(TX) and PA3(RX) are routed to USART2.
   */
  uartStart(&UARTD2, &uart_cfg_1);
  palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));


  /*
   * Normal main() thread activity, in this demo it does nothing.
   */
  while (true) {
    if (palReadPad(GPIOA, GPIOA_BUTTON)) {
      /*
       * Starts both a transmission and a receive operations, both will be
       * handled entirely in background.
       */
      uartStopReceive(&UARTD2);
      uartStopSend(&UARTD2);
      uartStartReceive(&UARTD2, 16, buffer);
      uartStartSend(&UARTD2, 16, message);
    }
    chThdSleepMilliseconds(500);
  }
}
Exemple #11
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Initialize the UART interface.
   */
   uartInit();

  /*
   * Start the Uart 1 interface.
   */
  uartStart(&UARTD1, &uartConf);

  /*
   * Send an message via the UART 1 interface.
   */
  uartStartSend(&UARTD1, 15, (const void *) "Hello world!.\n\r");

  /*
   * Starts the LED blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  while (TRUE) {
    chThdSleepMilliseconds(1000);
  }
}