mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Back out use on inline functions to access 16-bit registers. The inline functions were a work-around for misbehaving compiler years and years ago. The mon standard macro-ized version should work just fine.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/common/up_arch.h
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,10 +45,6 @@
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
@@ -57,27 +53,11 @@
|
||||
|
||||
# define getreg8(a) (*(volatile uint8_t *)(a))
|
||||
# define putreg8(v,a) (*(volatile uint8_t *)(a) = (v))
|
||||
# define getreg16(a) (*(volatile uint16_t *)(a))
|
||||
# define putreg16(v,a) (*(volatile uint16_t *)(a) = (v))
|
||||
# define getreg32(a) (*(volatile uint32_t *)(a))
|
||||
# define putreg32(v,a) (*(volatile uint32_t *)(a) = (v))
|
||||
|
||||
/* Some compiler options will convert short loads and stores into byte loads
|
||||
* and stores. We don't want this to happen for IO reads and writes!
|
||||
*/
|
||||
|
||||
/* # define getreg16(a) (*(volatile uint16_t *)(a)) */
|
||||
static inline uint16_t getreg16(unsigned int addr)
|
||||
{
|
||||
uint16_t retval;
|
||||
__asm__ __volatile__("\tldrh %0, [%1]\n\t" : "=r"(retval) : "r"(addr));
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* define putreg16(v,a) (*(volatile uint16_t *)(a) = (v)) */
|
||||
static inline void putreg16(uint16_t val, unsigned int addr)
|
||||
{
|
||||
__asm__ __volatile__("\tstrh %0, [%1]\n\t": : "r"(val), "r"(addr));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user