Skip to content

Commit 2eaa32f

Browse files
authored
Merge pull request #5627 from li-ho/ev_cog_armc6
ADI: Add ARMC6 compatible code
2 parents 6811c9f + 165b2c6 commit 2eaa32f

File tree

31 files changed

+132
-119
lines changed

31 files changed

+132
-119
lines changed

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/TARGET_EV_COG_AD3029LZ/device/startup_ADuCM3029.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4545
*
4646
*****************************************************************************/
4747
#include <stdint.h>
48-
#ifdef __CC_ARM
48+
#ifdef __ARMCC_VERSION
4949
#include <rt_misc.h>
5050
#endif
5151
#include <cmsis.h>
@@ -61,8 +61,8 @@ extern void SramInit(void);
6161
/*----------------------------------------------------------------------------
6262
Checksum options
6363
*----------------------------------------------------------------------------*/
64-
#if defined (__CC_ARM)
65-
__attribute__ ((at(0x000001A0u)))
64+
#if defined (__ARMCC_VERSION)
65+
__attribute__((section(".ARM.__at_0x000001A0")))
6666
#elif defined( __ICCARM__)
6767
__root
6868
#endif /* __ICCARM__ */
@@ -151,7 +151,7 @@ const pFunc SECTION_PLACE(IVT_NAME[104],VECTOR_SECTION) =
151151
/*----------------------------------------------------------------------------
152152
* Initialize .bss and .data for GNU
153153
*----------------------------------------------------------------------------*/
154-
#if defined( __GNUC__) && !defined (__CC_ARM)
154+
#if defined( __GNUC__) && !defined (__ARMCC_VERSION)
155155
void zero_bss(void)
156156
{
157157
uint32_t *pSrc, *pDest;
@@ -248,7 +248,7 @@ void Reset_Handler(void)
248248
may reside in DSRAM bank B. */
249249
SramInit();
250250

251-
#if defined(__GNUC__) && !defined (__CC_ARM)
251+
#if defined(__GNUC__) && !defined (__ARMCC_VERSION)
252252
/* Clear the bss section for GCC build only */
253253
zero_bss();
254254
#endif
@@ -263,7 +263,7 @@ void Reset_Handler(void)
263263
/*----------------------------------------------------------------------------
264264
Default Handler for Exceptions / Interrupts
265265
*----------------------------------------------------------------------------*/
266-
#if defined(__CC_ARM) || defined (__GNUC__)
266+
#if defined(__ARMCC_VERSION) || defined (__GNUC__)
267267
void Default_Handler(void)
268268
{
269269
while(1);

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/TARGET_EV_COG_AD3029LZ/device/startup_ADuCM3029.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,14 @@ RESET_EXCPT_HNDLR
6363

6464
#define VECTOR_SECTION ".vectors"
6565

66-
#ifdef __CC_ARM
67-
extern unsigned Image$$ADUCM_HEAP$$Base[];
68-
extern unsigned Image$$ADUCM_HEAP$$ZI$$Limit[];
66+
#ifdef __ARMCC_VERSION
6967
void Default_Handler(void);
70-
#define SECTION_NAME(sectionname) __attribute__ ((section(sectionname)))
71-
#define SECTION_PLACE(def,sectionname) def __attribute__ ((section(sectionname)))
68+
#define SECTION_NAME(sectionname) __attribute__((section(sectionname)))
69+
#define SECTION_PLACE(def,sectionname) def __attribute__((section(sectionname)))
7270
#define IVT_NAME __Vectors
7371
#define RESET_EXCPT_HNDLR __main
7472
#define COMPILER_NAME "ARMCC"
75-
#define WEAK_FUNCTION(x) void x (void) __attribute__ ((weak, alias("Default_Handler")));
73+
#define WEAK_FUNCTION(x) void x (void) __attribute__((weak, alias("Default_Handler")));
7674

7775
#elif defined(__ICCARM__)
7876
#pragma diag_suppress=Pm093,Pm140

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/gpio_api.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@
4646

4747
#define MUX_FUNC_0 0x0
4848
#define NUM_GPIO_PORTS 4
49-
50-
extern uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
51-
extern uint8_t gpio_initialized;
49+
/*******************************************************************************
50+
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
51+
guarantee 4 byte alignmnet.
52+
*******************************************************************************/
53+
extern uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
54+
extern uint8_t gpio_initialized;
5255

5356
static uint16_t gpio_oen[NUM_GPIO_PORTS] = {0};
5457
static uint16_t gpio_output_val[NUM_GPIO_PORTS] = {0};

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/gpio_dev_mem.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@
3939
******************************************************************************/
4040

4141
#include <drivers/gpio/adi_gpio.h>
42-
42+
/*******************************************************************************
43+
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
44+
guarantee 4 byte alignmnet.
45+
*******************************************************************************/
4346
// ADI GPIO device driver state memory. Only one state memory is required globally.
44-
uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
47+
uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
4548

4649
// Flag to indicate whether the GPIO driver has been initialized
47-
uint8_t gpio_initialized = 0;
50+
uint8_t gpio_initialized = 0;

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/gpio_irq_api.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ typedef struct {
5353
gpio_irq_event event;
5454
uint8_t int_enable;
5555
} gpio_chan_info_t;
56-
57-
extern uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
58-
extern uint8_t gpio_initialized;
56+
/*******************************************************************************
57+
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
58+
guarantee 4 byte alignmnet.
59+
*******************************************************************************/
60+
extern uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
61+
extern uint8_t gpio_initialized;
5962
static gpio_chan_info_t channel_ids[MAX_GPIO_PORTS][MAX_GPIO_LINES];
6063
static gpio_irq_handler irq_handler = NULL;
6164

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/i2c_api.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@
5757
int adi_i2c_memtype = 0;
5858
#endif
5959
#else
60-
static uint8_t i2c_Mem[ADI_I2C_MEMORY_SIZE];
60+
/*******************************************************************************
61+
ADI_I2C_DEV_DATA_TYPE Instance memory containing memory pointer should
62+
guarantee 4 byte alignmnet.
63+
*******************************************************************************/
64+
static uint32_t i2c_Mem[(ADI_I2C_MEMORY_SIZE + 3)/4];
6165
static ADI_I2C_HANDLE i2c_Handle;
6266
#if defined(ADI_DEBUG)
6367
#warning "BUILD_I2C_MI_DYNAMIC is NOT defined. Memory allocation for I2C will be static"
@@ -72,7 +76,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
7276
uint32_t i2c_sda = pinmap_peripheral(sda, PinMap_I2C_SDA);
7377
uint32_t i2c_scl = pinmap_peripheral(scl, PinMap_I2C_SCL);
7478
ADI_I2C_HANDLE *pI2C_Handle;
75-
uint8_t *I2C_Mem;
79+
uint32_t *I2C_Mem;
7680
ADI_I2C_RESULT I2C_Return = ADI_I2C_SUCCESS;
7781
uint32_t I2C_DevNum = I2C_0; /* ADuCM3029 only has 1 I2C port */
7882

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/objects.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ struct i2c_s {
7979
ADI_I2C_HANDLE *pI2C_Handle;
8080
#if defined(BUILD_I2C_MI_DYNAMIC)
8181
ADI_I2C_HANDLE I2C_Handle;
82-
uint8_t I2C_Mem[ADI_I2C_MEMORY_SIZE];
82+
/*******************************************************************************
83+
ADI_I2C_DEV_DATA_TYPE Instance memory containing memory pointer should
84+
guarantee 4 byte alignmnet.
85+
*******************************************************************************/
86+
uint32_t I2C_Mem[(ADI_I2C_MEMORY_SIZE + 3)/4];
8387
#endif
8488
};
8589

@@ -90,7 +94,11 @@ struct spi_s {
9094
ADI_SPI_HANDLE *pSPI_Handle;
9195
#if defined(BUILD_SPI_MI_DYNAMIC)
9296
ADI_SPI_HANDLE SPI_Handle;
93-
uint8_t SPI_Mem[ADI_SPI_MEMORY_SIZE];
97+
/*******************************************************************************
98+
ADI_SPI_DEV_DATA_TYPE Instance memory containing memory pointer should
99+
guarantee 4 byte alignmnet.
100+
*******************************************************************************/
101+
uint32_t SPI_Mem[(ADI_SPI_MEMORY_SIZE + 3)/4];
94102
#endif
95103
};
96104

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/rtc_api.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
#include "adi_pwr.h"
4747

4848
#define RTC_DEVICE_NUM 0
49-
static uint8_t aRtcDevMem0[ADI_RTC_MEMORY_SIZE];
49+
/*******************************************************************************
50+
ADI_RTC_DEVICE Instance memory containing memory pointer should guarantee
51+
4 byte alignmnet.
52+
*******************************************************************************/
53+
static uint32_t aRtcDevMem0[(ADI_RTC_MEMORY_SIZE + 3)/4];
5054
static ADI_RTC_HANDLE hDevice0 = NULL;
5155

5256

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/spi_api.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,16 @@
5959
int adi_spi_memtype = 0;
6060
#endif
6161
#else
62+
/*******************************************************************************
63+
ADI_SPI_DEV_DATA_TYPE Instance memory containing memory pointer should
64+
guarantee 4 byte alignmnet.
65+
*******************************************************************************/
6266
ADI_SPI_HANDLE spi_Handle0;
63-
uint8_t spi_Mem0[ADI_SPI_MEMORY_SIZE];
67+
uint32_t spi_Mem0[(ADI_SPI_MEMORY_SIZE + 3)/4];
6468
ADI_SPI_HANDLE spi_Handle1;
65-
uint8_t spi_Mem1[ADI_SPI_MEMORY_SIZE];
69+
uint32_t spi_Mem1[(ADI_SPI_MEMORY_SIZE + 3)/4];
6670
ADI_SPI_HANDLE spi_Handle2;
67-
uint8_t spi_Mem2[ADI_SPI_MEMORY_SIZE];
71+
uint32_t spi_Mem2[(ADI_SPI_MEMORY_SIZE + 3)/4];
6872
#if defined(ADI_DEBUG)
6973
#warning "BUILD_SPI_MI_DYNAMIC is NOT defined. Memory allocation for SPI will be static"
7074
int adi_spi_memtype = 1;
@@ -92,7 +96,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
9296
uint32_t spi_data = pinmap_merge(spi_mosi, spi_miso);
9397
uint32_t spi_cntl = pinmap_merge(spi_sclk, spi_ssel);
9498
ADI_SPI_HANDLE *pSPI_Handle;
95-
uint8_t *SPI_Mem;
99+
uint32_t *SPI_Mem;
96100
ADI_SPI_RESULT SPI_Return = ADI_SPI_SUCCESS;
97101
uint32_t nDeviceNum = 0;
98102
ADI_SPI_CHIP_SELECT spi_cs = ADI_SPI_CS_NONE;

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/trng_api.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,15 @@
5454
#define TRNG_CNT_VAL 4095
5555
#define TRNG_PRESCALER 2
5656

57-
/* RNG Device memory */
58-
static uint8_t RngDevMem[ADI_RNG_MEMORY_SIZE];
57+
/*******************************************************************************
58+
RNG Device memory is the instance of ADI_RNG_DEV_DATA_TYPE that contains
59+
pointers and requires 4 byte alignment. The use of uint8_t may cause memory
60+
access fault for some compilers which are not configured to handle unaligned
61+
accesses to SRAM. The size in uint8_t for RngDevMem is ADI_RNG_MEMORY_SIZE.
62+
The size in uint32_t for RngDevMem is recalculated to be
63+
(ADI_RNG_MEMORY_SIZE + 3)/4.
64+
*******************************************************************************/
65+
static uint32_t RngDevMem[(ADI_RNG_MEMORY_SIZE + 3)/4];
5966

6067
void trng_init(trng_t *obj)
6168
{

0 commit comments

Comments
 (0)