Skip to content

Commit

Permalink
Fixes for rand() function and I2C
Browse files Browse the repository at this point in the history
FIXED linker flags: removed --nano.specs to get rand() function working
FIXED I2C receive bug
  • Loading branch information
mhollfelder committed Mar 2, 2017
1 parent 55455da commit 90068bd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
8 changes: 3 additions & 5 deletions arm/libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern "C" {
#include <inttypes.h>

}

#include "Wire.h"

//****************************************************************************
Expand Down Expand Up @@ -81,9 +82,6 @@ void TwoWire::begin(void)
XMC_USIC_CH_SetInputSource(XMC_I2C_config->channel, XMC_USIC_CH_INPUT_DX0, XMC_I2C_config->input_source_dx0);
XMC_USIC_CH_SetInputSource(XMC_I2C_config->channel, XMC_USIC_CH_INPUT_DX1, XMC_I2C_config->input_source_dx1);

//XMC_USIC_CH_TXFIFO_Configure(XMC_I2C_config->channel, 32u, XMC_USIC_CH_FIFO_SIZE_32WORDS, 1u);
//XMC_USIC_CH_RXFIFO_Configure(XMC_I2C_config->channel, 0u, XMC_USIC_CH_FIFO_SIZE_32WORDS, 31u);

XMC_I2C_CH_Start(XMC_I2C_config->channel);

XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->sda.port, (uint8_t)XMC_I2C_config->sda.pin, &(XMC_I2C_config->sda_config));
Expand Down Expand Up @@ -206,7 +204,7 @@ uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddres
{
/* wait for ACK */
}
XMC_I2C_CH_ClearStatusFlag(XMC_I2C_config->channel, XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED | XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
XMC_I2C_CH_ClearStatusFlag(XMC_I2C_config->channel, XMC_I2C_CH_STATUS_FLAG_RECEIVE_INDICATION | XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);

rxBuffer[count] = XMC_I2C_CH_GetReceivedData(XMC_I2C_config->channel);
}
Expand All @@ -215,7 +213,7 @@ uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddres
{
/* wait for ACK */
}
XMC_I2C_CH_ClearStatusFlag(XMC_I2C_config->channel, XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED | XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
XMC_I2C_CH_ClearStatusFlag(XMC_I2C_config->channel, XMC_I2C_CH_STATUS_FLAG_RECEIVE_INDICATION | XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);

rxBuffer[quantity - 1] = XMC_I2C_CH_GetReceivedData(XMC_I2C_config->channel);

Expand Down
3 changes: 0 additions & 3 deletions arm/libraries/Wire/src/utility/xmc_i2c_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @cond
*/


//****************************************************************************
// @Project Includes
//****************************************************************************
Expand Down Expand Up @@ -109,8 +108,6 @@ XMC_I2C_t XMC_I2C_default =
.slave_protocol_irq_num = (IRQn_Type) 92,
.slave_protocol_irq_service_request = 2
};
#else
#error I2C not specified for selected board type
#endif

//****************************************************************************
Expand Down
1 change: 1 addition & 0 deletions arm/libraries/Wire/src/utility/xmc_i2c_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ extern XMC_I2C_t XMC_I2C_default;
extern XMC_I2C_t XMC_I2C_default;

#else
#error XMC Board not supported
#endif

#endif /* XMC_I2C_CONF_H */
2 changes: 1 addition & 1 deletion arm/platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"

## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/linker_script.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" -lc {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" -Wl,--end-group
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/linker_script.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" -Wl,--end-group

## Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
Expand Down

0 comments on commit 90068bd

Please sign in to comment.