Skip to content

Commit

Permalink
hpmicro: gptmr: update gptmr driver to enable cmp and reload setting …
Browse files Browse the repository at this point in the history
…to 0xFFFFFFFF

Signed-off-by: Zhihong Chen <[email protected]>
  • Loading branch information
chenzhihong007 committed Oct 31, 2024
1 parent c135c68 commit 3c246ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions arch/risc-v/src/hpmicro/hpm_sdk/drivers/inc/hpm_gptmr_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static inline void gptmr_channel_update_count(GPTMR_Type *ptr,
uint8_t ch_index,
uint32_t value)
{
if (value > 0) {
if ((value > 0) && (value != 0xFFFFFFFFu)) {
value--;
}
ptr->CHANNEL[ch_index].CNTUPTVAL = GPTMR_CHANNEL_CNTUPTVAL_CNTUPTVAL_SET(value);
Expand Down Expand Up @@ -358,7 +358,7 @@ static inline gptmr_work_mode_t gptmr_channel_get_capmode(GPTMR_Type *ptr, uint8
*/
static inline void gptmr_update_cmp(GPTMR_Type *ptr, uint8_t ch_index, uint8_t cmp_index, uint32_t cmp)
{
if (cmp > 0) {
if ((cmp > 0) && (cmp != 0xFFFFFFFFu)) {
cmp--;
}
ptr->CHANNEL[ch_index].CMP[cmp_index] = GPTMR_CHANNEL_CMP_CMP_SET(cmp);
Expand All @@ -385,7 +385,7 @@ static inline uint32_t gptmr_channel_get_reload(GPTMR_Type *ptr, uint8_t ch_inde
*/
static inline void gptmr_channel_config_update_reload(GPTMR_Type *ptr, uint8_t ch_index, uint32_t reload)
{
if (reload > 0) {
if ((reload > 0)&& (reload != 0xFFFFFFFFu)) {
reload--;
}
ptr->CHANNEL[ch_index].RLD = GPTMR_CHANNEL_RLD_RLD_SET(reload);
Expand Down
6 changes: 3 additions & 3 deletions arch/risc-v/src/hpmicro/hpm_sdk/drivers/src/hpm_gptmr_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void gptmr_channel_get_default_config(GPTMR_Type *ptr, gptmr_channel_config_t *c
config->dma_request_event = gptmr_dma_request_disabled;
config->synci_edge = gptmr_synci_edge_none;
for (uint8_t i = 0; i < GPTMR_CH_CMP_COUNT; i++) {
config->cmp[i] = 0xFFFFFFFFUL;
config->cmp[i] = 0xFFFFFFFEUL;
}
config->reload = 0xFFFFFFFFUL;
config->cmp_initial_polarity_high = true;
Expand Down Expand Up @@ -51,13 +51,13 @@ hpm_stat_t gptmr_channel_config(GPTMR_Type *ptr,

for (uint8_t i = GPTMR_CH_CMP_COUNT; i > 0; i--) {
tmp_value = config->cmp[i - 1];
if (tmp_value > 0) {
if ((tmp_value > 0) && (tmp_value != 0xFFFFFFFFu)) {
tmp_value--;
}
ptr->CHANNEL[ch_index].CMP[i - 1] = GPTMR_CHANNEL_CMP_CMP_SET(tmp_value);
}
tmp_value = config->reload;
if (tmp_value > 0) {
if ((tmp_value > 0) && (tmp_value != 0xFFFFFFFFu)) {
tmp_value--;
}
ptr->CHANNEL[ch_index].RLD = GPTMR_CHANNEL_RLD_RLD_SET(tmp_value);
Expand Down

0 comments on commit 3c246ca

Please sign in to comment.