Realign ADuCM4x50 and ADuCM302x instance memory blocks

Ensure all instance memory blocks meet 4 byte alignment requirement
  without relying on compiler's or liker's optional settings:
  - gpioMemory[]                                    for adi_gpio_Init()
  - aRtcDevMem0[]                                   for adi_rtc_Open()
  - i2c_Mem[] or I2C_Mem[]                          for adi_i2c_Open()
  - spi_Mem0[], spi_Mem1[], spi_Mem2[] or SPI_Mem[] for adi_spi_Open()
pull/5627/head
Edmund Hsu 2017-12-07 14:57:08 +11:00
parent 7239be2bd7
commit 165b2c665f
14 changed files with 94 additions and 36 deletions

View File

@ -46,9 +46,12 @@
#define MUX_FUNC_0 0x0
#define NUM_GPIO_PORTS 4
extern uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
extern uint8_t gpio_initialized;
/*******************************************************************************
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
extern uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
extern uint8_t gpio_initialized;
static uint16_t gpio_oen[NUM_GPIO_PORTS] = {0};
static uint16_t gpio_output_val[NUM_GPIO_PORTS] = {0};

View File

@ -39,9 +39,12 @@
******************************************************************************/
#include <drivers/gpio/adi_gpio.h>
/*******************************************************************************
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
// ADI GPIO device driver state memory. Only one state memory is required globally.
uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
// Flag to indicate whether the GPIO driver has been initialized
uint8_t gpio_initialized = 0;
uint8_t gpio_initialized = 0;

View File

@ -53,9 +53,12 @@ typedef struct {
gpio_irq_event event;
uint8_t int_enable;
} gpio_chan_info_t;
extern uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
extern uint8_t gpio_initialized;
/*******************************************************************************
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
extern uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
extern uint8_t gpio_initialized;
static gpio_chan_info_t channel_ids[MAX_GPIO_PORTS][MAX_GPIO_LINES];
static gpio_irq_handler irq_handler = NULL;

View File

@ -57,7 +57,11 @@
int adi_i2c_memtype = 0;
#endif
#else
static uint8_t i2c_Mem[ADI_I2C_MEMORY_SIZE];
/*******************************************************************************
ADI_I2C_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
static uint32_t i2c_Mem[(ADI_I2C_MEMORY_SIZE + 3)/4];
static ADI_I2C_HANDLE i2c_Handle;
#if defined(ADI_DEBUG)
#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)
uint32_t i2c_sda = pinmap_peripheral(sda, PinMap_I2C_SDA);
uint32_t i2c_scl = pinmap_peripheral(scl, PinMap_I2C_SCL);
ADI_I2C_HANDLE *pI2C_Handle;
uint8_t *I2C_Mem;
uint32_t *I2C_Mem;
ADI_I2C_RESULT I2C_Return = ADI_I2C_SUCCESS;
uint32_t I2C_DevNum = I2C_0; /* ADuCM3029 only has 1 I2C port */

View File

@ -79,7 +79,11 @@ struct i2c_s {
ADI_I2C_HANDLE *pI2C_Handle;
#if defined(BUILD_I2C_MI_DYNAMIC)
ADI_I2C_HANDLE I2C_Handle;
uint8_t I2C_Mem[ADI_I2C_MEMORY_SIZE];
/*******************************************************************************
ADI_I2C_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
uint32_t I2C_Mem[(ADI_I2C_MEMORY_SIZE + 3)/4];
#endif
};
@ -90,7 +94,11 @@ struct spi_s {
ADI_SPI_HANDLE *pSPI_Handle;
#if defined(BUILD_SPI_MI_DYNAMIC)
ADI_SPI_HANDLE SPI_Handle;
uint8_t SPI_Mem[ADI_SPI_MEMORY_SIZE];
/*******************************************************************************
ADI_SPI_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
uint32_t SPI_Mem[(ADI_SPI_MEMORY_SIZE + 3)/4];
#endif
};

View File

@ -46,7 +46,11 @@
#include "adi_pwr.h"
#define RTC_DEVICE_NUM 0
static uint8_t aRtcDevMem0[ADI_RTC_MEMORY_SIZE];
/*******************************************************************************
ADI_RTC_DEVICE Instance memory containing memory pointer should guarantee
4 byte alignmnet.
*******************************************************************************/
static uint32_t aRtcDevMem0[(ADI_RTC_MEMORY_SIZE + 3)/4];
static ADI_RTC_HANDLE hDevice0 = NULL;

View File

@ -59,12 +59,16 @@
int adi_spi_memtype = 0;
#endif
#else
/*******************************************************************************
ADI_SPI_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
ADI_SPI_HANDLE spi_Handle0;
uint8_t spi_Mem0[ADI_SPI_MEMORY_SIZE];
uint32_t spi_Mem0[(ADI_SPI_MEMORY_SIZE + 3)/4];
ADI_SPI_HANDLE spi_Handle1;
uint8_t spi_Mem1[ADI_SPI_MEMORY_SIZE];
uint32_t spi_Mem1[(ADI_SPI_MEMORY_SIZE + 3)/4];
ADI_SPI_HANDLE spi_Handle2;
uint8_t spi_Mem2[ADI_SPI_MEMORY_SIZE];
uint32_t spi_Mem2[(ADI_SPI_MEMORY_SIZE + 3)/4];
#if defined(ADI_DEBUG)
#warning "BUILD_SPI_MI_DYNAMIC is NOT defined. Memory allocation for SPI will be static"
int adi_spi_memtype = 1;
@ -92,7 +96,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
uint32_t spi_data = pinmap_merge(spi_mosi, spi_miso);
uint32_t spi_cntl = pinmap_merge(spi_sclk, spi_ssel);
ADI_SPI_HANDLE *pSPI_Handle;
uint8_t *SPI_Mem;
uint32_t *SPI_Mem;
ADI_SPI_RESULT SPI_Return = ADI_SPI_SUCCESS;
uint32_t nDeviceNum = 0;
ADI_SPI_CHIP_SELECT spi_cs = ADI_SPI_CS_NONE;

View File

@ -46,9 +46,12 @@
#define MUX_FUNC_0 0x0
#define NUM_GPIO_PORTS 4
extern uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
extern uint8_t gpio_initialized;
/*******************************************************************************
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
extern uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
extern uint8_t gpio_initialized;
static uint16_t gpio_oen[NUM_GPIO_PORTS] = {0};
static uint16_t gpio_output_val[NUM_GPIO_PORTS] = {0};

View File

@ -39,9 +39,12 @@
******************************************************************************/
#include <drivers/gpio/adi_gpio.h>
/*******************************************************************************
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
// ADI GPIO device driver state memory. Only one state memory is required globally.
uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE +3)/4];
// Flag to indicate whether the GPIO driver has been initialized
uint8_t gpio_initialized = 0;
uint8_t gpio_initialized = 0;

View File

@ -52,9 +52,12 @@ typedef struct {
gpio_irq_event event;
uint8_t int_enable;
} gpio_chan_info_t;
extern uint8_t gpioMemory[ADI_GPIO_MEMORY_SIZE];
extern uint8_t gpio_initialized;
/*******************************************************************************
ADI_GPIO_DEV_DATA Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
extern uint32_t gpioMemory[(ADI_GPIO_MEMORY_SIZE + 3)/4];
extern uint8_t gpio_initialized;
static gpio_chan_info_t channel_ids[MAX_GPIO_PORTS][MAX_GPIO_LINES];
static gpio_irq_handler irq_handler = NULL;

View File

@ -57,7 +57,11 @@
int adi_i2c_memtype = 0;
#endif
#else
static uint8_t i2c_Mem[ADI_I2C_MEMORY_SIZE];
/*******************************************************************************
ADI_I2C_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
static uint32_t i2c_Mem[(ADI_I2C_MEMORY_SIZE + 3)/4];
static ADI_I2C_HANDLE i2c_Handle;
#if defined(ADI_DEBUG)
#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)
uint32_t i2c_sda = pinmap_peripheral(sda, PinMap_I2C_SDA);
uint32_t i2c_scl = pinmap_peripheral(scl, PinMap_I2C_SCL);
ADI_I2C_HANDLE *pI2C_Handle;
uint8_t *I2C_Mem;
uint32_t *I2C_Mem;
ADI_I2C_RESULT I2C_Return = ADI_I2C_SUCCESS;
uint32_t I2C_DevNum = I2C_0; /* ADuCM4050 only has 1 I2C port */

View File

@ -79,7 +79,11 @@ struct i2c_s {
ADI_I2C_HANDLE *pI2C_Handle;
#if defined(BUILD_I2C_MI_DYNAMIC)
ADI_I2C_HANDLE I2C_Handle;
uint8_t I2C_Mem[ADI_I2C_MEMORY_SIZE];
/*******************************************************************************
ADI_I2C_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
uint32_t I2C_Mem[(ADI_I2C_MEMORY_SIZE + 3)/4];
#endif
};
@ -90,7 +94,11 @@ struct spi_s {
ADI_SPI_HANDLE *pSPI_Handle;
#if defined(BUILD_SPI_MI_DYNAMIC)
ADI_SPI_HANDLE SPI_Handle;
uint8_t SPI_Mem[ADI_SPI_MEMORY_SIZE];
/*******************************************************************************
ADI_SPI_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
uint32_t SPI_Mem[(ADI_SPI_MEMORY_SIZE + 3)/4];
#endif
};

View File

@ -46,7 +46,11 @@
#include "adi_pwr.h"
#define RTC_DEVICE_NUM 0
static uint8_t aRtcDevMem0[ADI_RTC_MEMORY_SIZE];
/*******************************************************************************
ADI_RTC_DEVICE Instance memory containing memory pointer should guarantee
4 byte alignmnet.
*******************************************************************************/
static uint32_t aRtcDevMem0[(ADI_RTC_MEMORY_SIZE + 3)/4];
static ADI_RTC_HANDLE hDevice0 = NULL;

View File

@ -61,12 +61,16 @@
int adi_spi_memtype = 0;
#endif
#else
/*******************************************************************************
ADI_SPI_DEV_DATA_TYPE Instance memory containing memory pointer should
guarantee 4 byte alignmnet.
*******************************************************************************/
ADI_SPI_HANDLE spi_Handle0;
uint8_t spi_Mem0[ADI_SPI_MEMORY_SIZE];
uint32_t spi_Mem0[(ADI_SPI_MEMORY_SIZE + 3)/4];
ADI_SPI_HANDLE spi_Handle1;
uint8_t spi_Mem1[ADI_SPI_MEMORY_SIZE];
uint32_t spi_Mem1[(ADI_SPI_MEMORY_SIZE + 3)/4];
ADI_SPI_HANDLE spi_Handle2;
uint8_t spi_Mem2[ADI_SPI_MEMORY_SIZE];
uint32_t spi_Mem2[(ADI_SPI_MEMORY_SIZE + 3)/4];
#if defined(ADI_DEBUG)
#warning "BUILD_SPI_MI_DYNAMIC is NOT defined. Memory allocation for SPI will be static"
int adi_spi_memtype = 1;
@ -94,7 +98,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
uint32_t spi_data = pinmap_merge(spi_mosi, spi_miso);
uint32_t spi_cntl = pinmap_merge(spi_sclk, spi_ssel);
ADI_SPI_HANDLE *pSPI_Handle;
uint8_t *SPI_Mem;
uint32_t *SPI_Mem;
ADI_SPI_RESULT SPI_Return = ADI_SPI_SUCCESS;
uint32_t nDeviceNum = 0;
ADI_SPI_CHIP_SELECT spi_cs = ADI_SPI_CS_NONE;