123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- #ifndef HAL_TIMER_H
- #define HAL_TIMER_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "hal_board.h"
- #define HAL_TIMER_0 0x00
- #define HAL_TIMER_1 0x01
- #define HAL_TIMER_2 0x02
- #define HAL_TIMER_3 0x03
- #define HAL_TIMER_MAX 4
- #define HAL_TIMER_MODE_NORMAL 0x01
- #define HAL_TIMER_MODE_CTC 0x02
- #define HAL_TIMER_MODE_MASK (HAL_TIMER_MODE_NORMAL | HAL_TIMER_MODE_CTC)
- #define HAL_TIMER_CHANNEL_SINGLE 0x01
- #define HAL_TIMER_CHANNEL_A 0x02
- #define HAL_TIMER_CHANNEL_B 0x04
- #define HAL_TIMER_CHANNEL_C 0x08
- #define HAL_TIMER_CHANNEL_MASK (HAL_TIMER_CHANNEL_SINGLE | \
- HAL_TIMER_CHANNEL_A | \
- HAL_TIMER_CHANNEL_B | \
- HAL_TIMER_CHANNEL_C)
- #define HAL_TIMER_CH_MODE_INPUT_CAPTURE 0x01
- #define HAL_TIMER_CH_MODE_OUTPUT_COMPARE 0x02
- #define HAL_TIMER_CH_MODE_OVERFLOW 0x04
- #define HAL_TIMER_CH_MODE_MASK (HAL_TIMER_CH_MODE_INPUT_CAPTURE | \
- HAL_TIMER_CH_MODE_OUTPUT_COMPARE | \
- HAL_TIMER_CH_MODE_OVERFLOW)
- #define HAL_TIMER_OK 0x00
- #define HAL_TIMER_NOT_OK 0x01
- #define HAL_TIMER_PARAMS_ERROR 0x02
- #define HAL_TIMER_NOT_CONFIGURED 0x03
- #define HAL_TIMER_INVALID_ID 0x04
- #define HAL_TIMER_INVALID_CH_MODE 0x05
- #define HAL_TIMER_INVALID_OP_MODE 0x06
- #define HAL_TIMER3_16_TC_STOP 0x00
- #define HAL_TIMER3_16_TC_DIV1 0x01
- #define HAL_TIMER3_16_TC_DIV8 0x02
- #define HAL_TIMER3_16_TC_DIV64 0x03
- #define HAL_TIMER3_16_TC_DIV256 0x04
- #define HAL_TIMER3_16_TC_DIV1024 0x05
- #define HAL_TIMER3_16_TC_EXTFE 0x06
- #define HAL_TIMER3_16_TC_EXTRE 0x07
- #define HAL_TIMER0_8_TC_STOP 0x00
- #define HAL_TIMER0_8_TC_DIV1 0x01
- #define HAL_TIMER0_8_TC_DIV8 0x02
- #define HAL_TIMER0_8_TC_DIV32 0x03
- #define HAL_TIMER0_8_TC_DIV64 0x04
- #define HAL_TIMER0_8_TC_DIV128 0x05
- #define HAL_TIMER0_8_TC_DIV256 0x06
- #define HAL_TIMER0_8_TC_DIV1024 0x07
- #define HAL_TIMER2_8_TC_STOP 0x00
- #define HAL_TIMER2_8_TC_DIV1 0x01
- #define HAL_TIMER2_8_TC_DIV8 0x02
- #define HAL_TIMER2_8_TC_DIV64 0x03
- #define HAL_TIMER2_8_TC_DIV256 0x04
- #define HAL_TIMER2_8_TC_DIV1024 0x05
- #define HAL_TIMER2_8_TC_EXTFE 0x06
- #define HAL_TIMER2_8_TC_EXTRE 0x07
- typedef void (*halTimerCBack_t) (uint8 timerId, uint8 channel, uint8 channelMode);
- extern void HalTimerInit ( void );
- extern uint8 HalTimerConfig ( uint8 timerId,
- uint8 opMode,
- uint8 channel,
- uint8 channelMode,
- bool intEnable,
- halTimerCBack_t cback );
- extern uint8 HalTimerStart ( uint8 timerId, uint32 timePerTick );
- extern uint8 HalTimerStop ( uint8 timerId );
- extern void HalTimerTick ( void );
- extern uint8 HalTimerInterruptEnable (uint8 timerId, uint8 channelMode, bool enable);
- #ifdef __cplusplus
- }
- #endif
- #endif
|