1 /** 2 * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #pragma once 7 8 #include <stdint.h> 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /** Group: configuration registers */ 14 /** Type of addr_lock register 15 * hardware lock regsiter 16 */ 17 typedef union { 18 struct { 19 /** lock : R/W; bitpos: [1:0]; default: 0; 20 * read to acquire hardware lock, write to release hardware lock 21 */ 22 uint32_t lock:2; 23 uint32_t reserved_2:30; 24 }; 25 uint32_t val; 26 } atomic_addr_lock_reg_t; 27 28 /** Type of lr_addr register 29 * gloable lr address regsiter 30 */ 31 typedef union { 32 struct { 33 /** gloable_lr_addr : R/W; bitpos: [31:0]; default: 0; 34 * backup gloable address 35 */ 36 uint32_t gloable_lr_addr:32; 37 }; 38 uint32_t val; 39 } atomic_lr_addr_reg_t; 40 41 /** Type of lr_value register 42 * gloable lr value regsiter 43 */ 44 typedef union { 45 struct { 46 /** gloable_lr_value : R/W; bitpos: [31:0]; default: 0; 47 * backup gloable value 48 */ 49 uint32_t gloable_lr_value:32; 50 }; 51 uint32_t val; 52 } atomic_lr_value_reg_t; 53 54 /** Type of lock_status register 55 * lock status regsiter 56 */ 57 typedef union { 58 struct { 59 /** lock_status : RO; bitpos: [1:0]; default: 0; 60 * read hareware lock status for debug 61 */ 62 uint32_t lock_status:2; 63 uint32_t reserved_2:30; 64 }; 65 uint32_t val; 66 } atomic_lock_status_reg_t; 67 68 /** Type of counter register 69 * wait counter register 70 */ 71 typedef union { 72 struct { 73 /** wait_counter : R/W; bitpos: [15:0]; default: 0; 74 * delay counter 75 */ 76 uint32_t wait_counter:16; 77 uint32_t reserved_16:16; 78 }; 79 uint32_t val; 80 } atomic_counter_reg_t; 81 82 83 typedef struct atomic_dev_t { 84 volatile atomic_addr_lock_reg_t addr_lock; 85 volatile atomic_lr_addr_reg_t lr_addr; 86 volatile atomic_lr_value_reg_t lr_value; 87 volatile atomic_lock_status_reg_t lock_status; 88 volatile atomic_counter_reg_t counter; 89 } atomic_dev_t; 90 91 extern atomic_dev_t ATOMIC_LOCKER; 92 93 #ifndef __cplusplus 94 _Static_assert(sizeof(atomic_dev_t) == 0x14, "Invalid size of atomic_dev_t structure"); 95 #endif 96 97 #ifdef __cplusplus 98 } 99 #endif 100