コード例 #1
0
ファイル: spirit_gpio.c プロジェクト: AlexShiLucky/NuttX
int spirit_gpio_set_rcoprescaler(FAR struct spirit_library_s *spirit,
                                 enum spirit_clockoutput_rcoprescaler_e rcoprescaler)
{
  uint8_t regval = 0;
  int ret;

  /* Check the parameters */

  DEBUGASSERT(IS_SPIRIT_CLOCK_OUTPUT_RCO(rcoprescaler));

  /* Reads the MCU_CLK_CONFIG register */

  ret = spirit_reg_read(spirit, MCU_CK_CONF_BASE, &regval, 1);
  if (ret >= 0)
    {
      /* Mask the RCO_RATIO field and writes the new value */

      regval &= 0xfe;
      regval |= (uint8_t)rcoprescaler;

      /* Write to the new RCO prescaler in the MCU_CLOCK register */

      ret = spirit_reg_write(spirit, MCU_CK_CONF_BASE, &regval, 1);
    }

  return ret;
}
コード例 #2
0
/**
 * @brief  Initializes the SPIRIT Clock Output according to the specified
 *         parameters in the xClockOutputInitStruct.
 * @param  pxClockOutputInitStruct pointer to a ClockOutputInit structure that
 *         contains the configuration information for the SPIRIT Clock Output.
 * @retval None.
 * @note   The function SpiritGpioClockOutput() must be called in order to enable
 *         or disable the MCU clock dividers.
 */
void SpiritGpioClockOutputInit(ClockOutputInit* pxClockOutputInitStruct)
{
  uint8_t tempRegValue = 0x00;

  /* Check the parameters */
  s_assert_param(IS_SPIRIT_CLOCK_OUTPUT_XO(pxClockOutputInitStruct->xClockOutputXOPrescaler));
  s_assert_param(IS_SPIRIT_CLOCK_OUTPUT_RCO(pxClockOutputInitStruct->xClockOutputRCOPrescaler));
  s_assert_param(IS_SPIRIT_CLOCK_OUTPUT_EXTRA_CYCLES(pxClockOutputInitStruct->xExtraClockCycles));

  /* Calculates the register value to write according to the specified configuration */
  tempRegValue = ((uint8_t)(pxClockOutputInitStruct->xClockOutputXOPrescaler) | (uint8_t)(pxClockOutputInitStruct->xClockOutputRCOPrescaler) | \
           (uint8_t)(pxClockOutputInitStruct->xExtraClockCycles));

  /* Writes the MCU_CLOCK register */
  g_xStatus = SpiritSpiWriteRegisters(MCU_CK_CONF_BASE, 1, &tempRegValue);

}
コード例 #3
0
/**
 * @brief  Sets the RCO ratio as clock output
 * @param  xRCOPrescaler the RCO prescaler to be used as clock output.
 *         This parameter can be any value of @ref ClockOutputRCOPrescaler .
 * @retval None.
 */
void SpiritGpioSetRCOPrescaler(ClockOutputRCOPrescaler xRCOPrescaler)
{
  uint8_t tempRegValue = 0x00;

  /* Check the parameters */
  s_assert_param(IS_SPIRIT_CLOCK_OUTPUT_RCO(xRCOPrescaler));

  /* Reads the MCU_CLK_CONFIG register */
  g_xStatus = SpiritSpiReadRegisters(MCU_CK_CONF_BASE, 1, &tempRegValue);

  /* Mask the RCO_RATIO field and writes the new value */
  tempRegValue &= 0xFE;
  tempRegValue |= ((uint8_t)xRCOPrescaler);

  /* Writes the new RCO prescaler in the MCU_CLOCK register */
  g_xStatus = SpiritSpiWriteRegisters(MCU_CK_CONF_BASE, 1, &tempRegValue);

}
コード例 #4
0
ファイル: spirit_gpio.c プロジェクト: AlexShiLucky/NuttX
int spirit_gpio_clockoutput_initialize(FAR struct spirit_library_s *spirit,
                                       FAR const struct spirit_clockoutput_init_s *clockoutput)
{
  uint8_t regval = 0;

  /* Check the parameters */

  DEBUGASSERT(IS_SPIRIT_CLOCK_OUTPUT_XO(clockoutput->xoprescaler));
  DEBUGASSERT(IS_SPIRIT_CLOCK_OUTPUT_RCO(clockoutput->rcoprescaler));
  DEBUGASSERT(IS_SPIRIT_CLOCK_OUTPUT_EXTRA_CYCLES(clockoutput->xtracycles));

  /* Calculates the register value to write according to the specified
   * configuration */

  regval = ((uint8_t)(clockoutput->xoprescaler) |
            (uint8_t)(clockoutput->rcoprescaler) |
            (uint8_t)(clockoutput->xtracycles));

  /* Write to the the MCU_CLOCK register */

  return spirit_reg_write(spirit, MCU_CK_CONF_BASE, &regval, 1);
}