Esempio n. 1
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);
}
Esempio n. 2
0
void startTsPort(ts_channel_s *tsChannel) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if EFI_USB_SERIAL || defined(__DOXYGEN__)
	if (isCommandLineConsoleOverTTL()) {
		print("TunerStudio over USB serial");
		/**
		 * This method contains a long delay, that's the reason why this is not done on the main thread
		 */
		usb_serial_start();
		// if console uses UART then TS uses USB
		tsChannel->channel = (BaseChannel *) CONSOLE_USB_DEVICE;
	} else
#endif
	{
		if (CONFIGB(useSerialPort)) {

			print("TunerStudio over USART");
			efiSetPadMode("tunerstudio rx", engineConfiguration->binarySerialRxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
			efiSetPadMode("tunerstudio tx", engineConfiguration->binarySerialTxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF));

#if TS_UART_DMA_MODE
			print("Using UART-DMA mode");
			// init FIFO queue
			iqObjectInit(&tsUartDma.fifoRxQueue, tsUartDma.buffer, sizeof(tsUartDma.buffer), NULL, NULL);
			
			// start DMA driver
			tsDmaUartConfig.speed = CONFIGB(tunerStudioSerialSpeed);
			uartStart(TS_DMA_UART_DEVICE, &tsDmaUartConfig);

			// start continuous DMA transfer using our circular buffer
			tsUartDma.readPos = 0;
			uartStartReceive(TS_DMA_UART_DEVICE, sizeof(tsUartDma.dmaBuffer), tsUartDma.dmaBuffer);
#else
			print("Using Serial mode");
			tsSerialConfig.speed = CONFIGB(tunerStudioSerialSpeed);

			sdStart(TS_SERIAL_UART_DEVICE, &tsSerialConfig);
			
			tsChannel->channel = (BaseChannel *) TS_SERIAL_UART_DEVICE;
#endif /* TS_UART_DMA_MODE */
		} else
			tsChannel->channel = (BaseChannel *) NULL;	// actually not used
	}
#else  /* EFI_PROD_CODE */
	tsChannel->channel = (BaseChannel *) TS_SIMULATOR_PORT;
#endif /* EFI_PROD_CODE */
}
Esempio n. 3
0
void setup(void)
{
    // we need to release the JTAG reset pin to be used as a GPIO, otherwise we can't enable
    // or disable SBUS out
    AFIO->MAPR = AFIO_MAPR_SWJ_CFG_NOJNTRST;

    hal.rcin->init();
    hal.rcout->init();

    for (uint8_t i = 0; i< 14; i++) {
        hal.rcout->enable_ch(i);
    }

    iomcu.init();

    iomcu.calculate_fw_crc();
    uartStart(&UARTD2, &uart_cfg);
    uartStartReceive(&UARTD2, sizeof(iomcu.rx_io_packet), &iomcu.rx_io_packet);
}
Esempio n. 4
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);
  }
}