Skip to content

Commit

Permalink
Moved clock source number check into RevB function
Browse files Browse the repository at this point in the history
Moved clock source check to RevB function and removed 'last_clock_source' parameter.

Signed-off-by: Furkan Akkiz <[email protected]>
  • Loading branch information
hfakkiz committed Dec 4, 2023
1 parent d449d3b commit 683953c
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 38 deletions.
6 changes: 0 additions & 6 deletions Libraries/PeriphDrivers/Source/WDT/wdt_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
const uint8_t last_clock_source = MXC_WDT_ERFO_CLK;

if ((clock_source < 0) || (clock_source > last_clock_source)) {
return E_BAD_PARAM;
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, (int)clock_source);

return E_NO_ERROR;
Expand Down
6 changes: 0 additions & 6 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me12.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
const uint8_t last_clock_source = MXC_WDT_ERFO_CLK;

if ((clock_source < 0) || (clock_source > last_clock_source)) {
return E_BAD_PARAM;
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, (int)clock_source);

return E_NO_ERROR;
Expand Down
12 changes: 0 additions & 12 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me15.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,6 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
#if TARGET_NUM == 32670
const uint8_t last_clock_source = MXC_WDT_ERFO_CLK;
#elif TARGET_NUM == 32675
const uint8_t last_clock_source = MXC_WDT_INRO_CLK;
#else
#error ME15 WDT driver does not support given target number.
#endif

if ((clock_source < 0) || (clock_source > last_clock_source)) {
return E_BAD_PARAM;
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, (int)clock_source);

return E_NO_ERROR;
Expand Down
4 changes: 0 additions & 4 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
}
}

if (idx == clock_source_num) {
return E_BAD_PARAM;
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, idx);

return E_NO_ERROR;
Expand Down
4 changes: 0 additions & 4 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
}
}

if (idx == clock_source_num) {
return E_BAD_PARAM;
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, idx);

return E_NO_ERROR;
Expand Down
6 changes: 0 additions & 6 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me21.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
const uint8_t last_clock_source = MXC_WDT_ERFO_CLK;

if ((clock_source < 0) || (clock_source > last_clock_source)) {
return E_BAD_PARAM;
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, (int)clock_source);

return E_NO_ERROR;
Expand Down
3 changes: 3 additions & 0 deletions Libraries/PeriphDrivers/Source/WDT/wdt_revb.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ void MXC_WDT_RevB_ClearIntFlag(mxc_wdt_revb_regs_t *wdt)

void MXC_WDT_RevB_SetClockSource(mxc_wdt_revb_regs_t *wdt, int clock_source)
{
const uint8_t clock_source_num = 8; // Max number of clock sources for Rev B WDT

MXC_ASSERT(clock_source < clock_source_num && clock_source >= 0);
MXC_SETFIELD(wdt->clksel, MXC_F_WDT_REVB_CLKSEL_SOURCE,
(clock_source << MXC_F_WDT_REVB_CLKSEL_SOURCE_POS));
}

0 comments on commit 683953c

Please sign in to comment.