int Init_Main_Thread (void) {

  tid_MainThread = osThreadCreate (osThread(MainThread), NULL);
  if (!tid_MainThread) return(-1);
	
#ifdef USE_DGUS_DRIVER
	/*Initialize the USART driver */
  Driver_USART1.Initialize(DWIN_USART_callback);
  /*Power up the USART peripheral */
  Driver_USART1.PowerControl(ARM_POWER_FULL);
	
  /*Configure the USART to 115200 Bits/sec */
  Driver_USART1.Control(ARM_USART_MODE_ASYNCHRONOUS |
												ARM_USART_DATA_BITS_8 |
												ARM_USART_PARITY_NONE |
												ARM_USART_STOP_BITS_1 |
												ARM_USART_FLOW_CONTROL_NONE, DGUS_BAUDRATE);
	
	/* Enable Receiver and Transmitter lines */
  Driver_USART1.Control (ARM_USART_CONTROL_TX, 1);
  Driver_USART1.Control (ARM_USART_CONTROL_RX, 1);
	
	/* Set DGUS driver */
	DGUS_USART_Driver = &Driver_USART1;
#endif
	
  return(0);
}
Пример #2
0
// Initialize newlib
void hardware_init_hook(void) {
    // Configure LED-pins as outputs.
    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);

	// Initialize UART
	Driver_UART_DEBUG.Initialize(NULL);

#if defined(__CMSIS_RTOS) && defined(SOFTDEVICE_PRESENT)
    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);

    // We need to configure the interrupt before starting the kernel as we cannot call an SVC in an SVC Handler
    uint32_t err_code = sd_nvic_SetPriority(RTC1_IRQn, NRF_APP_PRIORITY_LOW);
    assert(err_code == NRF_SUCCESS);

    err_code = sd_nvic_EnableIRQ(RTC1_IRQn);
    assert(err_code == NRF_SUCCESS);
#endif
}
Пример #3
0
// Initialize newlib
void hardware_init_hook(void) {
	// Initialize the LED
	BSP_LED_Init(LED2);

	/* STM32L4xx HAL library initialization:
	   - Configure the Flash prefetch, Flash preread and Buffer caches
	   - Systick timer is configured by default as source of time base, but user
			 can eventually implement his proper time base source (a general purpose
			 timer for example or other time source), keeping in mind that Time base
			 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
			 handled in milliseconds basis.
	   - Low Level Initialization
	 */
	HAL_Init();

	/* Configure the System clock to have a frequency of 80 MHz */
	SystemClock_Config();

	// Initialize UART
	Driver_UART_DEBUG.Initialize(NULL);
}
Пример #4
0
/* Read "len" of char to "ptr" from file id "fd"
 * Return number of char read. */
int _read(int fd, char *ptr, int len) {
	return Driver_UART_DEBUG.Receive(ptr, len);
}
Пример #5
0
/* Write "len" of char from "ptr" to file id "fd"
 * Return number of char written. */
int _write(int fd, char *ptr, int len) {
	return Driver_UART_DEBUG.Send(ptr, len);
}
Пример #6
0
/* Write one char "ch" to the default console */
void _ttywrch(int ch) {
	Driver_UART_DEBUG.Send(&ch, 1);
}