Skip to content

Commit

Permalink
feat(PeriphDrivers): Add clock selection feature to WDT (#808)
Browse files Browse the repository at this point in the history
Signed-off-by: Furkan Akkiz <[email protected]>
  • Loading branch information
hfakkiz authored Dec 6, 2023
1 parent 7fe9ab5 commit 6035f1a
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32655/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IBRO_CLK,
MXC_WDT_INRO_CLK,
MXC_WDT_ERTCO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +244,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
20 changes: 20 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32662/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IPO_CLK,
MXC_WDT_IBRO_CLK,
MXC_WDT_NANO_CLK,
MXC_WDT_ERTCO_CLK,
MXC_WDT_EXT_CLK,
MXC_WDT_ERFO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +247,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
20 changes: 20 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32670/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IPO_CLK,
MXC_WDT_IBRO_CLK,
MXC_WDT_INRO_CLK,
MXC_WDT_ERTCO_CLK,
MXC_WDT_EXT_CLK,
MXC_WDT_ERFO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +247,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
20 changes: 20 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32672/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IPO_CLK,
MXC_WDT_IBRO_CLK,
MXC_WDT_INRO_CLK,
MXC_WDT_ERTCO_CLK,
MXC_WDT_EXT_CLK,
MXC_WDT_ERFO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +247,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
17 changes: 17 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32675/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IPO_CLK,
MXC_WDT_IBRO_CLK,
MXC_WDT_INRO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -238,6 +248,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
12 changes: 12 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32680/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum { MXC_WDT_PCLK = 0, MXC_WDT_IBRO_CLK, MXC_WDT_INRO_CLK } mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +239,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
17 changes: 17 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32690/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IBRO_CLK,
MXC_WDT_INRO_CLK,
MXC_WDT_ERTCO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +244,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
17 changes: 17 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX78000/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IBRO_CLK,
MXC_WDT_INRO_CLK,
MXC_WDT_ERTCO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +244,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
20 changes: 20 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX78002/wdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ typedef enum {
MXC_WDT_WINDOWED = 1,
} mxc_wdt_mode_t;

/**
* @brief Peripheral Clock settings
*/
typedef enum {
MXC_WDT_PCLK = 0,
MXC_WDT_IPO_CLK,
MXC_WDT_IBRO_CLK,
MXC_WDT_INRO_CLK,
MXC_WDT_ERTCO_CLK,
MXC_WDT_EXT_CLK,
MXC_WDT_ERFO_CLK
} mxc_wdt_clock_t;

/**
* @brief Timer Configuration
*/
Expand Down Expand Up @@ -234,6 +247,13 @@ int MXC_WDT_GetIntFlag(mxc_wdt_regs_t *wdt);
*/
void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt);

/**
* @brief Sets clock source.
* @param wdt Pointer to watchdog registers.
* @param clock_source Clock source.
*/
int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source);

/**@} end of group wdt */

#ifdef __cplusplus
Expand Down
7 changes: 7 additions & 0 deletions Libraries/PeriphDrivers/Source/WDT/wdt_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,10 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)
{
MXC_WDT_RevB_ClearIntFlag((mxc_wdt_revb_regs_t *)wdt);
}

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, (int)clock_source);

return E_NO_ERROR;
}
7 changes: 7 additions & 0 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me12.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,10 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)
{
MXC_WDT_RevB_ClearIntFlag((mxc_wdt_revb_regs_t *)wdt);
}

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, (int)clock_source);

return E_NO_ERROR;
}
7 changes: 7 additions & 0 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me15.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,10 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)
{
MXC_WDT_RevB_ClearIntFlag((mxc_wdt_revb_regs_t *)wdt);
}

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, (int)clock_source);

return E_NO_ERROR;
}
39 changes: 39 additions & 0 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,42 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)
{
MXC_WDT_RevB_ClearIntFlag((mxc_wdt_revb_regs_t *)wdt);
}

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
const uint8_t clock_source_num = 8;
uint8_t idx = 0;
uint8_t instance = 0;

#if TARGET_NUM == 32655 || TARGET_NUM == 78000
mxc_wdt_clock_t clock_sources[2][8] = {
{ MXC_WDT_PCLK, MXC_WDT_IBRO_CLK, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ MXC_WDT_IBRO_CLK, MXC_WDT_ERTCO_CLK, MXC_WDT_INRO_CLK, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
};
#elif TARGET_NUM == 32680
mxc_wdt_clock_t clock_sources[2][8] = {
{ MXC_WDT_PCLK, MXC_WDT_IBRO_CLK, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ MXC_WDT_IBRO_CLK, 0xFF, MXC_WDT_INRO_CLK, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
};
#else
#error ME17 WDT driver does not support given target number.
#endif

if (wdt == MXC_WDT0) {
instance = 0;
} else if (wdt == MXC_WDT1) {
instance = 1;
} else {
return E_BAD_PARAM;
}

for (idx = 0; idx < clock_source_num; idx++) {
if (clock_sources[instance][idx] == clock_source) {
break;
}
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, idx);

return E_NO_ERROR;
}
29 changes: 29 additions & 0 deletions Libraries/PeriphDrivers/Source/WDT/wdt_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,32 @@ void MXC_WDT_ClearIntFlag(mxc_wdt_regs_t *wdt)
{
MXC_WDT_RevB_ClearIntFlag((mxc_wdt_revb_regs_t *)wdt);
}

int MXC_WDT_SetClockSource(mxc_wdt_regs_t *wdt, mxc_wdt_clock_t clock_source)
{
const uint8_t clock_source_num = 8;
uint8_t idx = 0;
uint8_t instance = 0;
mxc_wdt_clock_t clock_sources[2][8] = {
{ MXC_WDT_PCLK, MXC_WDT_IBRO_CLK, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ MXC_WDT_IBRO_CLK, MXC_WDT_INRO_CLK, MXC_WDT_ERTCO_CLK, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
};

if (wdt == MXC_WDT0) {
instance = 0;
} else if (wdt == MXC_WDT1) {
instance = 1;
} else {
return E_BAD_PARAM;
}

for (idx = 0; idx < clock_source_num; idx++) {
if (clock_sources[instance][idx] == clock_source) {
break;
}
}

MXC_WDT_RevB_SetClockSource((mxc_wdt_revb_regs_t *)wdt, idx);

return E_NO_ERROR;
}
Loading

0 comments on commit 6035f1a

Please sign in to comment.