AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/tc/tc.h
static inline void tc_set_resolution (volatile void *tc,
					uint32_t resolution)
  {
    uint32_t tc_clk_rate = sysclk_get_per_hz ();

    if (resolution <= (tc_clk_rate / 1024))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV1024_gc);
      }
    else if (resolution <= (tc_clk_rate / 256))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV256_gc);
      }
    else if (resolution <= (tc_clk_rate / 64))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV64_gc);
      }
    else if (resolution <= (tc_clk_rate / 8))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV8_gc);
      }
    else if (resolution <= (tc_clk_rate / 4))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV4_gc);
      }
    else if (resolution <= (tc_clk_rate / 2))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV2_gc);
      }
    else
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV1_gc);
      }
  }
/**
 * \brief Select clock for a specified TC and resolution.
 *
 * This function configures the clock selection, as prescaled CLKper, for a
 * specified TC that gives a resolution at least as high as the one specified.
 * The resolution of a TC is synonymous with its clock frequency.
 *
 * \note It is also possible to clock TCs with event channels. This is not
 * handled by this implementation.
 *
 * \param tc   ID of TC to get clock selection for.
 * \param resolution Desired resolution for the TC in Hz.
 */
\brief Select clock for a specified TC and resolution.
This function configures the clock selection, as prescaled CLKper, for a
specified TC that gives a resolution at least as high as the one specified.
The resolution of a TC is synonymous with its clock frequency.

\note It is also possible to clock TCs with event channels. This is not
handled by this implementation.

\param tc   ID of TC to get clock selection for.
\param resolution Desired resolution for the TC in Hz.
\ brief Select clock for a specified TC and resolution . This function configures the clock selection as prescaled CLKper for a specified TC that gives a resolution at least as high as the one specified . The resolution of a TC is synonymous with its clock frequency . \ note It is also possible to clock TCs with event channels . This is not handled by this implementation . \ param tc ID of TC to get clock selection for . \ param resolution Desired resolution for the TC in Hz .
static inline void tc_set_resolution (volatile void *tc,
					uint32_t resolution)
  {
    uint32_t tc_clk_rate = sysclk_get_per_hz ();
    if (resolution <= (tc_clk_rate / 1024))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV1024_gc);
      }
    else if (resolution <= (tc_clk_rate / 256))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV256_gc);
      }
    else if (resolution <= (tc_clk_rate / 64))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV64_gc);
      }
    else if (resolution <= (tc_clk_rate / 8))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV8_gc);
      }
    else if (resolution <= (tc_clk_rate / 4))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV4_gc);
      }
    else if (resolution <= (tc_clk_rate / 2))
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV2_gc);
      }
    else
      {
	tc_write_clock_source (tc, TC_CLKSEL_DIV1_gc);
      }
  }
static inline void tc_set_resolution ( volatile void * tc , uint32_t resolution ) { uint32_t tc_clk_rate = sysclk_get_per_hz ( ) ; if ( resolution <= ( tc_clk_rate / 1024 ) ) { tc_write_clock_source ( tc , TC_CLKSEL_DIV1024_gc ) ; } else if ( resolution <= ( tc_clk_rate / 256 ) ) { tc_write_clock_source ( tc , TC_CLKSEL_DIV256_gc ) ; } else if ( resolution <= ( tc_clk_rate / 64 ) ) { tc_write_clock_source ( tc , TC_CLKSEL_DIV64_gc ) ; } else if ( resolution <= ( tc_clk_rate / 8 ) ) { tc_write_clock_source ( tc , TC_CLKSEL_DIV8_gc ) ; } else if ( resolution <= ( tc_clk_rate / 4 ) ) { tc_write_clock_source ( tc , TC_CLKSEL_DIV4_gc ) ; } else if ( resolution <= ( tc_clk_rate / 2 ) ) { tc_write_clock_source ( tc , TC_CLKSEL_DIV2_gc ) ; } else { tc_write_clock_source ( tc , TC_CLKSEL_DIV1_gc ) ; } }
\brief Select clock for a specified TC and resolution.
\ brief Select clock for a specified TC and resolution .