Esempio n. 1
0
/**
 * @brief   Low level serial driver stop.
 * @details De-initializes the UART, stops the associated clock, resets the
 *          interrupt vector.
 *
 * @param[in] sdp       pointer to a @p SerialDriver object
 *
 * @notapi
 */
void sd_lld_stop(SerialDriver *sdp) {

  if (sdp->state == SD_READY) {
    uart_deinit(sdp->uart);
#if USE_LPC214x_UART0
    if (&SD1 == sdp) {
      PCONP = (PCONP & PCALL) & ~PCUART0;
      VICIntEnClear = INTMASK(SOURCE_UART0);
      return;
    }
#endif
#if USE_LPC214x_UART1
    if (&SD2 == sdp) {
      PCONP = (PCONP & PCALL) & ~PCUART1;
      VICIntEnClear = INTMASK(SOURCE_UART1);
      return;
    }
#endif
  }
}
Esempio n. 2
0
/**
 * @brief   Low level serial driver configuration and (re)start.
 *
 * @param[in] sdp       pointer to a @p SerialDriver object
 * @param[in] config    the architecture-dependent serial driver configuration.
 *                      If this parameter is set to @p NULL then a default
 *                      configuration is used.
 *
 * @notapi
 */
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {

  if (config == NULL)
    config = &default_config;

  if (sdp->state == SD_STOP) {
#if USE_LPC214x_UART0
    if (&SD1 == sdp) {
      PCONP = (PCONP & PCALL) | PCUART0;
      VICIntEnable = INTMASK(SOURCE_UART0);
    }
#endif
#if USE_LPC214x_UART1
    if (&SD2 == sdp) {
      PCONP = (PCONP & PCALL) | PCUART1;
      VICIntEnable = INTMASK(SOURCE_UART1);
    }
#endif
  }
  uart_init(sdp, config);
}
Esempio n. 3
0
/**
 * @brief   Deactivates the SPI peripheral.
 *
 * @param[in] spip      pointer to the @p SPIDriver object
 *
 * @notapi
 */
void spi_lld_stop(SPIDriver *spip) {

  if (spip->spd_state != SPI_STOP) {
    spip->spd_ssp->SSP_CR1  = 0;
    spip->spd_ssp->SSP_CR0  = 0;
    spip->spd_ssp->SSP_CPSR = 0;
#if LPC214x_SPI_USE_SSP
    if (&SPID1 == spip) {
      PCONP = (PCONP & PCALL) & ~PCSPI1;
      VICIntEnClear = INTMASK(SOURCE_SPI1);
    }
#endif
  }
}
Esempio n. 4
0
/*
 * Board-specific initialization code.
 */
void boardInit(void) {

    /*
     * System Timer initialization, 1ms intervals.
     */
    SetVICVector(T0IrqHandler, 0, SOURCE_Timer0);
    VICIntEnable = INTMASK(SOURCE_Timer0);
    TC *timer = T0Base;
    timer->TC_PR = VAL_TC0_PRESCALER;
    timer->TC_MR0 = (PCLK / CH_FREQUENCY) / (VAL_TC0_PRESCALER + 1);
    timer->TC_MCR = 3;    /* Interrupt and clear TC on match MR0. */
    timer->TC_TCR = 2;    /* Reset counter and prescaler. */
    timer->TC_TCR = 1;    /* Timer enabled. */
}
Esempio n. 5
0
/**
 * @brief   Configures and activates the SPI peripheral.
 *
 * @param[in] spip      pointer to the @p SPIDriver object
 *
 * @notapi
 */
void spi_lld_start(SPIDriver *spip) {

  if (spip->spd_state == SPI_STOP) {
    /* Clock activation.*/
#if LPC214x_SPI_USE_SSP
    if (&SPID1 == spip) {
      PCONP = (PCONP & PCALL) | PCSPI1;
      VICIntEnable = INTMASK(SOURCE_SPI1);
    }
#endif
  }
  /* Configuration.*/
  spip->spd_ssp->SSP_CR1  = 0;
  /* Emptying the receive FIFO, it happens to not be empty while debugging.*/
  while (spip->spd_ssp->SSP_SR & SR_RNE)
    (void) spip->spd_ssp->SSP_DR;
  spip->spd_ssp->SSP_ICR  = ICR_RT | ICR_ROR;
  spip->spd_ssp->SSP_CR0  = spip->spd_config->spc_cr0;
  spip->spd_ssp->SSP_CPSR = spip->spd_config->spc_cpsr;
  spip->spd_ssp->SSP_CR1  = CR1_SSE;
}