WDT: Change "variable style" by "pointer style" (#520)

This commit is contained in:
Stephan 2023-02-27 18:53:11 +01:00 committed by GitHub
commit 32ee32aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View file

@ -947,7 +947,7 @@ int main() {
asm volatile ("wfi");
neorv32_cpu_csr_write(CSR_MIE, 0);
NEORV32_WDT.CTRL = 0;
NEORV32_WDT->CTRL = 0;
if (neorv32_cpu_csr_read(CSR_MCAUSE) == WDT_TRAP_CODE) {
test_ok();

View file

@ -1197,7 +1197,7 @@ enum NEORV32_TRNG_CTRL_enum {
**************************************************************************/
/**@{*/
/** WDT module prototype */
typedef struct __attribute__((packed,aligned(4))) {
typedef volatile struct __attribute__((packed,aligned(4))) {
uint32_t CTRL; /**< offset 0: control register (#NEORV32_WDT_CTRL_enum) */
} neorv32_wdt_t;
@ -1205,7 +1205,7 @@ typedef struct __attribute__((packed,aligned(4))) {
#define NEORV32_WDT_BASE (0xFFFFFFBCU)
/** WDT module hardware access (#neorv32_wdt_t) */
#define NEORV32_WDT (*((volatile neorv32_wdt_t*) (NEORV32_WDT_BASE)))
#define NEORV32_WDT ((neorv32_wdt_t*) (NEORV32_WDT_BASE))
/** WDT control register bits */
enum NEORV32_WDT_CTRL_enum {

View file

@ -73,7 +73,7 @@ int neorv32_wdt_available(void) {
**************************************************************************/
void neorv32_wdt_setup(uint32_t timeout, int lock, int debug_en, int sleep_en) {
NEORV32_WDT.CTRL = 0; // reset and disable
NEORV32_WDT->CTRL = 0; // reset and disable
uint32_t enable_int = ((uint32_t)(1)) << WDT_CTRL_EN;
uint32_t timeout_int = ((uint32_t)(timeout & 0xffffffU)) << WDT_CTRL_TIMEOUT_LSB;
@ -81,11 +81,11 @@ void neorv32_wdt_setup(uint32_t timeout, int lock, int debug_en, int sleep_en) {
uint32_t sleep_en_int = ((uint32_t)(sleep_en & 0x1U)) << WDT_CTRL_SEN;
// update WDT control register
NEORV32_WDT.CTRL = enable_int | timeout_int | debug_en_int | sleep_en_int;
NEORV32_WDT->CTRL = enable_int | timeout_int | debug_en_int | sleep_en_int;
// lock configuration?
if (lock) {
NEORV32_WDT.CTRL |= 1 << WDT_CTRL_LOCK;
NEORV32_WDT->CTRL |= 1 << WDT_CTRL_LOCK;
}
}
@ -99,10 +99,10 @@ int neorv32_wdt_disable(void) {
const uint32_t en_mask_c = (uint32_t)(1 << WDT_CTRL_EN);
NEORV32_WDT.CTRL &= en_mask_c; // try to disable
NEORV32_WDT->CTRL &= en_mask_c; // try to disable
// check if WDT is really off
if (NEORV32_WDT.CTRL & en_mask_c) {
if (NEORV32_WDT->CTRL & en_mask_c) {
return -1; // still active
}
else {
@ -116,7 +116,7 @@ int neorv32_wdt_disable(void) {
**************************************************************************/
void neorv32_wdt_feed(void) {
NEORV32_WDT.CTRL |= (uint32_t)(1 << WDT_CTRL_RESET);
NEORV32_WDT->CTRL |= (uint32_t)(1 << WDT_CTRL_RESET);
}
@ -127,7 +127,7 @@ void neorv32_wdt_feed(void) {
**************************************************************************/
int neorv32_wdt_get_cause(void) {
if (NEORV32_WDT.CTRL & (1 << WDT_CTRL_RCAUSE)) { // reset caused by watchdog
if (NEORV32_WDT->CTRL & (1 << WDT_CTRL_RCAUSE)) { // reset caused by watchdog
return 1;
}
else { // reset caused by system (external or OCD)