Skip to content

Fixed GCC Compiler warnings #1543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,14 @@
#endif

/* Define WEAK attribute */
#if defined ( __CC_ARM )
# define WEAK __attribute__ ((weak))
#elif defined ( __ICCARM__ )
# define WEAK __weak
#elif defined ( __GNUC__ )
# define WEAK __attribute__ ((weak))
#endif
//defined in toochain.h
//#if defined ( __CC_ARM )
//# define WEAK __attribute__ ((weak))
//#elif defined ( __ICCARM__ )
//# define WEAK __weak
//#elif defined ( __GNUC__ )
//# define WEAK __attribute__ ((weak))
//#endif

/* Define NO_INIT attribute */
#if defined ( __CC_ARM )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const struct pwm_pin_channel pwn_pins[] = {
{PB31, PWM_0, 1},

/* Not connected */
{NC , NC , NC}
{(PinName) NC ,(PWMName) NC ,(uint8_t) NC}
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "compiler.h"
#include "system.h"


uint8_t g_sys_init = 0;

//called before main - implement here if board needs it ortherwise, let
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ void analogin_init(analogin_t *obj, PinName pin)
static uint8_t init_flag = 0;

pos_input = pinmap_find_peripheral(pin, PinMap_ADC);
MBED_ASSERT(pos_input != NC);
MBED_ASSERT(pos_input != (uint32_t)NC);

adc_get_config_defaults(&(obj->config_adc));
obj->config_adc.positive_input = pos_input;
obj->config_adc.positive_input = (enum adc_positive_input)pos_input;
if (init_flag == 0) { // ADC init and enable to be done only once.
adc_init(&adc_instance, ADC, &(obj->config_adc));
adc_enable(&adc_instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void dma_handler(const struct dma_resource* const resource)
return;
}

callback_func = dma_channels[channel_index].handler;
callback_func = (void(*)(void))(dma_channels[channel_index].handler);
if (callback_func) {
callback_func();
}
Expand Down Expand Up @@ -268,7 +268,6 @@ bool dma_start_transfer(int channelid)
*/
bool dma_busy(int channelid)
{
int res = 0;
/* Sanity check arguments */
MBED_ASSERT(channelid < CONF_MAX_USED_CHANNEL_NUM);

Expand All @@ -278,7 +277,8 @@ bool dma_busy(int channelid)

if (channel_index >= CONF_MAX_USED_CHANNEL_NUM) {
/* This channel is not active! return zero for now */
res = 0;
//res = 0;
return 0;
}

return dma_is_busy(&dma_channels[channel_index].resource);
Expand All @@ -292,7 +292,6 @@ bool dma_busy(int channelid)
*/
bool dma_is_transfer_complete(int channelid)
{
int res = 0;
/* Sanity check arguments */
MBED_ASSERT(channelid < CONF_MAX_USED_CHANNEL_NUM);

Expand All @@ -302,7 +301,8 @@ bool dma_is_transfer_complete(int channelid)

if (channel_index >= CONF_MAX_USED_CHANNEL_NUM) {
/* This channel is not active! return zero for now */
res = 0;
// res = 0;
return 0;
}

return (STATUS_OK == dma_get_job_status(&dma_channels[channel_index].resource));
Expand Down Expand Up @@ -332,10 +332,10 @@ void dma_set_handler(int channelid, uint32_t handler, uint32_t event)

dma_channels[channel_index].handler = handler;
if (event & DMA_TRANSFER_ERROR) {
dma_register_callback(&dma_channels[channel_index].resource, dma_handler, DMA_CALLBACK_TRANSFER_ERROR);
dma_register_callback(&dma_channels[channel_index].resource, (dma_callback_t)dma_handler, DMA_CALLBACK_TRANSFER_ERROR);
}
if (event & DMA_TRANSFER_COMPLETE) {
dma_register_callback(&dma_channels[channel_index].resource, dma_handler, DMA_CALLBACK_TRANSFER_DONE);
dma_register_callback(&dma_channels[channel_index].resource, (dma_callback_t)dma_handler, DMA_CALLBACK_TRANSFER_DONE);
}

/* Set interrupt vector if someone have removed it */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ void dma_set_handler(int channelid, uint32_t handler, uint32_t event);
}
#endif

#endif /* _DMA_API_HAL_H */
#endif /* _DMA_API_HAL_H */
Original file line number Diff line number Diff line change
Expand Up @@ -487,40 +487,29 @@ enum status_code system_clock_source_write_calibration(
{
switch (clock_source) {
case SYSTEM_CLOCK_SOURCE_OSC8M:

if (calibration_value > 0xfff || freq_range > 4) {
return STATUS_ERR_INVALID_ARG;
}

SYSCTRL->OSC8M.bit.CALIB = calibration_value;
SYSCTRL->OSC8M.bit.FRANGE = freq_range;
break;

case SYSTEM_CLOCK_SOURCE_OSC32K:

if (calibration_value > 128) {
return STATUS_ERR_INVALID_ARG;
}

_system_osc32k_wait_for_sync();
SYSCTRL->OSC32K.bit.CALIB = calibration_value;
break;

case SYSTEM_CLOCK_SOURCE_ULP32K:

if (calibration_value > 32) {
return STATUS_ERR_INVALID_ARG;
}

SYSCTRL->OSCULP32K.bit.CALIB = calibration_value;
break;

default:
Assert(false);
return STATUS_ERR_INVALID_ARG;
break;
}

return STATUS_OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ enum status_code system_clock_source_write_calibration(
default:
Assert(false);
return STATUS_ERR_INVALID_ARG;
break;

}

return STATUS_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
*/

#include <system.h>
#include <toolchain.h>

/**
* \internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void gpio_mode(gpio_t *obj, PinMode mode)
struct port_config pin_conf;

obj->mode = mode;
pin_conf.direction = obj->direction;
pin_conf.direction = (enum port_pin_dir)obj->direction;
pin_conf.powersave = obj->powersave;
switch (mode) {
case PullNone :
Expand All @@ -75,9 +75,8 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
{
MBED_ASSERT(obj->pin != (PinName)NC);
struct port_config pin_conf;

obj->direction = direction;
pin_conf.input_pull = obj->mode;
pin_conf.input_pull = (enum port_pin_pull)obj->mode;
pin_conf.powersave = obj->powersave;
switch (direction) {
case PIN_INPUT :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void gpio_irq(void)
if (extint_chan_is_detected(current_channel)) {
extint_chan_clear_detected(current_channel);
port_base = (PortGroup*)port_get_group_from_gpio_pin(ext_int_pins[current_channel]);
mask = gpio_set(ext_int_pins[current_channel]);
mask = gpio_set((PinName)ext_int_pins[current_channel]);
if ((port_base->IN.reg & mask) != 0) {
event = IRQ_RISE;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static uint32_t i2c_instances[SERCOM_INST_NUM] = {0};
const uint32_t sercom_irq_handlers[SERCOM_INST_NUM] = {
MREPEAT(SERCOM_INST_NUM, _SERCOM_INTERRUPT_HANDLERS, ~)
};

#endif

/* Forward declaration */
Expand Down Expand Up @@ -330,7 +331,7 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
struct i2c_master_packet packet;
packet.address = (address & 0xFF) >> 1;
packet.data_length = length;
packet.data = data;
packet.data = (uint8_t *)data;
packet.ten_bit_address = false;
packet.high_speed = false;

Expand Down Expand Up @@ -596,7 +597,7 @@ void i2c_slave_mode(i2c_t *obj, int enable_slave)
uint32_t sercom_index = _sercom_get_sercom_inst_index(pI2C_S(obj)->master.hw);
for (i=0; i<2; i++) {
mux_func[i] = pinmap_function_sercom(pI2C_S(obj)->pins[0], sercom_index);
if (mux_func[i] == NC) return;
if (mux_func[i] == (uint32_t)NC) return;
}

if (enable_slave) {
Expand Down Expand Up @@ -721,7 +722,7 @@ int i2c_slave_write(i2c_t *obj, const char *data, int length)

struct i2c_slave_packet packet;
packet.data_length = length;
packet.data = data;
packet.data = (uint8_t *)data;

tmp_status = i2c_slave_write_packet_wait(&pI2C_S(obj)->slave, &packet);

Expand All @@ -731,6 +732,7 @@ int i2c_slave_write(i2c_t *obj, const char *data, int length)
/* Currently, no way to track no of bytes transmitted, so return 0 */
return 0;
}

}

/** Configure I2C slave address.
Expand Down Expand Up @@ -863,7 +865,7 @@ void i2c_transfer_asynch(i2c_t *obj, const void *tx, size_t tx_length, void *rx,
/* Init i2c packet. */
pI2C_S(obj)->wr_packet.address = address >> 1;
pI2C_S(obj)->wr_packet.data_length = tx_length;
pI2C_S(obj)->wr_packet.data = tx;
pI2C_S(obj)->wr_packet.data = (uint8_t *)tx;

pI2C_S(obj)->rd_packet.address = address >> 1;
pI2C_S(obj)->rd_packet.data_length = rx_length;
Expand All @@ -877,8 +879,8 @@ void i2c_transfer_asynch(i2c_t *obj, const void *tx, size_t tx_length, void *rx,

/* Set interrupt handler to default handler of ASF */
/* Enable interrupt */
NVIC_SetVector((SERCOM0_IRQn + sercom_index), sercom_irq_handlers[sercom_index]);
NVIC_EnableIRQ(SERCOM0_IRQn + sercom_index);
NVIC_SetVector((IRQn_Type)((uint32_t)SERCOM0_IRQn + sercom_index), sercom_irq_handlers[sercom_index]);
NVIC_EnableIRQ((IRQn_Type)((uint32_t)SERCOM0_IRQn + sercom_index));

/* Register callbacks */
i2c_master_register_callback(&pI2C_S(obj)->master, i2c_transfer_complete_callback, I2C_MASTER_CALLBACK_ERROR);
Expand Down Expand Up @@ -927,20 +929,20 @@ uint32_t i2c_irq_handler_asynch(i2c_t *obj)
case STATUS_OK:
/* Transfer is complete */
return (I2C_EVENT_TRANSFER_COMPLETE & event_mask);
break;

case STATUS_ERR_BAD_ADDRESS:
/* Received a NACK */
return (I2C_EVENT_ERROR_NO_SLAVE & event_mask);
break;

case STATUS_ERR_PACKET_COLLISION:
/* An error occurred in between transfer */
return (I2C_EVENT_ERROR & event_mask);
break;

default:
return 0;
}

return 0;
//return 0;
}

/** Attempts to determine if I2C peripheral is already in use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ void pin_mode(PinName pin, PinMode mode)
}

system_pinmux_pin_set_config(pin, &pin_conf);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ static uint32_t pinmap_merge_pins(uint32_t a, uint32_t b)
*/
uint32_t pinmap_find_peripheral_from_pad(PinName pin, enum sercom_pad_selection pad_select)
{
uint32_t pin_sercom = NC;
uint32_t pin_sercom =(uint32_t)NC;

if (pin == NC) return NC;
if (pin == NC) return (uint32_t)NC;

if (pad_select == SERCOM_USE_EXTENDED_PAD) {
pin_sercom = pinmap_find_peripheral(pin, PinMap_SERCOM_PADEx);
Expand Down Expand Up @@ -99,7 +99,7 @@ uint32_t pinmap_find_sercom(PinName pin1, PinName pin2, PinName pin3, PinName pi
{
int i;
uint32_t sercom_index[4];
uint32_t pin_com = NC;
uint32_t pin_com = (uint32_t)NC;

sercom_index[0] = pinmap_find_peripheral_from_pad(pin1, SERCOM_USE_DEFAULT_PAD);
sercom_index[1] = pinmap_find_peripheral_from_pad(pin2, SERCOM_USE_DEFAULT_PAD);
Expand All @@ -112,7 +112,7 @@ uint32_t pinmap_find_sercom(PinName pin1, PinName pin2, PinName pin3, PinName pi
if (pin_com == (uint32_t)NC) {
pin_com = sercom_index[i] & 0x0F;
} else if (pin_com != (sercom_index[i] & 0x0F)) {
return NC;
return (uint32_t)NC;
}
}
}
Expand All @@ -128,12 +128,12 @@ uint32_t pinmap_find_sercom(PinName pin1, PinName pin2, PinName pin3, PinName pi
*/
uint32_t pinmap_function_sercom(PinName pin, uint32_t sercom_index)
{
uint32_t func = NC;
uint32_t func = (uint32_t)NC;
uint32_t index;
sercom_index &= 0x0F;

if ((pin == NC) || (sercom_index >= SERCOM_INST_NUM)) {
return NC;
return (uint32_t)NC;
}
index = pinmap_peripheral(pin, PinMap_SERCOM_PAD);
if ((index & 0x0F) == sercom_index) {
Expand All @@ -145,7 +145,7 @@ uint32_t pinmap_function_sercom(PinName pin, uint32_t sercom_index)
func = pinmap_function(pin, PinMap_SERCOM_PADEx);
return func;
}
return NC;
return (uint32_t)NC;
}

/** Find the MUX pad of input pin specific to given SERCOM index
Expand All @@ -160,7 +160,7 @@ uint32_t pinmap_pad_sercom(PinName pin, uint32_t sercom_index)
sercom_index &= 0x0F;

if ((pin == NC) || (sercom_index >= SERCOM_INST_NUM)) {
return NC;
return (uint32_t)NC;
}
index = pinmap_peripheral(pin, PinMap_SERCOM_PAD);
if ((index & 0x0F) == sercom_index) {
Expand All @@ -170,7 +170,7 @@ uint32_t pinmap_pad_sercom(PinName pin, uint32_t sercom_index)
if ((index & 0x0F) == sercom_index) {
return ((index >> 4) & 0x0F);
}
return NC;
return (uint32_t)NC;
}

/** Find the MUX function of input pin specific to given SERCOM index
Expand Down Expand Up @@ -201,7 +201,7 @@ uint32_t pinmap_peripheral_sercom(PinName pin, uint32_t sercom_index)
uint32_t index = sercom_index & 0x0F;

if (index >= SERCOM_INST_NUM) {
return NC;
return (uint32_t)NC;
}
return sercom_address[(sercom_index&0x0F)];
}
Expand All @@ -222,5 +222,5 @@ uint32_t pinmap_channel_pwm(PinName pin, PWMName pwm)
}
pwm_ch++;
}
return NC;
return (uint32_t)NC;
}
Loading