AG903ライブラリリファレンス
内容インデックスホーム
Body Source
本文ソース
1: 10: 11: 15: 16: 17: #include "AG903_errno.h" 18: #include "AG903_common.h" 19: #include "wdt/wdtprm.h" 20: #include "register/AG903_wdtreg.h" 21: 22: #define AG903_WDT_READ_REG(REG) ((AG903_WDT)->REG) 23: #define AG903_WDT_WRITE_REG(REG,VAL) ((AG903_WDT)->REG = (uint32_t)(VAL)) 24: #define AG903_WDT_SET_REG(REG,VAL) ((AG903_WDT)->REG |= (uint32_t)(VAL)) 25: #define AG903_WDT_CLR_REG(REG,VAL) ((AG903_WDT)->REG &= (uint32_t)(~VAL)) 26: 27: #define AG903_WDT_PASSWORD (0x5AB9) 28: 29: 35: void AG903_WDTPrmGetCount(uint32_t* cnt) 36: { 37: ASSERT(NULL != cnt); 38: 39: (*cnt) = AG903_WDT_READ_REG(WdCounter); 40: } 41: 42: 48: void AG903_WDTPrmSetCount(uint32_t cnt) 49: { 50: AG903_WDT_WRITE_REG(WdLoad, cnt); 51: } 52: 53: 59: void AG903_WDTPrmGetLoad(uint32_t *load) 60: { 61: ASSERT(NULL != load); 62: 63: (*load) = AG903_WDT_READ_REG(WdLoad); 64: } 65: 66: 72: void AG903_WDTPrmRestartCount(void) 73: { 74: AG903_WDT_WRITE_REG(WdRestart, AG903_WDT_PASSWORD); 75: } 76: 77: 87: void AG903_WDTPrmSetControl(_Bool rst, _Bool intr, _Bool ext) 88: { 89: uint32_t set=0; 90: uint32_t clr=0; 91: 92: if(true == rst) { 93: set |= (1<<AG903_WDT_WdCR_WdRst_POS); 94: } 95: if(true == intr) { 96: set |= (1<<AG903_WDT_WdCR_WdIntr_POS); 97: } 98: if(true == ext) { 99: set |= (1<<AG903_WDT_WdCR_WdExt_POS); 100: } 101: clr = ~set & (AG903_WDT_WdCR_WdRst_MSK|AG903_WDT_WdCR_WdIntr_MSK|AG903_WDT_WdCR_WdExt_POS); 102: clr |= (1<<AG903_WDT_WdCR_WdClock_POS); 103: 104: AG903_WDT_CLR_REG(WdCR, clr); 105: AG903_WDT_SET_REG(WdCR, set); 106: } 107: 108: 117: void AG903_WDTPrmGetControl(_Bool *rst, _Bool *intr, _Bool *ext) 118: { 119: uint32_t cr=0; 120: ASSERT(NULL != rst); 121: ASSERT(NULL != intr); 122: ASSERT(NULL != ext); 123: 124: cr = AG903_WDT_READ_REG(WdCR); 125: if (cr & (1<<AG903_WDT_WdCR_WdRst_POS)) { 126: (*rst) = true; 127: } else { 128: (*rst) = false; 129: } 130: if (cr & (1<<AG903_WDT_WdCR_WdIntr_POS)) { 131: (*intr) = true; 132: } else { 133: (*intr) = false; 134: } 135: if (cr & (1<<AG903_WDT_WdCR_WdExt_POS)) { 136: (*ext) = true; 137: } else { 138: (*ext) = false; 139: } 140: } 141: 142: 149: void AG903_WDTPrmEnableCount(void) 150: { 151: AG903_WDT_SET_REG(WdCR, (1<<AG903_WDT_WdCR_WdEnable_POS)); 152: } 153: 154: 161: void AG903_WDTPrmDisableCount(void) 162: { 163: AG903_WDT_CLR_REG(WdCR, (1<<AG903_WDT_WdCR_WdEnable_POS)); 164: } 165: 166: 172: void AG903_WDTPrmGetStatus(uint32_t* status) 173: { 174: ASSERT(NULL != status); 175: 176: (*status) = AG903_WDT_READ_REG(WdStatus); 177: } 178: 179: 186: void AG903_WDTPrmClearStatus(void) 187: { 188: AG903_WDT_SET_REG(WdClear, (1<<AG903_WDT_WdClear_WdClear_POS)); 189: } 190: 191: 197: void AG903_WDTPrmSetIntrlen(uint8_t intrlen) 198: { 199: AG903_WDT_WRITE_REG(WdIntrlen, intrlen); 200: } 201: 202: 208: void AG903_WDTPrmGetIntrlen(uint8_t *intrlen) 209: { 210: ASSERT(NULL != intrlen); 211: (*intrlen) = AG903_WDT_READ_REG(WdIntrlen); 212: } 213: 214: 220: void AG903_WDTPrmGetRevision(uint8_t *revision) 221: { 222: ASSERT(NULL != revision); 223: (*revision) = AG903_WDT_READ_REG(WdRevision); 224: }
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.