frc_timer_reg.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef _SOC_FRC_TIMER_REG_H_
  15. #define _SOC_FRC_TIMER_REG_H_
  16. #include "soc.h"
  17. /**
  18. * These are the register definitions for "legacy" timers
  19. */
  20. #define REG_FRC_TIMER_BASE(i) (DR_REG_FRC_TIMER_BASE + i*0x20)
  21. #define FRC_TIMER_LOAD_REG(i) (REG_FRC_TIMER_BASE(i) + 0x0) // timer load value (23 bit for i==0, 32 bit for i==1)
  22. #define FRC_TIMER_LOAD_VALUE(i) ((i == 0)?0x007FFFFF:0xffffffff)
  23. #define FRC_TIMER_LOAD_VALUE_S 0
  24. #define FRC_TIMER_COUNT_REG(i) (REG_FRC_TIMER_BASE(i) + 0x4) // timer count value (23 bit for i==0, 32 bit for i==1)
  25. #define FRC_TIMER_COUNT ((i == 0)?0x007FFFFF:0xffffffff)
  26. #define FRC_TIMER_COUNT_S 0
  27. #define FRC_TIMER_CTRL_REG(i) (REG_FRC_TIMER_BASE(i) + 0x8)
  28. #define FRC_TIMER_INT_STATUS (BIT(8)) // interrupt status (RO)
  29. #define FRC_TIMER_ENABLE (BIT(7)) // enable timer
  30. #define FRC_TIMER_AUTOLOAD (BIT(6)) // enable autoload
  31. #define FRC_TIMER_PRESCALER 0x00000007
  32. #define FRC_TIMER_PRESCALER_S 1
  33. #define FRC_TIMER_PRESCALER_1 (0 << FRC_TIMER_PRESCALER_S)
  34. #define FRC_TIMER_PRESCALER_16 (2 << FRC_TIMER_PRESCALER_S)
  35. #define FRC_TIMER_PRESCALER_256 (4 << FRC_TIMER_PRESCALER_S)
  36. #define FRC_TIMER_LEVEL_INT (BIT(0)) // 1: level, 0: edge
  37. #define FRC_TIMER_INT_REG(i) (REG_FRC_TIMER_BASE(i) + 0xC)
  38. #define FRC_TIMER_INT_CLR (BIT(0)) // clear interrupt
  39. #define FRC_TIMER_ALARM_REG(i) (REG_FRC_TIMER_BASE(i) + 0x10) // timer alarm value; register only present for i == 1
  40. #define FRC_TIMER_ALARM 0xFFFFFFFF
  41. #define FRC_TIMER_ALARM_S 0
  42. #endif //_SOC_FRC_TIMER_REG_H_