hpm_pwm_drv.h 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. /*
  2. * Copyright (c) 2021 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_PWM_DRV_H
  8. #define HPM_PWM_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_pwm_regs.h"
  11. /**
  12. * @brief PWM driver APIs
  13. * @defgroup pwm_interface PWM driver APIs
  14. * @ingroup io_interfaces
  15. * @{
  16. *
  17. */
  18. #define PWM_UNLOCK_KEY (0xB0382607UL)
  19. /* IRQ enable bit mask */
  20. #define PWM_IRQ_FAULT PWM_IRQEN_FAULTIRQE_MASK
  21. #define PWM_IRQ_EX_RELOAD PWM_IRQEN_XRLDIRQE_MASK
  22. #define PWM_IRQ_HALF_RELOAD PWM_IRQEN_HALFRLDIRQE_MASK
  23. #define PWM_IRQ_RELOAD PWM_IRQEN_RLDIRQE_MASK
  24. #define PWM_IRQ_CMP(x) PWM_IRQEN_CMPIRQEX_SET((1 << x))
  25. /* PWM force output mask */
  26. #define PWM_FORCE_OUTPUT(pwm_index, force_output) \
  27. (force_output << (pwm_index << 1))
  28. #define PWM_DUTY_CYCLE_FP_MAX ((1U << 24) - 1)
  29. /**
  30. * @brief pwm trigger mode
  31. *
  32. */
  33. typedef enum pwm_counter_type {
  34. pwm_counter_type_capture_rising_edge, /**< rising edge trigger*/
  35. pwm_counter_type_capture_falling_edge, /**< falling edge trigger*/
  36. } pwm_counter_type_t;
  37. /**
  38. * @brief pwm cmp mode
  39. *
  40. */
  41. typedef enum pwm_cmp_mode {
  42. pwm_cmp_mode_output_compare = 0, /**< output compare*/
  43. pwm_cmp_mode_input_capture = 1, /**< input compare*/
  44. } pwm_cmp_mode_t;
  45. /**
  46. * @brief update time of the shadow register
  47. *
  48. */
  49. typedef enum pwm_register_update {
  50. pwm_shadow_register_update_on_shlk = 0, /**< after software set shlk bit of shlk register*/
  51. pwm_shadow_register_update_on_modify = 1, /**< immediately after the register being modified*/
  52. pwm_shadow_register_update_on_hw_event = 2, /**< after hardware event assert*/
  53. pwm_shadow_register_update_on_sh_synci = 3, /**< after SHSYNCI assert */
  54. } pwm_shadow_register_update_trigger_t;
  55. /**
  56. * @brief configure the state of channel 0-7 outputs when the forced output is in effect
  57. *
  58. */
  59. typedef enum pwm_fault_mode {
  60. pwm_fault_mode_force_output_0 = 0, /**< fault forced output logic 0 */
  61. pwm_fault_mode_force_output_1 = 1, /**< fault forced output logic 1 */
  62. pwm_fault_mode_force_output_highz = 2, /**< turn off output, pin becomes high resistance */
  63. } pwm_fault_mode_t;
  64. /**
  65. * @brief select when to recover PWM output after fault
  66. *
  67. */
  68. typedef enum pwm_fault_recovery_trigger {
  69. pwm_fault_recovery_immediately = 0, /**< immediately*/
  70. pwm_fault_recovery_on_reload = 1, /**< after pwm timer counter reload time*/
  71. pwm_fault_recovery_on_hw_event = 2, /**< after hardware event assert*/
  72. pwm_fault_recovery_on_fault_clear = 3, /**< after software write faultclr bit in GCR register*/
  73. } pwm_fault_recovery_trigger_t;
  74. /**
  75. * @brief fault input signal
  76. *
  77. */
  78. typedef enum pwm_fault_source {
  79. pwm_fault_source_internal_0 = PWM_GCR_FAULTI0EN_MASK, /**< FAULTI0 */
  80. pwm_fault_source_internal_1 = PWM_GCR_FAULTI1EN_MASK, /**< FAULTI1 */
  81. pwm_fault_source_internal_2 = PWM_GCR_FAULTI2EN_MASK, /**< FAULTI2 */
  82. pwm_fault_source_internal_3 = PWM_GCR_FAULTI3EN_MASK, /**< FAULTI3 */
  83. pwm_fault_source_external_0 = PWM_GCR_FAULTE0EN_MASK, /**< EXFAULTI0 */
  84. pwm_fault_source_external_1 = PWM_GCR_FAULTE1EN_MASK, /**< EXFAULTI1 */
  85. } pwm_fault_source_t;
  86. /**
  87. * @brief Select sources for force output
  88. *
  89. */
  90. typedef enum pwm_force_source {
  91. pwm_force_source_force_input = 0, /**< force output is enabled when FRCI assert */
  92. pwm_force_source_software = 1, /**< force output is enabled by software write swfrc to 1 */
  93. } pwm_force_source_t;
  94. /**
  95. * @brief select when the FRCMD shadow register will be loaded to its work register
  96. *
  97. */
  98. typedef enum pwm_force_cmd_timing {
  99. pwm_force_immediately = 0, /**< after software set shlk bit of shlk register */
  100. pwm_force_at_reload = 1, /**< immediately after the register being modified */
  101. pwm_force_at_synci = 2, /**< after hardware event assert */
  102. pwm_force_none = 3, /**< after SHSYNCI assert */
  103. } pwm_force_cmd_timing_t;
  104. /**
  105. * @brief pwm output type
  106. *
  107. */
  108. typedef enum pwm_output_type {
  109. pwm_output_0 = 0, /**< output 0 */
  110. pwm_output_1 = 1, /**< output 1 */
  111. pwm_output_high_z = 2, /**< output */
  112. pwm_output_no_force = 3,
  113. } pwm_output_type_t;
  114. /**
  115. * @brief pwm compare config
  116. *
  117. */
  118. typedef struct pwm_cmp_config {
  119. uint32_t cmp; /**< compare value */
  120. bool enable_ex_cmp; /**< enable extended compare value */
  121. #if PWM_SOC_HRPWM_SUPPORT
  122. bool enable_hrcmp; /**< enable high precision pwm */
  123. #endif
  124. uint8_t mode; /**< compare work mode: pwm_cmp_mode_output_compare or pwm_cmp_mode_input_capture */
  125. uint8_t update_trigger; /**< compare configuration update trigger */
  126. uint8_t ex_cmp; /**< extended compare value */
  127. uint8_t half_clock_cmp; /**< half clock compare value*/
  128. uint8_t jitter_cmp; /**< jitter compare value */
  129. #if PWM_SOC_HRPWM_SUPPORT
  130. uint8_t hrcmp; /**< high precision pwm */
  131. #endif
  132. } pwm_cmp_config_t;
  133. /**
  134. * @brief pwm output channel config
  135. *
  136. */
  137. typedef struct pwm_output_channel {
  138. uint8_t cmp_start_index; /**< output channel compare start index */
  139. uint8_t cmp_end_index; /**< output channel compare end index */
  140. bool invert_output; /**< invert output */
  141. } pwm_output_channel_t;
  142. /**
  143. * @brief pwm fault source config
  144. *
  145. */
  146. typedef struct pwm_fault_source_config {
  147. uint32_t source_mask; /**< fault source mask*/
  148. bool fault_recover_at_rising_edge; /**< recover fault at rising edge */
  149. bool external_fault_active_low; /**< active external fault by low */
  150. uint8_t fault_output_recovery_trigger; /**< fault output recoverty trigger */
  151. } pwm_fault_source_config_t;
  152. /**
  153. * @brief pwm config data
  154. *
  155. */
  156. typedef struct pwm_config {
  157. bool enable_output; /**< enable pwm output */
  158. bool invert_output; /**< invert pwm output level */
  159. uint8_t update_trigger; /**< pwm config update trigger */
  160. uint8_t fault_mode; /**< fault mode */
  161. uint8_t fault_recovery_trigger; /**< fault recoverty trigger */
  162. uint8_t force_source; /**< fault source */
  163. uint32_t dead_zone_in_half_cycle; /**< dead zone in half cycle*/
  164. } pwm_config_t;
  165. /**
  166. * @brief pair pwm config
  167. *
  168. */
  169. typedef struct pwm_pair_config {
  170. pwm_config_t pwm[2]; /**< pwm config data */
  171. } pwm_pair_config_t;
  172. #ifdef __cplusplus
  173. extern "C" {
  174. #endif
  175. /**
  176. * @brief issue all shawdow register
  177. *
  178. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  179. */
  180. static inline void pwm_issue_shadow_register_lock_event(PWM_Type *pwm_x)
  181. {
  182. if (pwm_x->SHCR & PWM_SHCR_SHLKEN_MASK) {
  183. /*
  184. * if lock shadow register has been enabled in SHCR, it has to set
  185. * the lock bit twice to issue shadow register lock event.
  186. */
  187. pwm_x->SHLK = PWM_SHLK_SHLK_MASK;
  188. }
  189. pwm_x->SHLK = PWM_SHLK_SHLK_MASK;
  190. }
  191. /**
  192. * @brief lock all shawdow register
  193. *
  194. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  195. */
  196. static inline void pwm_shadow_register_lock(PWM_Type *pwm_x)
  197. {
  198. pwm_x->SHCR |= PWM_SHCR_SHLKEN_MASK;
  199. pwm_x->SHLK = PWM_SHLK_SHLK_MASK;
  200. }
  201. /**
  202. * @brief unlock all shadow register
  203. *
  204. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  205. */
  206. static inline void pwm_shadow_register_unlock(PWM_Type *pwm_x)
  207. {
  208. pwm_x->UNLK = PWM_UNLOCK_KEY;
  209. }
  210. /**
  211. * @brief set counter start value and extended start value
  212. *
  213. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  214. * @param[in] ex_start pwm timer counter extended start value
  215. * @param[in] start pwm timer counter start value
  216. */
  217. static inline void pwm_set_start_count(PWM_Type *pwm_x,
  218. uint8_t ex_start,
  219. uint32_t start)
  220. {
  221. pwm_x->STA = PWM_STA_XSTA_SET(ex_start)
  222. | PWM_STA_STA_SET(start);
  223. }
  224. #if PWM_SOC_HRPWM_SUPPORT
  225. /**
  226. * @brief set hrpwm counter start value
  227. *
  228. * @param pwm_x PWM base address, HPM_PWMx(x=0..n)
  229. * @param start pwm timer counter start value
  230. */
  231. static inline void pwm_set_hrpwm_start_count(PWM_Type *pwm_x,
  232. uint32_t start)
  233. {
  234. pwm_x->STA_HRPWM = PWM_STA_HRPWM_STA_SET(start);
  235. }
  236. #endif
  237. /**
  238. * @brief set the reload value
  239. *
  240. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  241. * @param[in] ex_reload pwm timer counter extended reload value
  242. * @param[in] reload pwm timer counter reload value
  243. */
  244. static inline void pwm_set_reload(PWM_Type *pwm_x,
  245. uint8_t ex_reload,
  246. uint32_t reload)
  247. {
  248. pwm_shadow_register_unlock(pwm_x);
  249. pwm_x->RLD = PWM_RLD_XRLD_SET(ex_reload)
  250. | PWM_RLD_RLD_SET(reload);
  251. }
  252. #if PWM_SOC_HRPWM_SUPPORT
  253. /**
  254. * @brief set the hr pwm reload value
  255. *
  256. * @param pwm_x PWM base address, HPM_PWMx(x=0..n)
  257. * @param hr_reload pwm timer counter hrpwm reload value
  258. * @param reload pwm timer counter reload value
  259. */
  260. static inline void pwm_set_hrpwm_reload(PWM_Type *pwm_x,
  261. uint16_t hrpwm_reload,
  262. uint32_t reload)
  263. {
  264. pwm_shadow_register_unlock(pwm_x);
  265. pwm_x->RLD_HRPWM = PWM_RLD_HRPWM_RLD_HR_SET(hrpwm_reload)
  266. | PWM_RLD_HRPWM_RLD_SET(reload);
  267. }
  268. #endif
  269. /**
  270. * @brief clear pwm status register
  271. *
  272. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  273. * @param[in] mask :
  274. * @arg PWM_IRQ_FAULT: fault condition flag
  275. * @arg PWM_IRQ_EX_RELOAD : extended reload flag, this flag set when xcnt count to xrld value or when SYNCI assert
  276. * @arg PWM_IRQ_HALF_RELOAD: half reload flag, this flag set when cnt count to rld/2
  277. * @arg PWM_IRQ_RELOAD: reload flag, this flag set when cnt count to rld value or when SYNCI assert
  278. * @arg PWM_IRQ_CMP(x)(x=0...n): comparator output compare or input capture flag
  279. */
  280. static inline void pwm_clear_status(PWM_Type *pwm_x, uint32_t mask)
  281. {
  282. pwm_x->SR |= mask;
  283. }
  284. #if PWM_SOC_TIMER_RESET_SUPPORT
  285. /**
  286. * @brief Reset timer and extension timer
  287. *
  288. * @param pwm_x PWM base address, HPM_PWMx(x=0..n)
  289. */
  290. static inline void pwm_timer_reset(PWM_Type *pwm_x)
  291. {
  292. pwm_x->GCR = ((pwm_x->GCR & ~(PWM_GCR_TIMERRESET_MASK)) | PWM_GCR_TIMERRESET_SET(1));
  293. }
  294. #endif
  295. /**
  296. * @brief get pwm status register
  297. *
  298. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  299. * @retval uint32_t SR register value
  300. */
  301. static inline uint32_t pwm_get_status(PWM_Type *pwm_x)
  302. {
  303. return pwm_x->SR;
  304. }
  305. /**
  306. * @brief disable pwm irq
  307. *
  308. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  309. * @param[in] mask :
  310. * @arg PWM_IRQ_FAULT: fault condition interrupt enable
  311. * @arg PWM_IRQ_EX_RELOAD: extended reload flag interrupt enable
  312. * @arg PWM_IRQ_HALF_RELOAD: half reload flag interrupt enable
  313. * @arg PWM_IRQ_RELOAD: reload flag interrupt enable
  314. * @arg PWM_IRQ_CMP(x)(x=0...n): comparator output compare or input capture flag interrupt enable
  315. */
  316. static inline void pwm_disable_irq(PWM_Type *pwm_x, uint32_t mask)
  317. {
  318. pwm_x->IRQEN &= ~mask;
  319. }
  320. /**
  321. * @brief enable pwm irq
  322. *
  323. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  324. * @param[in] mask :
  325. * @arg PWM_IRQ_FAULT: fault condition interrupt enable
  326. * @arg PWM_IRQ_EX_RELOAD: extended reload flag interrupt enable
  327. * @arg PWM_IRQ_HALF_RELOAD: half reload flag interrupt enable
  328. * @arg PWM_IRQ_RELOAD: reload flag interrupt enable
  329. * @arg PWM_IRQ_CMP(x)(x=0...n): comparator output compare or input capture flag interrupt enable
  330. */
  331. static inline void pwm_enable_irq(PWM_Type *pwm_x, uint32_t mask)
  332. {
  333. pwm_x->IRQEN |= mask;
  334. }
  335. /**
  336. * @brief disable pwm dma request
  337. *
  338. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  339. * @param[in] mask :
  340. * @arg PWM_IRQ_FAULT: fault condition DMA request enable
  341. * @arg PWM_IRQ_EX_RELOAD: extended reload flag DMA request enable
  342. * @arg PWM_IRQ_HALF_RELOAD: half reload flag DMA request enable
  343. * @arg PWM_IRQ_RELOAD: reload flag DMA request enable
  344. * @arg PWM_IRQ_CMP(x)(x=0...n): comparator output compare or input capture flag DMA request enable
  345. *
  346. */
  347. static inline void pwm_disable_dma_request(PWM_Type *pwm_x, uint32_t mask)
  348. {
  349. pwm_x->DMAEN &= ~mask;
  350. }
  351. /**
  352. * @brief enable pwm dma request
  353. *
  354. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  355. * @param[in] mask :
  356. * @arg PWM_IRQ_FAULT: fault condition DMA request enable
  357. * @arg PWM_IRQ_EX_RELOAD: extended reload flag DMA request enable
  358. * @arg PWM_IRQ_HALF_RELOAD: half reload flag DMA request enable
  359. * @arg PWM_IRQ_RELOAD: reload flag DMA request enable
  360. * @arg PWM_IRQ_CMP(x)(x=0...n): comparator output compare or input capture flag DMA request enable
  361. *
  362. */
  363. static inline void pwm_enable_dma_request(PWM_Type *pwm_x, uint32_t mask)
  364. {
  365. pwm_x->DMAEN |= mask;
  366. }
  367. /**
  368. * @brief set target cmp as hardware event to trigger force cmd output
  369. *
  370. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  371. * @param[in] target_cmp_index cmp index select one of the cmp as hardware event time to load FRCMD shadow registers [0-23]
  372. */
  373. static inline void pwm_set_force_cmd_shadow_register_hwevent(PWM_Type *pwm_x,
  374. uint8_t target_cmp_index)
  375. {
  376. pwm_x->SHCR = ((pwm_x->SHCR & ~(PWM_SHCR_FRCSHDWSEL_MASK))
  377. | PWM_SHCR_FRCSHDWSEL_SET(target_cmp_index));
  378. }
  379. /**
  380. * @note if trigger is not set to hardware event, target_cmp_index can be
  381. * passed with any value
  382. *
  383. */
  384. /**
  385. * @brief set shadow register control register
  386. *
  387. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  388. * @param[in] trigger select when the counter related shadow registers @ref pwm_shadow_register_update_trigger_t
  389. * @param[in] target_cmp_index select one of the comparators as hardware event (0..(PWM_SOC_CMP_MAX_COUNT-1))
  390. */
  391. static inline void pwm_set_load_counter_shadow_register_trigger(PWM_Type *pwm_x,
  392. pwm_shadow_register_update_trigger_t trigger,
  393. uint8_t target_cmp_index)
  394. {
  395. if (trigger == pwm_shadow_register_update_on_hw_event) {
  396. pwm_x->SHCR = ((pwm_x->SHCR & ~(PWM_SHCR_CNTSHDWSEL_MASK
  397. | PWM_SHCR_CNTSHDWUPT_MASK))
  398. | PWM_SHCR_CNTSHDWSEL_SET(target_cmp_index)
  399. | PWM_SHCR_CNTSHDWUPT_SET(trigger));
  400. } else {
  401. pwm_x->SHCR = ((pwm_x->SHCR & ~(PWM_SHCR_CNTSHDWUPT_MASK))
  402. | PWM_SHCR_CNTSHDWUPT_SET(trigger));
  403. }
  404. }
  405. /**
  406. * @brief Configure input capture cmp to trigger shadow register updates
  407. *
  408. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  409. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  410. * @param[in] is_falling_edge which edge is used as shadow register hardware load event
  411. * @arg 1- falling edge
  412. * @arg 0- rising edge
  413. */
  414. static inline void pwm_load_cmp_shadow_on_capture(PWM_Type *pwm_x,
  415. uint8_t index,
  416. bool is_falling_edge)
  417. {
  418. pwm_x->CMPCFG[index] |= PWM_CMPCFG_CMPMODE_MASK;
  419. pwm_x->GCR = ((pwm_x->GCR & ~(PWM_GCR_CMPSHDWSEL_MASK | PWM_GCR_HWSHDWEDG_MASK))
  420. | PWM_GCR_CMPSHDWSEL_SET(index)
  421. | PWM_GCR_HWSHDWEDG_SET(is_falling_edge));
  422. }
  423. #if PWM_SOC_SHADOW_TRIG_SUPPORT
  424. /**
  425. * @brief Set the timer shadow register to update the trigger edge
  426. *
  427. * @param[in] pwm_x pwm_x PWM base address, HPM_PWMx(x=0..n)
  428. * @param[in] is_falling_edge which edge is used as shadow register hardware load event
  429. * @arg 1- falling edge
  430. * @arg 0- rising edge
  431. */
  432. static inline void pwm_set_cnt_shadow_trig_edge(PWM_Type *pwm_x,
  433. bool is_falling_edge)
  434. {
  435. pwm_x->SHCR = ((pwm_x->SHCR & ~PWM_SHCR_CNT_UPDATE_EDGE_MASK)
  436. | PWM_SHCR_CNT_UPDATE_EDGE_SET(is_falling_edge));
  437. }
  438. /**
  439. * @brief Set the force output shadow register to update the trigger edge
  440. *
  441. * @param[in] pwm_x pwm_x PWM base address, HPM_PWMx(x=0..n)
  442. * @param[in] is_falling_edge which edge is used as shadow register hardware load event
  443. * @arg 1- falling edge
  444. * @arg 0- rising edge
  445. */
  446. static inline void pwm_set_force_shadow_trig_edge(PWM_Type *pwm_x,
  447. bool is_falling_edge)
  448. {
  449. pwm_x->SHCR = ((pwm_x->SHCR & ~PWM_SHCR_FORCE_UPDATE_EDGE_MASK)
  450. | PWM_SHCR_FORCE_UPDATE_EDGE_SET(is_falling_edge));
  451. }
  452. #endif
  453. /**
  454. * @brief disable pwn cmp half clock
  455. *
  456. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  457. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  458. */
  459. static inline void pwm_cmp_disable_half_clock(PWM_Type *pwm_x, uint8_t index)
  460. {
  461. pwm_x->CMP[index] &= ~PWM_CMP_CMPHLF_MASK;
  462. }
  463. /**
  464. * @brief enable pwm cmp half clock
  465. *
  466. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  467. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  468. */
  469. static inline void pwm_cmp_enable_half_clock(PWM_Type *pwm_x, uint8_t index)
  470. {
  471. pwm_x->CMP[index] |= PWM_CMP_CMPHLF_MASK;
  472. }
  473. /**
  474. * @brief update pwm cmp jitter counter compare value
  475. *
  476. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  477. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  478. * @param[in] jitter jitter value
  479. */
  480. static inline void pwm_cmp_update_jitter_value(PWM_Type *pwm_x, uint8_t index, uint8_t jitter)
  481. {
  482. pwm_x->CMP[index] = (pwm_x->CMP[index] & ~PWM_CMP_CMPJIT_MASK) | PWM_CMP_CMPJIT_SET(jitter);
  483. }
  484. /**
  485. * @brief update pwm cmp value
  486. *
  487. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  488. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  489. * @param[in] cmp clock counter compare value
  490. * @param[in] ex_cmp extended counter compare value
  491. */
  492. static inline void pwm_cmp_update_cmp_value(PWM_Type *pwm_x, uint8_t index,
  493. uint32_t cmp, uint16_t ex_cmp)
  494. {
  495. pwm_x->CMP[index] = (pwm_x->CMP[index] & ~(PWM_CMP_CMP_MASK | PWM_CMP_XCMP_MASK))
  496. | PWM_CMP_CMP_SET(cmp) | PWM_CMP_XCMP_SET(ex_cmp);
  497. }
  498. #if PWM_SOC_HRPWM_SUPPORT
  499. /**
  500. * @brief update high-precision cmp value
  501. *
  502. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  503. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  504. * @param[in] cmp clock counter compare value
  505. * @param[in] hrcmp high-precision pwm
  506. */
  507. static inline void pwm_cmp_update_hrcmp_value(PWM_Type *pwm_x, uint8_t index,
  508. uint32_t cmp, uint16_t hrcmp)
  509. {
  510. pwm_x->CMP_HRPWM[index] = (pwm_x->CMP_HRPWM[index] & ~(PWM_CMP_HRPWM_CMP_MASK | PWM_CMP_HRPWM_CMP_HR_MASK))
  511. | PWM_CMP_HRPWM_CMP_SET(cmp) | PWM_CMP_HRPWM_CMP_HR_SET(hrcmp);
  512. }
  513. #endif
  514. /**
  515. * @brief Forced update of pwm cmp register value, cmp content guaranteed accurate by user
  516. *
  517. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  518. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  519. * @param[in] cmp cmp register data
  520. */
  521. static inline void pwm_cmp_force_value(PWM_Type *pwm_x, uint8_t index, uint32_t cmp)
  522. {
  523. pwm_x->CMP[index] = cmp;
  524. }
  525. /**
  526. * @brief config pwm cmp
  527. *
  528. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  529. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  530. * @param[in] config @ref pwm_cmp_config_t
  531. */
  532. static inline void pwm_config_cmp(PWM_Type *pwm_x, uint8_t index, pwm_cmp_config_t *config)
  533. {
  534. pwm_shadow_register_unlock(pwm_x);
  535. if (config->mode == pwm_cmp_mode_output_compare) {
  536. #if PWM_SOC_HRPWM_SUPPORT
  537. if (config->enable_hrcmp) {
  538. pwm_x->CMPCFG[index] = PWM_CMPCFG_CMPSHDWUPT_SET(config->update_trigger);
  539. pwm_x->CMP[index] = PWM_CMP_HRPWM_CMP_SET(config->cmp)
  540. | PWM_CMP_HRPWM_CMP_HR_SET(config->hrcmp);
  541. } else {
  542. #endif
  543. pwm_x->CMPCFG[index] = PWM_CMPCFG_XCNTCMPEN_SET(config->enable_ex_cmp)
  544. | PWM_CMPCFG_CMPSHDWUPT_SET(config->update_trigger);
  545. pwm_x->CMP[index] = PWM_CMP_CMP_SET(config->cmp)
  546. | PWM_CMP_XCMP_SET(config->ex_cmp)
  547. | PWM_CMP_CMPHLF_SET(config->half_clock_cmp)
  548. | PWM_CMP_CMPJIT_SET(config->jitter_cmp);
  549. #if PWM_SOC_HRPWM_SUPPORT
  550. }
  551. #endif
  552. } else {
  553. pwm_x->CMPCFG[index] |= PWM_CMPCFG_CMPMODE_MASK;
  554. }
  555. }
  556. /**
  557. * @brief config pwm output channel
  558. *
  559. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  560. * @param[in] index channel index (0..(PWM_SOC_PWM_MAX_COUNT-1))
  561. * @param[in] config @ref pwm_output_channel_t
  562. */
  563. static inline void pwm_config_output_channel(PWM_Type *pwm_x, uint8_t index, pwm_output_channel_t *config)
  564. {
  565. pwm_x->CHCFG[index] = PWM_CHCFG_CMPSELBEG_SET(config->cmp_start_index)
  566. | PWM_CHCFG_CMPSELEND_SET(config->cmp_end_index)
  567. | PWM_CHCFG_OUTPOL_SET(config->invert_output);
  568. }
  569. /**
  570. * @brief config pwm fault source
  571. *
  572. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  573. * @param[in] config @ref pwm_fault_source_config_t
  574. */
  575. static inline void pwm_config_fault_source(PWM_Type *pwm_x, pwm_fault_source_config_t *config)
  576. {
  577. pwm_x->GCR = (pwm_x->GCR & ~(PWM_GCR_FAULTI0EN_MASK | PWM_GCR_FAULTI1EN_MASK
  578. | PWM_GCR_FAULTI2EN_MASK | PWM_GCR_FAULTI3EN_MASK
  579. | PWM_GCR_FAULTE0EN_MASK | PWM_GCR_FAULTE1EN_MASK
  580. | PWM_GCR_FAULTRECEDG_MASK | PWM_GCR_FAULTEXPOL_MASK
  581. | PWM_GCR_FAULTRECHWSEL_MASK))
  582. | config->source_mask
  583. | PWM_GCR_FAULTEXPOL_SET(config->external_fault_active_low)
  584. | PWM_GCR_FAULTRECEDG_SET(config->fault_recover_at_rising_edge)
  585. | PWM_GCR_FAULTRECHWSEL_SET(config->fault_output_recovery_trigger);
  586. }
  587. /**
  588. * @brief clear pwm fault status
  589. *
  590. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  591. */
  592. static inline void pwm_clear_fault(PWM_Type *pwm_x)
  593. {
  594. pwm_x->GCR |= PWM_GCR_FAULTCLR_MASK;
  595. }
  596. /**
  597. * @brief stop the pwm timer counter
  598. *
  599. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  600. */
  601. static inline void pwm_stop_counter(PWM_Type *pwm_x)
  602. {
  603. pwm_x->GCR &= ~PWM_GCR_CEN_MASK;
  604. }
  605. /**
  606. * @brief start pwm timer counter
  607. *
  608. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  609. */
  610. static inline void pwm_start_counter(PWM_Type *pwm_x)
  611. {
  612. pwm_x->GCR |= PWM_GCR_CEN_MASK;
  613. }
  614. /**
  615. * @brief enable software force
  616. *
  617. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  618. */
  619. static inline void pwm_enable_sw_force(PWM_Type *pwm_x)
  620. {
  621. pwm_x->GCR |= PWM_GCR_SWFRC_MASK;
  622. }
  623. /**
  624. * @brief disable software force , force will take effect
  625. *
  626. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  627. */
  628. static inline void pwm_disable_sw_force(PWM_Type *pwm_x)
  629. {
  630. pwm_x->GCR &= ~PWM_GCR_SWFRC_MASK;
  631. }
  632. /**
  633. * @brief enable pwm reload value by synci
  634. *
  635. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  636. */
  637. static inline void pwm_enable_reload_at_synci(PWM_Type *pwm_x)
  638. {
  639. pwm_x->GCR |= PWM_GCR_XRLDSYNCEN_MASK | PWM_GCR_RLDSYNCEN_MASK;
  640. }
  641. /**
  642. * @brief disable pwm output
  643. *
  644. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  645. * @param[in] index pwm index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  646. */
  647. static inline void pwm_disable_output(PWM_Type *pwm_x, uint8_t index)
  648. {
  649. pwm_x->PWMCFG[index] &= ~PWM_PWMCFG_OEN_MASK;
  650. }
  651. /**
  652. * @brief enable pwm output
  653. *
  654. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  655. * @param[in] index pwm index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  656. */
  657. static inline void pwm_enable_output(PWM_Type *pwm_x, uint8_t index)
  658. {
  659. pwm_x->PWMCFG[index] |= PWM_PWMCFG_OEN_MASK;
  660. }
  661. /**
  662. * @brief config pwm force output level per output channel
  663. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  664. * @param[in] output_mask PWM output channel force level, set it using the macro
  665. * @arg PWM_FORCE_OUTPUT(pwm_index, force_output)
  666. */
  667. static inline void pwm_set_force_output(PWM_Type *pwm_x, uint32_t output_mask)
  668. {
  669. pwm_x->FRCMD = PWM_FRCMD_FRCMD_SET(output_mask);
  670. }
  671. /**
  672. * @brief config pwm force polarity
  673. *
  674. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  675. * @param[in] polarity polarity of input pwm_force
  676. * @arg 1- active low
  677. * @arg 0- active high
  678. */
  679. static inline void pwm_config_force_polarity(PWM_Type *pwm_x, bool polarity)
  680. {
  681. pwm_x->GCR = (pwm_x->GCR & ~(PWM_GCR_FRCPOL_MASK)) | PWM_GCR_FRCPOL_SET(polarity);
  682. }
  683. /**
  684. * @brief config the force effective time
  685. *
  686. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  687. * @param[in] timing @ref pwm_force_cmd_timing_t
  688. */
  689. static inline void pwm_config_force_cmd_timing(PWM_Type *pwm_x, pwm_force_cmd_timing_t timing)
  690. {
  691. pwm_x->GCR = (pwm_x->GCR & ~(PWM_GCR_FRCTIME_MASK)) | PWM_GCR_FRCTIME_SET(timing);
  692. }
  693. /**
  694. * @brief enable pwm sw force output
  695. *
  696. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  697. * @param[in] index pwm cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  698. */
  699. static inline void pwm_enable_pwm_sw_force_output(PWM_Type *pwm_x, uint8_t index)
  700. {
  701. pwm_x->PWMCFG[index] |= PWM_PWMCFG_OEN_MASK | PWM_PWMCFG_FRCSRCSEL_MASK
  702. | PWM_PWMCFG_FRCSHDWUPT_SET(pwm_shadow_register_update_on_modify);
  703. }
  704. /**
  705. * @brief disable pwm sw force output
  706. *
  707. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  708. * @param[in] index pwm cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  709. */
  710. static inline void pwm_disable_pwm_sw_force_output(PWM_Type *pwm_x, uint8_t index)
  711. {
  712. pwm_x->PWMCFG[index] &= ~PWM_PWMCFG_FRCSRCSEL_MASK;
  713. }
  714. /**
  715. * @brief config PWM channel configure registe
  716. *
  717. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  718. * @param[in] index pwm channel index (0..(PWM_SOC_PWM_MAX_COUNT-1))
  719. * @param[in] config @ref pwm_config_t
  720. * @param[in] enable_pair_mode enable pair mode
  721. * @arg 1- PWM output is in pair mode
  722. * @arg 0- PWM output is in indepandent mode
  723. */
  724. static inline void pwm_config_pwm(PWM_Type *pwm_x, uint8_t index,
  725. pwm_config_t *config, bool enable_pair_mode)
  726. {
  727. pwm_x->PWMCFG[index] = PWM_PWMCFG_OEN_SET(config->enable_output)
  728. | PWM_PWMCFG_FRCSHDWUPT_SET(config->update_trigger)
  729. | PWM_PWMCFG_FAULTMODE_SET(config->fault_mode)
  730. | PWM_PWMCFG_FAULTRECTIME_SET(config->fault_recovery_trigger)
  731. | PWM_PWMCFG_FRCSRCSEL_SET(config->force_source)
  732. | PWM_PWMCFG_PAIR_SET(enable_pair_mode)
  733. | PWM_PWMCFG_DEADAREA_SET(config->dead_zone_in_half_cycle);
  734. }
  735. /**
  736. * @brief pwm load cmp shadow on match
  737. *
  738. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  739. * @param[in] index cmp index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  740. * @param[in] config @ref pwm_cmp_config_t
  741. * @retval status_invalid_argument or status_success
  742. */
  743. hpm_stat_t pwm_load_cmp_shadow_on_match(PWM_Type *pwm_x,
  744. uint8_t index,
  745. pwm_cmp_config_t *config);
  746. /**
  747. * @brief pwm get captured count
  748. *
  749. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  750. * @param[out] buf count value
  751. * @param[in] counter @ref pwm_counter_type_t
  752. * @param[in] start_index start capture index (0..(PWM_SOC_CMP_MAX_COUNT-1))
  753. * @param[in] num capture num (1..PWM_SOC_CMP_MAX_COUNT)
  754. */
  755. void pwm_get_captured_count(PWM_Type *pwm_x, uint32_t *buf, pwm_counter_type_t counter, uint8_t start_index, uint8_t num);
  756. /**
  757. * @brief get default cmp config
  758. *
  759. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  760. * @param[out] config @ref pwm_cmp_config_t
  761. */
  762. void pwm_get_default_cmp_config(PWM_Type *pwm_x, pwm_cmp_config_t *config);
  763. /**
  764. * @brief get default output channel config
  765. *
  766. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  767. * @param[out] config @ref pwm_output_channel_t
  768. */
  769. void pwm_get_default_output_channel_config(PWM_Type *pwm_x, pwm_output_channel_t *config);
  770. /**
  771. * @brief get default pwm config
  772. *
  773. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  774. * @param[out] config @ref pwm_config_t
  775. */
  776. void pwm_get_default_pwm_config(PWM_Type *pwm_x, pwm_config_t *config);
  777. /**
  778. * @brief get default pwm pair config
  779. *
  780. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  781. * @param[out] config @ref pwm_pair_config_t
  782. */
  783. void pwm_get_default_pwm_pair_config(PWM_Type *pwm_x, pwm_pair_config_t *config);
  784. /**
  785. * @brief setup waveform
  786. *
  787. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  788. * @param[in] pwm_index pwm channel index (0..(PWM_SOC_PWM_MAX_COUNT-1))
  789. * @param[in] pwm_config @ref pwm_config_t
  790. * @param[in] cmp_start_index pwm cmp index (0..(PWM_SOC_PWM_MAX_COUNT-1))
  791. * @param[in] cmp @ref pwm_cmp_config_t
  792. * @param[in] cmp_num cmp num (1..PWM_SOC_CMP_MAX_COUNT), cmp[cmp_num-1] must not overflow
  793. * @retval hpm_stat_t
  794. */
  795. hpm_stat_t pwm_setup_waveform(PWM_Type *pwm_x,
  796. uint8_t pwm_index, pwm_config_t *pwm_config,
  797. uint8_t cmp_start_index, pwm_cmp_config_t *cmp, uint8_t cmp_num);
  798. /**
  799. * @brief setup pwm waveform in pair
  800. *
  801. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  802. * @param[in] pwm_index pwm channel index (0..(PWM_SOC_PWM_MAX_COUNT-1))
  803. * @param[in] pwm_pair_config @ref pwm_pair_config_t
  804. * @param[in] cmp_start_index pwm cmp index (0..(PWM_SOC_PWM_MAX_COUNT-1))
  805. * @param[in] cmp @ref pwm_cmp_config_t
  806. * @param[in] cmp_num cmp num (1..PWM_SOC_CMP_MAX_COUNT), cmp[cmp_num-1] must not overflow
  807. * @retval hpm_stat_t @ref status_invalid_argument or @ref status_success
  808. */
  809. hpm_stat_t pwm_setup_waveform_in_pair(PWM_Type *pwm_x,
  810. uint8_t pwm_index, pwm_pair_config_t *pwm_pair_config,
  811. uint8_t cmp_start_index, pwm_cmp_config_t *cmp, uint8_t cmp_num);
  812. /**
  813. * @brief update raw compare value for edge aligned waveform
  814. *
  815. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  816. * @param[in] cmp_index index of cmp to be adjusted (0..(PWM_SOC_PWM_MAX_COUNT-1))
  817. * @param[in] target_cmp target compare value
  818. * @retval hpm_stat_t @ref status_invalid_argument or @ref status_success
  819. */
  820. hpm_stat_t pwm_update_raw_cmp_edge_aligned(PWM_Type *pwm_x, uint8_t cmp_index,
  821. uint32_t target_cmp);
  822. /**
  823. * @brief update raw compare value for central aligned waveform
  824. *
  825. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  826. * @param[in] cmp1_index index of cmp1 to be adjusted (cmp1_index must be even number)
  827. * @param[in] cmp2_index index of cmp2 to be adjusted (cmp2_index must be odd number)
  828. * @param[in] target_cmp1 target compare value for cmp1
  829. * @param[in] target_cmp2 target compare value for cmp2
  830. * @retval hpm_stat_t @ref status_invalid_argument or @ref status_success cmp1_index
  831. */
  832. hpm_stat_t pwm_update_raw_cmp_central_aligned(PWM_Type *pwm_x, uint8_t cmp1_index,
  833. uint8_t cmp2_index, uint32_t target_cmp1, uint32_t target_cmp2);
  834. #if PWM_SOC_HRPWM_SUPPORT
  835. /**
  836. * @brief Enable high-precision pwm
  837. *
  838. * @param[in] pwm_x @ref PWM_Type PWM base address
  839. */
  840. static inline void pwm_enable_hrpwm(PWM_Type *pwm_x)
  841. {
  842. pwm_x->GCR = (pwm_x->GCR & ~(PWM_GCR_HR_PWM_EN_MASK)) | PWM_GCR_HR_PWM_EN_SET(1);
  843. }
  844. /**
  845. * @brief Disable high-precision pwm
  846. *
  847. * @param[in] pwm_x @ref PWM_Type PWM base address
  848. */
  849. static inline void pwm_disable_hrpwm(PWM_Type *pwm_x)
  850. {
  851. pwm_x->GCR = pwm_x->GCR & ~(PWM_GCR_HR_PWM_EN_MASK);
  852. }
  853. /**
  854. * @brief Calibrate all channels of hrpwm
  855. *
  856. * @param[in] pwm_x @ref PWM_Type PWM base address
  857. */
  858. static inline void pwm_cal_hrpwm_start(PWM_Type *pwm_x)
  859. {
  860. pwm_x->HRPWM_CFG |= PWM_HRPWM_CFG_CAL_START_MASK;
  861. }
  862. /**
  863. * @brief Calibrate specified hrpwm channels
  864. *
  865. * @param[in] pwm_x @ref PWM_Type PWM base address
  866. * @param[in] chn Channel number
  867. */
  868. static inline void pwm_cal_hrpwm_chn_start(PWM_Type *pwm_x, uint8_t chn)
  869. {
  870. pwm_x->HRPWM_CFG |= PWM_HRPWM_CFG_CAL_START_SET(chn);
  871. }
  872. /**
  873. * @brief Wait for the completion of calibration of the specified channel of high-precision PWM, blocking
  874. *
  875. * @param[in] pwm_x @ref PWM_Type PWM base address
  876. * @param[in] chn Channel number
  877. */
  878. static inline void pwm_cal_hrpwm_chn_wait(PWM_Type *pwm_x, uint8_t chn)
  879. {
  880. while (PWM_ANASTS_CALON_GET(pwm_x->ANASTS[chn])) {
  881. };
  882. }
  883. /**
  884. * @brief get calibration status
  885. *
  886. * @param[in] pwm_x pwm_x @ref PWM_Type PWM base address
  887. * @param[in] chn Channel number
  888. * @return uint32_t finished will be set zero.
  889. */
  890. static inline uint32_t pwm_get_cal_hrpwm_status(PWM_Type *pwm_x, uint8_t chn)
  891. {
  892. return PWM_ANASTS_CALON_GET(pwm_x->ANASTS[chn]);
  893. }
  894. /**
  895. * @brief update raw high-precision compare value for edge aligned waveform
  896. *
  897. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  898. * @param[in] cmp_index index of cmp to be adjusted (0..(PWM_SOC_PWM_MAX_COUNT-1))
  899. * @param[in] target_cmp target compare value
  900. * @param[in] target_hrcmp target high-precision compare value
  901. * @return hpm_stat_t
  902. */
  903. hpm_stat_t pwm_update_raw_hrcmp_edge_aligned(PWM_Type *pwm_x, uint8_t cmp_index, uint32_t target_cmp,
  904. uint16_t target_hrcmp);
  905. /**
  906. * @brief update raw high-precision compare value for central aligned waveform
  907. *
  908. * @param[in] pwm_x PWM base address, HPM_PWMx(x=0..n)
  909. * @param[in] cmp1_index index of cmp1 to be adjusted (cmp1_index must be even number)
  910. * @param[in] cmp2_index index of cmp2 to be adjusted (cmp2_index must be odd number)
  911. * @param[in] target_cmp1 target compare value for cmp1
  912. * @param[in] target_cmp2 target compare value for cmp2
  913. * @param[in] target_hrcmp1 target high-precision compare value for cmp1
  914. * @param[in] target_hrcmp2 target high-precision compare value for cmp2
  915. * @return hpm_stat_t
  916. */
  917. hpm_stat_t pwm_update_raw_hrcmp_central_aligned(PWM_Type *pwm_x, uint8_t cmp1_index,
  918. uint8_t cmp2_index, uint32_t target_cmp1, uint32_t target_cmp2,
  919. uint16_t target_hrcmp1, uint16_t target_hrcmp2);
  920. #endif
  921. #ifdef __cplusplus
  922. }
  923. #endif
  924. /**
  925. * @}
  926. */
  927. #endif /* HPM_PWM_DRV_H */