mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
dport access: Add _DPORT_REG_SET_BIT & _DPORT_REG_CLR_BIT
This commit is contained in:
parent
dc8c33892e
commit
cb31222e8b
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include <sdkconfig.h>
|
||||||
|
|
||||||
#ifndef _ESP_DPORT_ACCESS_H_
|
#ifndef _ESP_DPORT_ACCESS_H_
|
||||||
#define _ESP_DPORT_ACCESS_H_
|
#define _ESP_DPORT_ACCESS_H_
|
||||||
|
|
||||||
|
@ -25,14 +25,21 @@ extern "C" {
|
|||||||
|
|
||||||
//Registers Operation {{
|
//Registers Operation {{
|
||||||
|
|
||||||
//Register read macros with an underscore prefix access DPORT memory directly. In IDF apps, use the non-underscore versions to be SMP-safe.
|
// The _DPORT_xxx register read macros access DPORT memory directly (as opposed to
|
||||||
|
// DPORT_REG_READ which applies SMP-safe protections).
|
||||||
|
//
|
||||||
|
// Use DPORT_REG_READ versions to be SMP-safe in IDF apps. If you want to
|
||||||
|
// make a sequence of DPORT reads, use DPORT_STALL_OTHER_CPU_START() macro
|
||||||
|
// explicitly and then use _DPORT_REG_READ macro while other CPU is stalled.
|
||||||
|
//
|
||||||
|
// _DPORT_REG_WRITE & DPORT_REG_WRITE are equivalent.
|
||||||
#define _DPORT_REG_READ(_r) (*(volatile uint32_t *)(_r))
|
#define _DPORT_REG_READ(_r) (*(volatile uint32_t *)(_r))
|
||||||
#define _DPORT_REG_WRITE(_r, _v) (*(volatile uint32_t *)(_r)) = (_v)
|
#define _DPORT_REG_WRITE(_r, _v) (*(volatile uint32_t *)(_r)) = (_v)
|
||||||
|
|
||||||
//write value to register
|
// Write value to DPORT register (does not require protecting)
|
||||||
#define DPORT_REG_WRITE(_r, _v) _DPORT_REG_WRITE((_r), (_v))
|
#define DPORT_REG_WRITE(_r, _v) _DPORT_REG_WRITE((_r), (_v))
|
||||||
|
|
||||||
//read value from register
|
// Read value from register, SMP-safe version.
|
||||||
static inline uint32_t IRAM_ATTR DPORT_REG_READ(uint32_t reg)
|
static inline uint32_t IRAM_ATTR DPORT_REG_READ(uint32_t reg)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
@ -83,6 +90,8 @@ static inline uint32_t IRAM_ATTR DPORT_REG_READ(uint32_t reg)
|
|||||||
//Register read macros with an underscore prefix access DPORT memory directly. In IDF apps, use the non-underscore versions to be SMP-safe.
|
//Register read macros with an underscore prefix access DPORT memory directly. In IDF apps, use the non-underscore versions to be SMP-safe.
|
||||||
#define _DPORT_READ_PERI_REG(addr) (*((volatile uint32_t *)(addr)))
|
#define _DPORT_READ_PERI_REG(addr) (*((volatile uint32_t *)(addr)))
|
||||||
#define _DPORT_WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)(addr))) = (uint32_t)(val)
|
#define _DPORT_WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)(addr))) = (uint32_t)(val)
|
||||||
|
#define _DPORT_REG_SET_BIT(_r, _b) _DPORT_REG_WRITE((_r), (_DPORT_REG_READ(_r)|(_b)))
|
||||||
|
#define _DPORT_REG_CLR_BIT(_r, _b) _DPORT_REG_WRITE((_r), (_DPORT_REG_READ(_r) & (~(_b))))
|
||||||
|
|
||||||
//read value from register
|
//read value from register
|
||||||
static inline uint32_t IRAM_ATTR DPORT_READ_PERI_REG(uint32_t addr)
|
static inline uint32_t IRAM_ATTR DPORT_READ_PERI_REG(uint32_t addr)
|
||||||
|
Loading…
Reference in New Issue
Block a user