Skip to content

Commit

Permalink
CHANGED: Wire lib - use HW FIFO - incresed buffer size - renamed stru…
Browse files Browse the repository at this point in the history
…ct variable

FIXED: == / = typo
UPDATED: boards.txt
INCREASED: Stack size (XMC1100)
FIXED: HardwareSerial issue from GitHub
ADJUSTED: delayMicroseconds
ADDED: XMC1300 Board
  • Loading branch information
mhollfelder committed Jul 19, 2017
1 parent a931d89 commit 057193b
Show file tree
Hide file tree
Showing 73 changed files with 1,882 additions and 6,336 deletions.
File renamed without changes.
25 changes: 21 additions & 4 deletions arm/README.md → arm/README.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
# Infineon's XMC Microcontroller Boards for Arduino
# Infineon's XMC Microcontroller Boards for Arduino

```
Important Information:
Arduino 1.8.0 IDE might have problems with the XMC-for-Arduino releases.
Please update to the newest version.
In case of problems, please open an 'Issue' ticket and we will get in contact with you.
```
From the road test of our products, we got the feedback that you might not get a notification that a new firmware is available for the built-in SEGGER J-Link debugger taking care of the flashing as well as additional handling of the microcontrollers on the evaluation boards.
Please be informed that this might lead to problems and this makes use of the boards impossible, e.g. in the Arduino IDE an upload might be indicated as successful, but nothing happens or GDB errors occur in DAVE.

The notes and direct inputs from Enrico Miglino, Thomas Gambill as well as all the colleagues from the element14 community discussing this topic have shown this issue, please find the discussion here:

[element14: Infineon DC Motor Shield w/ TLE94112EL for Arduino](https://www.element14.com/community/roadTests/1760/l/infineon-dc-motor-shield-w-tle94112el-for-arduino#comment-107765)

Thank you very much for your effort and input.
If you face these problems, please update to the latest firmware by using SEGGER J-Link Configurator as shown below:

![J-Link_Conf](https://raw.githubusercontent.com/infineon/assets/master/Pictures/J-Link_Conf.png)

In case of further problems, please open an 'Issue' ticket and we will get in contact with you.

Thank you very much!

Kind regards,

The Infineon Team

```

```


This repository enables the integration of [Infineon's](https://www.infineon.com/) XMC microcontrollers into the [Arduino IDE](https://www.arduino.cc/en/main/software).

## Supported Microcontroller Boards
Expand All @@ -22,6 +37,7 @@ This repository enables the integration of [Infineon's](https://www.infineon.com
* [XMC4700 Relax Kit](https://www.infineon.com/cms/en/product/evaluation-boards/KIT_XMC47_RELAX_LITE_V1/productType.html?productType=5546d46250cc1fdf0150f6a2788e6e89)

## Additional Information

Please visit also the Wiki for additional information, e.g. datasheets, pin out diagrams, etc.:

[XMC-for-Arduino Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki)
Expand Down Expand Up @@ -68,3 +84,4 @@ In the boards list **Tools** > **Board**, the XMC microcontroller boards XMC2Go,
* **This integration will only work for Arduino IDE >=1.5**
* **The XMC1100 Boot Kit has limitations if compared to the official Arduino boards (consult the [XMC-for-Arduino Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki) for more information)**
* **Refer also to the LICENSE.md/txt file for further information**
* **Arduino 1.8.0 IDE might have problems with the XMC-for-Arduino releases**
60 changes: 31 additions & 29 deletions arm/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ XMC1100_Boot_Kit.build.f_cpu=32000000L
XMC1100_Boot_Kit.build.board=ARM_XMC
XMC1100_Boot_Kit.build.board.version=1100
XMC1100_Boot_Kit.build.board.type=T038x0064
XMC1100_Boot_Kit.build.board.v=0032
XMC1100_Boot_Kit.build.board.v=0064
XMC1100_Boot_Kit.build.core=./
XMC1100_Boot_Kit.build.variant=XMC1100
XMC1100_Boot_Kit.build.board_variant=XMC1100_Boot_Kit
Expand Down Expand Up @@ -49,7 +49,7 @@ XMC1100_XMC2GO.build.f_cpu=32000000L
XMC1100_XMC2GO.build.board=ARM_XMC
XMC1100_XMC2GO.build.board.version=1100
XMC1100_XMC2GO.build.board.type=T038x0064
XMC1100_XMC2GO.build.board.v=0032
XMC1100_XMC2GO.build.board.v=0064
XMC1100_XMC2GO.build.core=./
XMC1100_XMC2GO.build.variant=XMC1100
XMC1100_XMC2GO.build.board_variant=XMC1100_XMC2GO
Expand All @@ -58,33 +58,35 @@ XMC1100_XMC2GO.build.flash_ld=linker_script.ld


####################################################
#XMC1300_Boot_Kit.name=XMC1300 Boot Kit
#XMC1300_Boot_Kit.upload.tool=xmcprog
#XMC1300_Boot_Kit.upload.speed=115200
#XMC1300_Boot_Kit.upload.resetmethod=ck
#XMC1300_Boot_Kit.upload.maximum_size=65536
#XMC1300_Boot_Kit.upload.wait_for_upload_port=true

#XMC1300_Boot_Kit.communication=usb
#XMC1300_Boot_Kit.protocol=dragon_isp
#XMC1300_Boot_Kit.program.protocol=dragon_isp
#XMC1300_Boot_Kit.program.tool=xmcprog
#XMC1300_Boot_Kit.program.extra_params=-Pusb

#XMC1300_Boot_Kit.serial.disableDTR=true
#XMC1300_Boot_Kit.serial.disableRTS=true

#XMC1300_Boot_Kit.build.mcu=cortex-m0
#XMC1300_Boot_Kit.build.f_cpu=32000000L
#XMC1300_Boot_Kit.build.board=ARM_XMC
#XMC1300_Boot_Kit.build.board.version=1302
#XMC1300_Boot_Kit.build.board.type=T038x0200
#XMC1300_Boot_Kit.build.board.v=0200
#XMC1300_Boot_Kit.build.core=./
#XMC1300_Boot_Kit.build.variant=XMC1300
#XMC1300_Boot_Kit.build.board_variant=XMC1300_Boot_Kit
#XMC1300_Boot_Kit.build.flash_size=64K
#XMC1300_Boot_Kit.build.flash_ld=linker_script.ld
XMC1300_Boot_Kit.name=XMC1300 Boot Kit
XMC1300_Boot_Kit.upload.tool=xmcprog
XMC1300_Boot_Kit.upload.speed=115200
XMC1300_Boot_Kit.upload.resetmethod=ck
XMC1300_Boot_Kit.upload.maximum_size=65536
XMC1300_Boot_Kit.upload.wait_for_upload_port=true

XMC1300_Boot_Kit.communication=usb
XMC1300_Boot_Kit.protocol=dragon_isp
XMC1300_Boot_Kit.program.protocol=dragon_isp
XMC1300_Boot_Kit.program.tool=xmcprog
XMC1300_Boot_Kit.program.extra_params=-Pusb

XMC1300_Boot_Kit.serial.disableDTR=true
XMC1300_Boot_Kit.serial.disableRTS=true

XMC1300_Boot_Kit.build.mcu=cortex-m0
XMC1300_Boot_Kit.build.f_cpu=32000000L
XMC1300_Boot_Kit.build.board=ARM_XMC
XMC1300_Boot_Kit.build.board.version=1302
XMC1300_Boot_Kit.build.board.type=T038x0200
XMC1300_Boot_Kit.build.board.v=0200
XMC1300_Boot_Kit.build.core=./
XMC1300_Boot_Kit.build.variant=XMC1300
XMC1300_Boot_Kit.build.board_variant=XMC1300_Boot_Kit
XMC1300_Boot_Kit.build.flash_size=64K
XMC1300_Boot_Kit.build.flash_ld=linker_script.ld


####################################################
XMC4700_Relax_Kit.name=XMC4700 Relax Kit
XMC4700_Relax_Kit.upload.tool=xmcprog
Expand Down
54 changes: 39 additions & 15 deletions arm/cores/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern "C" {
// @Std Includes
//****************************************************************************
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <types.h>
Expand All @@ -43,6 +44,8 @@ extern "C" {
#include <xmc_ccu8.h>
#include <xmc_vadc.h>
#include <xmc_uart.h>
//Additional xmc libs
#include <xmc_dac.h>

//****************************************************************************
// @Defines
Expand Down Expand Up @@ -124,6 +127,19 @@ extern "C" {
} XMC_PWM8_t;
#endif

#ifdef DAC
//TODO: find a better name; XMC_DAC_t is already used by XMCLib
/*
* XMC DAC type
*/
typedef struct
{
XMC_DAC_t *group;
uint8_t channel;
uint8_t resolution; //number of resolution bits
} XMC_ARD_DAC_t;
#endif

/*
* XMC VADC type (with or without adc grouping)
*/
Expand Down Expand Up @@ -168,10 +184,33 @@ extern "C" {
#ifdef CCU8V2
extern XMC_PWM8_t mapping_pwm8[];
#endif
#ifdef DAC
extern XMC_ARD_DAC_t mapping_dac[];
#endif

extern XMC_UART_t XMC_UART_debug;
extern XMC_UART_t XMC_UART_on_board;

//****************************************************************************
// @Prototypes Of Global Functions
//****************************************************************************

/*
* \brief Arduino yield function.
*/
void yield( void );

/*
* \brief Arduino Main setup function. Called only once at the beginning.
*/
extern void setup(void);

/*
* \brief Arduino Main loop function. Called in an endless loop.
*/
extern void loop(void);


//****************************************************************************
// @Arduino Core Includes
//****************************************************************************
Expand All @@ -197,21 +236,6 @@ extern "C" {
#include "HardwareSerial.h"


//****************************************************************************
// @Prototypes Of Global Functions
//****************************************************************************

/*
* \brief Arduino Main setup function. Called only once at the beginning.
*/
extern void setup(void);

/*
* \brief Arduino Main loop function. Called in an endless loop.
*/
extern void loop(void);


//****************************************************************************
// @Board Variant Includes
//****************************************************************************
Expand Down
5 changes: 4 additions & 1 deletion arm/cores/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ void HardwareSerial::IrqHandler( void )
XMC_UART_CH_ClearStatusFlag(_XMC_UART_config->channel, (XMC_UART_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION |
XMC_UART_CH_STATUS_FLAG_RECEIVE_INDICATION));

_rx_buffer->store_char(XMC_UART_CH_GetReceivedData(_XMC_UART_config->channel));
while(_XMC_UART_config->channel->RBUFSR & (USIC_CH_RBUFSR_RDV0_Msk | USIC_CH_RBUFSR_RDV1_Msk))
{
_rx_buffer->store_char(XMC_UART_CH_GetReceivedData(_XMC_UART_config->channel));
}
}

// Do we need to keep sending data?
Expand Down
15 changes: 5 additions & 10 deletions arm/cores/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ typedef enum XMC_UART_MODE
class HardwareSerial: public Stream
{
public:
XMC_UART_t* _XMC_UART_config;

HardwareSerial(XMC_UART_t* xmc_uart_config, RingBuffer* rx_buffer, RingBuffer* tx_buffer);

void begin(const uint32_t speed);
void begin(const uint32_t speed, const XMC_UART_MODE_t config);
void end(void);
Expand Down Expand Up @@ -121,19 +123,12 @@ class HardwareSerial: public Stream
private:
RingBuffer* _rx_buffer;
RingBuffer* _tx_buffer;

XMC_UART_t* _XMC_UART_config;
};

extern HardwareSerial Serial;
#if (NUM_SERIAL > 1)

#if defined(XMC4700_Relax_Kit)
extern HardwareSerial Serial1;
#elif (NUM_SERIAL > 2)
extern HardwareSerial Serial2;
#elif (NUM_SERIAL > 3)
extern HardwareSerial Serial3;
#elif (NUM_SERIAL > 4)
extern HardwareSerial Serial4;
#endif


Expand Down
32 changes: 32 additions & 0 deletions arm/cores/hooks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (c) 2012 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/**
* Empty yield() hook.
*
* This function is intended to be used by library writers to build
* libraries or sketches that supports cooperative threads.
*
* Its defined as a weak symbol and it can be redefined to implement a
* real cooperative scheduler.
*/
static void __empty() {
// Empty
}
void yield(void) __attribute__ ((weak, alias("__empty")));

16 changes: 16 additions & 0 deletions arm/cores/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ void wiring_analog_init(void)
/* Initialize the background source hardware. The gating mode is set to
* ignore to pass external triggers unconditionally.*/
XMC_VADC_GLOBAL_BackgroundInit(VADC, &vadc_background_config);


//Additional Initialization of DAC starting here

}

void analogReadResolution(uint8_t res)
Expand Down Expand Up @@ -236,6 +240,18 @@ void analogWrite(uint8_t pin, uint16_t value)

XMC_CCU8_SLICE_StartTimer(pwm8->slice);
}
#endif
#ifdef DAC
else if(digitalPinHasDAC(pin))
{
uint8_t dac_num = digitalPinToDACNum(pin);
XMC_ARD_DAC_t *dac = &(mapping_dac[dac_num]);
XMC_DAC_Enable(dac->group);
XMC_DAC_CH_EnableOutput(dac->group, dac->channel);
XMC_DAC_CH_StartSingleValueMode(dac->group, dac->channel);
uint16_t dacValue = map(value, 0, (0b10<<_writeResolution)-1, 0, (0b10<<dac->resolution)-1);
XMC_DAC_CH_Write(dac->group, dac->channel, dacValue);
}
#endif
else // all the other pins
{
Expand Down
6 changes: 5 additions & 1 deletion arm/cores/wiring_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ void delay(uint32_t dwMs)
XMC_SYSTIMER_StartTimer(TimerId);

// Wait until timer expires
while (!delay_timer_expired);
do
{
yield();
}
while(!delay_timer_expired);

// Delete Timer since is One-Shot
XMC_SYSTIMER_DeleteTimer(TimerId);
Expand Down
2 changes: 1 addition & 1 deletion arm/cores/wiring_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" {
#define USEC_TO_N_NOP_CYCLES 36
#elif ((UC_FAMILY == XMC1) && (F_CPU == 32000000U))
// time per loop cycle: 0,375 us
#define USEC_TO_N_NOP_CYCLES 2.66
#define USEC_TO_N_NOP_CYCLES 3
#else
#error USEC_TO_N_NOP_CYCLES not calculated
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ void setup()
//Use the commented line below instead to use the default I2C address.
//ifxDps310.begin(Wire);

// the function below fixes a hardware problem on some devices
// you have this bug if you measure around 60°C when temperature is around 20°C
// call correctTemp() directly after begin() to fix this issue
//ifxDps310.correctTemp();

//temperature measure rate (value from 0 to 7)
//2^temp_mr temperature measurement results per second
int temp_mr = 2;
Expand Down
5 changes: 5 additions & 0 deletions arm/libraries/IFX_Dps310/example/i2c_command/i2c_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ void setup()
//if you are using the Pressure 3 click Board, you need 0x76
//ifxDps310.begin(&Wire);

// the function below fixes a hardware problem on some devices
// you have this bug if you measure around 60°C when temperature is around 20°C
// call correctTemp() directly after begin() to fix this issue
//ifxDps310.correctTemp();

Serial.println("Init complete!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ void setup()

//begin and config Dps310 for interrupts
ifxDps310.begin(Wire);

// the function below fixes a hardware problem on some devices
// you have this bug if you measure around 60°C when temperature is around 20°C
// call correctTemp() directly after begin() to fix this issue
//ifxDps310.correctTemp();

int ret = ifxDps310.setInterruptPolarity(1);
ret = ifxDps310.setInterruptSources(1, 0, 0);
//clear interrupt flag by reading
Expand Down
Loading

0 comments on commit 057193b

Please sign in to comment.