⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tc.h

📁 FreeRTOS is a portable, open source, mini Real Time Kernel - a free to download and royalty free RTO
💻 H
📖 第 1 页 / 共 2 页
字号:
  //!   - \ref TC_EVT_EFFECT_NOOP;\n
  //!   - \ref TC_EVT_EFFECT_SET;\n
  //!   - \ref TC_EVT_EFFECT_CLEAR;\n
  //!   - \ref TC_EVT_EFFECT_TOGGLE.
  unsigned int bcpc            : 2;

  //! RB compare effect on TIOB:\n
  //!   - \ref TC_EVT_EFFECT_NOOP;\n
  //!   - \ref TC_EVT_EFFECT_SET;\n
  //!   - \ref TC_EVT_EFFECT_CLEAR;\n
  //!   - \ref TC_EVT_EFFECT_TOGGLE.
  unsigned int bcpb            : 2;

  //! Software trigger effect on TIOA:\n
  //!   - \ref TC_EVT_EFFECT_NOOP;\n
  //!   - \ref TC_EVT_EFFECT_SET;\n
  //!   - \ref TC_EVT_EFFECT_CLEAR;\n
  //!   - \ref TC_EVT_EFFECT_TOGGLE.
  unsigned int aswtrg          : 2;

  //! External event effect on TIOA:\n
  //!   - \ref TC_EVT_EFFECT_NOOP;\n
  //!   - \ref TC_EVT_EFFECT_SET;\n
  //!   - \ref TC_EVT_EFFECT_CLEAR;\n
  //!   - \ref TC_EVT_EFFECT_TOGGLE.
  unsigned int aeevt           : 2;

  //! RC compare effect on TIOA:\n
  //!   - \ref TC_EVT_EFFECT_NOOP;\n
  //!   - \ref TC_EVT_EFFECT_SET;\n
  //!   - \ref TC_EVT_EFFECT_CLEAR;\n
  //!   - \ref TC_EVT_EFFECT_TOGGLE.
  unsigned int acpc            : 2;

  //! RA compare effect on TIOA:\n
  //!   - \ref TC_EVT_EFFECT_NOOP;\n
  //!   - \ref TC_EVT_EFFECT_SET;\n
  //!   - \ref TC_EVT_EFFECT_CLEAR;\n
  //!   - \ref TC_EVT_EFFECT_TOGGLE.
  unsigned int acpa            : 2;

  unsigned int                 : 1;

  //! Waveform selection:\n
  //!   - \ref TC_WAVEFORM_SEL_UP_MODE;\n
  //!   - \ref TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER;\n
  //!   - \ref TC_WAVEFORM_SEL_UPDOWN_MODE;\n
  //!   - \ref TC_WAVEFORM_SEL_UPDOWN_MODE_RC_TRIGGER.
  unsigned int wavsel          : 2;

  //! External event trigger enable:\n
  //!   - \c FALSE;\n
  //!   - \c TRUE.
  unsigned int enetrg          : 1;

  //! External event selection:\n
  //!   - \ref TC_EXT_EVENT_SEL_TIOB_INPUT;\n
  //!   - \ref TC_EXT_EVENT_SEL_XC0_OUTPUT;\n
  //!   - \ref TC_EXT_EVENT_SEL_XC1_OUTPUT;\n
  //!   - \ref TC_EXT_EVENT_SEL_XC2_OUTPUT.
  unsigned int eevt            : 2;

  //! External event edge selection:\n
  //!   - \ref TC_SEL_NO_EDGE;\n
  //!   - \ref TC_SEL_RISING_EDGE;\n
  //!   - \ref TC_SEL_FALLING_EDGE;\n
  //!   - \ref TC_SEL_EACH_EDGE.
  unsigned int eevtedg         : 2;

  //! Counter clock disable with RC compare:\n
  //!   - \c FALSE;\n
  //!   - \c TRUE.
  unsigned int cpcdis          : 1;

  //! Counter clock stopped with RC compare:\n
  //!   - \c FALSE;\n
  //!   - \c TRUE.
  unsigned int cpcstop         : 1;

  //! Burst signal selection:\n
  //!   - \ref TC_BURST_NOT_GATED;\n
  //!   - \ref TC_BURST_CLK_AND_XC0;\n
  //!   - \ref TC_BURST_CLK_AND_XC1;\n
  //!   - \ref TC_BURST_CLK_AND_XC2.
  unsigned int burst           : 2;

  //! Clock invert:\n
  //!   - \ref TC_CLOCK_RISING_EDGE;\n
  //!   - \ref TC_CLOCK_FALLING_EDGE.
  unsigned int clki            : 1;

  //! Clock selection:\n
  //!   - \ref TC_CLOCK_SOURCE_TC1;\n
  //!   - \ref TC_CLOCK_SOURCE_TC2;\n
  //!   - \ref TC_CLOCK_SOURCE_TC3;\n
  //!   - \ref TC_CLOCK_SOURCE_TC4;\n
  //!   - \ref TC_CLOCK_SOURCE_TC5;\n
  //!   - \ref TC_CLOCK_SOURCE_XC0;\n
  //!   - \ref TC_CLOCK_SOURCE_XC1;\n
  //!   - \ref TC_CLOCK_SOURCE_XC2.
  unsigned int tcclks          : 3;
} tc_waveform_opt_t;


/*! \brief Reads timer/counter interrupt settings.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval >=0 The interrupt enable configuration organized according to \ref tc_interrupt_t.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_get_interrupt_settings(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Enables various timer/counter interrupts.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 * \param bitfield        The interrupt enable configuration.
 *
 * \retval 0 Success.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_configure_interrupts(volatile avr32_tc_t *tc, unsigned int channel, const tc_interrupt_t *bitfield);

/*! \brief Selects which external clock to use and how to configure it.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 * \param ext_clk_sig_src External clock signal selection:
 *   \arg \c TC_CH0_EXT_CLK0_SRC_TCLK0;
 *   \arg \c TC_CH0_EXT_CLK0_SRC_NO_CLK;
 *   \arg \c TC_CH0_EXT_CLK0_SRC_TIOA1;
 *   \arg \c TC_CH0_EXT_CLK0_SRC_TIOA2;
 *   \arg \c TC_CH1_EXT_CLK1_SRC_TCLK1;
 *   \arg \c TC_CH1_EXT_CLK1_SRC_NO_CLK;
 *   \arg \c TC_CH1_EXT_CLK1_SRC_TIOA0;
 *   \arg \c TC_CH1_EXT_CLK1_SRC_TIOA2;
 *   \arg \c TC_CH2_EXT_CLK2_SRC_TCLK2;
 *   \arg \c TC_CH2_EXT_CLK2_SRC_NO_CLK;
 *   \arg \c TC_CH2_EXT_CLK2_SRC_TIOA0;
 *   \arg \c TC_CH2_EXT_CLK2_SRC_TIOA1.
 *
 * \retval 0 Success.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_select_external_clock(volatile avr32_tc_t *tc, unsigned int channel, unsigned int ext_clk_sig_src);

/*! \brief Sets options for timer/counter capture initialization.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param opt             Options for capture mode.
 *
 * \retval 0 Success.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_init_capture(volatile avr32_tc_t *tc, const tc_capture_opt_t *opt);

/*! \brief Sets options for timer/counter waveform initialization.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param opt             Options for waveform generation.
 *
 * \retval 0 Success.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_init_waveform(volatile avr32_tc_t *tc, const tc_waveform_opt_t *opt);

/*! \brief Starts a timer/counter.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval 0 Success.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_start(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Stops a timer/counter.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval 0 Success.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_stop(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Performs a software trigger: the counter is reset and the clock is started.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval 0 Success.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_software_trigger(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Asserts a SYNC signal to generate a software trigger and reset all channels.
 *
 * \param tc              Pointer to the TC instance to access.
 */
extern void tc_sync_trigger(volatile avr32_tc_t *tc);

/*! \brief Reads the status register.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval >=0 Status register value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_read_sr(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Reads the channel's TC counter and returns the value.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval >=0 TC counter value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_read_tc(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Reads the channel's RA register and returns the value.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval >=0 RA register value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_read_ra(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Reads the channel's RB register and returns the value.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval >=0 RB register value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_read_rb(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Reads the channel's RC register and returns the value.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 *
 * \retval >=0 RC register value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_read_rc(volatile avr32_tc_t *tc, unsigned int channel);

/*! \brief Writes a value to the channel's RA register.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 * \param value           Value to write to the RA register.
 *
 * \retval >=0 Written value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_write_ra(volatile avr32_tc_t *tc, unsigned int channel, unsigned short value);

/*! \brief Writes a value to the channel's RB register.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 * \param value           Value to write to the RB register.
 *
 * \retval >=0 Written value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_write_rb(volatile avr32_tc_t *tc, unsigned int channel, unsigned short value);

/*! \brief Writes a value to the channel's RC register.
 *
 * \param tc              Pointer to the TC instance to access.
 * \param channel         The TC instance channel to access.
 * \param value           Value to write to the RC register.
 *
 * \retval >=0 Written value.
 * \retval TC_INVALID_ARGUMENT Invalid argument(s).
 */
extern int tc_write_rc(volatile avr32_tc_t *tc, unsigned int channel, unsigned short value);


#endif  // _TC_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -