diff --git a/README.md b/README.md index 0cdb4994..e158f085 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ This repository integrates [Infineon's](https://www.infineon.com/) XMC microcont - [Prework for SEGGER J-Link](#prework-for-segger-j-link) - [Using Arduino IDE](#using-arduino-ide) - [Separation of release packages from version 2.0.0 onwards](#separation-of-release-packages-from-version-200-onwards) + - [Known Issues](#known-issues) - [Using PlatformIO IDE](#using-platformio-ide) - [Contributing and Third Party Libraries](#contributing-and-third-party-libraries) - [Additional Contributors](#additional-contributors) @@ -104,6 +105,10 @@ Any new board or feature integration will only be done in the *XMC Family V2.x* ![Board list v1x](https://raw.githubusercontent.com/Infineon/Assets/version-2.x/Pictures/Board_List_v2x.png.jpg) +### Known Issues + +* :warning: While using the pins connected to the **LEDs** configured as **INPUT**, there might be some abberation in behavior due to the presence of the series resistor of the LED, as it causes a voltage drop on the pin. In case of such an occurance, it is advised to desolder the series resistor and the LED and thereby using the pin as INPUT. + ### Using PlatformIO IDE - [What is PlatformIO?](http://docs.platformio.org/en/latest/what-is-platformio.html?utm_source=github&utm_medium=xmc-for-arduino) diff --git a/boards.txt b/boards.txt index df311a24..4ebf9a46 100644 --- a/boards.txt +++ b/boards.txt @@ -67,7 +67,7 @@ XMC1100_XMC2GO.build.mcu=cortex-m0 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.type=Q024x0064 XMC1100_XMC2GO.build.board.v=0064 XMC1100_XMC2GO.build.core=./ XMC1100_XMC2GO.build.variant=XMC1100 diff --git a/cores/Arduino.h b/cores/Arduino.h index 37bd3177..3fcdc415 100644 --- a/cores/Arduino.h +++ b/cores/Arduino.h @@ -47,6 +47,9 @@ extern "C" { #include #include #include +#include +#include +#include //**************************************************************************** // @Defines @@ -55,6 +58,13 @@ extern "C" { #define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) #define microsecondsToClockCycles(a) ( (a) * (F_CPU / 1000000L) ) +// default XMC_SPI instance is XMC_SPI_0 for all variants +#define XMC_SPI_default XMC_SPI_0 +// default XMC_I2C instance is XMC_I2C_0 for all variants +#define XMC_I2C_default XMC_I2C_0 +// used by XMC_I2S +#define BUFFER_SIZE 512 + //**************************************************************************** // @Typedefs //**************************************************************************** @@ -187,6 +197,53 @@ extern "C" { uint32_t irq_service_request ; } XMC_UART_t; + /* + * XMC SPI type + */ + typedef struct + { + XMC_USIC_CH_t* channel ; + XMC_SPI_CH_CONFIG_t channel_config ; + XMC_PORT_PIN_t mosi ; + XMC_GPIO_CONFIG_t mosi_config ; + XMC_PORT_PIN_t miso ; + XMC_GPIO_CONFIG_t miso_config ; + XMC_USIC_INPUT_t input_source ; + XMC_PORT_PIN_t sclkout ; + XMC_GPIO_CONFIG_t sclkout_config ; + } XMC_SPI_t; + + /* + * XMC I2C type + */ + typedef struct + { + XMC_USIC_CH_t* channel; + XMC_I2C_CH_CONFIG_t channel_config; + XMC_PORT_PIN_t sda; + XMC_GPIO_CONFIG_t sda_config; + XMC_PORT_PIN_t scl; + XMC_GPIO_CONFIG_t scl_config; + XMC_USIC_INPUT_t input_source_dx0; + XMC_USIC_INPUT_t input_source_dx1; + IRQn_Type slave_receive_irq_num; + uint32_t slave_receive_irq_service_request; + IRQn_Type protocol_irq_num; + uint32_t protocol_irq_service_request; + } XMC_I2C_t; + + /* + * XMC I2S type + */ + typedef struct + { + XMC_GPIO_CONFIG_t input_config; + XMC_GPIO_CONFIG_t sclk_config; + XMC_GPIO_CONFIG_t wa_config; + IRQn_Type protocol_irq_num; + uint32_t protocol_irq_service_request; + } XMC_I2S_t; + //**************************************************************************** // @Imported Global Variables //**************************************************************************** @@ -205,6 +262,17 @@ extern "C" { #endif extern XMC_UART_t XMC_UART_debug; extern XMC_UART_t XMC_UART_on_board; + + extern XMC_SPI_t XMC_SPI_0; + // Some boards for eg. XMC4700 Relax Kit has more than one SPI instance + extern XMC_SPI_t XMC_SPI_1; + extern XMC_SPI_t XMC_SPI_2; + + extern XMC_I2C_t XMC_I2C_0; + // Some boards for eg. XMC4700 Relax Kit has more than one I2C instance + extern XMC_I2C_t XMC_I2C_1; + + extern XMC_I2S_t i2s_config; //**************************************************************************** // @Prototypes Of Global Functions diff --git a/cores/HardwareSerial.cpp b/cores/HardwareSerial.cpp index e4763829..64a8e649 100644 --- a/cores/HardwareSerial.cpp +++ b/cores/HardwareSerial.cpp @@ -56,8 +56,6 @@ uart_ch_config.stop_bits = (uint8_t)(( config & 0x0f0U ) >> 4 ); XMC_UART_CH_Init( _XMC_UART_config->channel, &uart_ch_config ); -XMC_GPIO_Init( _XMC_UART_config->rx.port, _XMC_UART_config->rx.pin, &(_XMC_UART_config->rx_config) ); - // dx0 is UART RX: source must be set XMC_USIC_CH_SetInputSource( _XMC_UART_config->channel, XMC_USIC_CH_INPUT_DX0, _XMC_UART_config->input_source_dx0 ); @@ -92,10 +90,13 @@ XMC_USIC_CH_SetInterruptNodePointer(_XMC_UART_config->channel, _XMC_UART_config->irq_service_request ); NVIC_SetPriority(_XMC_UART_config->irq_num, 3); NVIC_EnableIRQ(_XMC_UART_config->irq_num); + +XMC_UART_CH_Start( _XMC_UART_config->channel ); + // TX pin setup put here to avoid startup corrupted characters being first sent XMC_GPIO_Init( _XMC_UART_config->tx.port, _XMC_UART_config->tx.pin, &(_XMC_UART_config->tx_config) ); -XMC_UART_CH_Start( _XMC_UART_config->channel ); +XMC_GPIO_Init( _XMC_UART_config->rx.port, _XMC_UART_config->rx.pin, &(_XMC_UART_config->rx_config) ); } diff --git a/cores/wiring_analog.c b/cores/wiring_analog.c index 5fc4b102..6e1576b4 100644 --- a/cores/wiring_analog.c +++ b/cores/wiring_analog.c @@ -216,6 +216,70 @@ if( channel < NUM_ANALOG_INPUTS ) return value; } +/* analogRead_variableGain takes parameter of ADC channel number and gain value + return 0xFFFFFFFF for invalid channel + + gain value gain factor + 0 1 + 1 3 + 2 6 + 3 12 + Also, refer to macros in wiring_analog.h +*/ + +uint32_t analogRead_variableGain( uint8_t channel, uint8_t gain_value ) +{ +#if(XMC_VADC_SHS_AVAILABLE == 1U) +uint32_t value; + +value = 0xFFFFFFFF; +if( channel < NUM_ANALOG_INPUTS ) + { + XMC_ADC_t *adc = &mapping_adc[ channel ]; + +#if(XMC_VADC_GROUP_AVAILABLE == 1U) + // ADC grouping + if( !(adc->enabled) ) + { + XMC_VADC_CHANNEL_CONFIG_t vadc_gobal_channel_config; + memset( &vadc_gobal_channel_config, 0, sizeof( XMC_VADC_CHANNEL_CONFIG_t ) ); + vadc_gobal_channel_config.input_class = XMC_VADC_CHANNEL_CONV_GROUP_CLASS1; + vadc_gobal_channel_config.result_reg_number = adc->result_reg_num; + vadc_gobal_channel_config.alias_channel = XMC_VADC_CHANNEL_ALIAS_DISABLED; + + XMC_VADC_RESULT_CONFIG_t vadc_gobal_result_config = { .g_rcr = 0 }; + /* Configure a channel belonging to the aforesaid conversion kernel */ + XMC_VADC_GROUP_ChannelInit( adc->group, adc->channel_num, &vadc_gobal_channel_config ); + /* Configure a result resource belonging to the aforesaid conversion kernel */ + XMC_VADC_GROUP_ResultInit( adc->group, adc->result_reg_num, &vadc_gobal_result_config ); + /* Add channel into the Background Request Source Channel Select Register */ + XMC_VADC_GLOBAL_BackgroundAddChannelToSequence( VADC, (uint32_t)adc->group_num, + (uint32_t)adc->channel_num ); + /* Set the gain factor of the Sample and hold module*/ + XMC_VADC_GLOBAL_SHS_SetGainFactor( SHS0, gain_value, (uint32_t)adc->group_num, (uint32_t)adc->channel_num ); + } + /* Start conversion manually using load event trigger*/ + XMC_VADC_GLOBAL_BackgroundTriggerConversion( VADC ); + value = XMC_VADC_GROUP_GetResult( adc->group, adc->result_reg_num ); +#else + // XMC1100 no ADC grouping + if( !(adc->enabled) ) + /* Add a channel to the background source. */ + VADC->BRSSEL[ ADC_CONVERSION_GROUP ] = (uint32_t)( 1U << adc->channel_num ); + /* Set the gain factor of the Sample and hold module */ + XMC_VADC_GLOBAL_SHS_SetGainFactor( SHS0, gain_value, XMC_VADC_GROUP_INDEX_0, (uint32_t)adc->channel_num ); + // Generates conversion request + XMC_VADC_GLOBAL_BackgroundTriggerConversion( VADC ); + + // Wait until conversion is ready + while( ( ( value = XMC_VADC_GLOBAL_GetDetailedResult( VADC ) ) & VADC_GLOBRES_VF_Msk) == 0u ); +#endif + value = ( ( value & VADC_GLOBRES_RESULT_Msk) >> ( ADC_MAX_READ_RESOLUTION - _readResolution ) ); +return value; + } +#endif +} + /* Helper function for analogWrite and setAnalogWriteFrequency to scan mapping tables to determine for a given pin which PWM4, PWM8 or DAC diff --git a/cores/wiring_analog.h b/cores/wiring_analog.h index 3da40ccc..10162ee1 100644 --- a/cores/wiring_analog.h +++ b/cores/wiring_analog.h @@ -26,6 +26,15 @@ extern "C" { #endif +/********************************************************************************************************************* + * MACROS + ********************************************************************************************************************/ +// ADC gain macros +#define ADC_VAR_GAIN_FACTOR_1 0 +#define ADC_VAR_GAIN_FACTOR_3 1 +#define ADC_VAR_GAIN_FACTOR_6 2 +#define ADC_VAR_GAIN_FACTOR_12 3 + //**************************************************************************** // @External Prototypes //**************************************************************************** @@ -85,6 +94,22 @@ extern "C" { */ extern uint32_t analogRead( uint8_t channel ) ; + /* + * \brief Reads the value from the specified analogue channel and add variable gain at input. + * + * \param channel + * \param gain_factor + * + * gain value gain factor + * 0 1 + * 1 3 + * 2 6 + * 3 12 + * + * \return Read value from selected channel, or 0xFFFFFFFF for error. + */ + extern uint32_t analogRead_variableGain( uint8_t channel, uint8_t gain_value ) ; + /* * \brief Set the resolution of analogRead return values in number of bits. * \note Default is 10 bits (range from 0 to 1023). diff --git a/keywords.txt b/keywords.txt index 4a2f3bb9..bdde5779 100644 --- a/keywords.txt +++ b/keywords.txt @@ -16,6 +16,7 @@ getAnalogReadBits KEYWORD2 getAnalogWriteBits KEYWORD2 getAnalogReadMaximum KEYWORD2 getAnalogWriteMaximum KEYWORD2 +analogRead_variableGain KEYWORD2 ####################################### # Instances (KEYWORD2) diff --git a/libraries/I2S/README.md b/libraries/I2S/README.md index 0f2500af..3352c5f9 100644 --- a/libraries/I2S/README.md +++ b/libraries/I2S/README.md @@ -35,7 +35,7 @@ The library has been tested with the XMC4700 Relax Kit, XMC1100 XMC 2Go, and XMC `Ensure that level shifting is in place as the microphone board has 3.3 V logic level, XMC1100 Boot Kit has 5 V by default.` -This configuration is defined in `utility\xmc_i2s_conf.h`. +This configuration is defined in the respective board configuration files `pins_arduino.h`. If we take the pin out of XMC for Arduino, the respective pins for SPI are redefined. Therefore, SPI cannot be used anymore in combination with I2S - please keep this in mind. On the other hand, using `SPI.begin()` and `I2S.begin()` will reactivate the original setting and switching between both interfaces is possible on the fly. diff --git a/libraries/I2S/src/I2S.h b/libraries/I2S/src/I2S.h index 71ffa33d..778fb058 100644 --- a/libraries/I2S/src/I2S.h +++ b/libraries/I2S/src/I2S.h @@ -61,9 +61,6 @@ #ifndef I2S_h #define I2S_h -#if defined(XMC4700_Relax_Kit) || defined(XMC1100_XMC2GO) || defined(XMC1100_Boot_Kit) -#include "utility/xmc_i2s_conf.h" - typedef enum { I2S_PHILIPS_MODE, I2S_RIGHT_JUSTIFIED_MODE, @@ -260,8 +257,4 @@ class I2SClass extern I2SClass I2S; -#else -#error "Only XMC4700 Relax Kit, XMC1100 XMC2Go or XMC1100 Boot Kit is supported for I2S" -#endif - #endif /* I2S_h */ diff --git a/libraries/I2S/src/utility/xmc_i2s_conf.c b/libraries/I2S/src/utility/xmc_i2s_conf.c deleted file mode 100644 index b7e98ed2..00000000 --- a/libraries/I2S/src/utility/xmc_i2s_conf.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include "xmc_i2s_conf.h" - -XMC_I2S_t i2s_config = { -#if defined(XMC4700_Relax_Kit) - .input_config = {.mode = XMC_GPIO_MODE_INPUT_TRISTATE, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, - .sclk_config = {.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, - .wa_config = {.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, - .protocol_irq_num = (IRQn_Type)USIC2_2_IRQn, - .protocol_irq_service_request = 2 -#elif defined(XMC1100_XMC2GO) || defined(XMC1100_Boot_Kit) - .input_config = {.input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD, .mode = XMC_GPIO_MODE_INPUT_TRISTATE, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, - .sclk_config = {.input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD, .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, - .wa_config = {.input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD, .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, - .protocol_irq_num = (IRQn_Type)USIC0_2_IRQn, - .protocol_irq_service_request = 2 -#endif -}; \ No newline at end of file diff --git a/libraries/I2S/src/utility/xmc_i2s_conf.h b/libraries/I2S/src/utility/xmc_i2s_conf.h deleted file mode 100644 index 6c649098..00000000 --- a/libraries/I2S/src/utility/xmc_i2s_conf.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - * xmc_i2s_conf.h - Auxiliary file for the I2S library for Arduino. - * - * Have a look at the application note/datasheet for more information. - * - * Copyright (c) 2018 Infineon Technologies AG - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef XMC_I2S_CONF_H -#define XMC_I2S_CONF_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "xmc_i2s.h" - -#define BUFFER_SIZE 512 - -// Only tested with XMC4700 -/*U2C0*/ -/*DX0C -> P3.7*/ -/*SCLKOUT(ALT1) -> P3.9*/ -/*WA(ALT1) -> P3.10*/ -#if defined(XMC4700_Relax_Kit) -#define MASTER_CHANNEL XMC_I2S2_CH0 -// master transmit slave receive -#define MASTER_MTSR PORT3, 8 -// master receive slave transmit -#define MASTER_MRST PORT3, 7 -#define INPUT_SOURCE USIC2_C0_DX0_P3_7 -#define MASTER_SCLK PORT3, 9 -#define MASTER_WACLK PORT3, 10 - -#elif defined(XMC1100_XMC2GO) || defined(XMC1100_Boot_Kit) -/*U0C1*/ -/*DX0C(Input) -> P0.6*/ -/*SCLKOUT(ALT6) -> P0.8*/ -/*WA(ALT6) -> P0.9*/ -#define MASTER_CHANNEL XMC_I2S0_CH1 -#define MASTER_MRST PORT0, 6 -#define INPUT_SOURCE USIC0_C1_DX0_P0_6 -#define MASTER_SCLK PORT0, 8 -#define MASTER_WACLK PORT0, 9 - -#elif defined(XMC1100_Boot_Kit) -/*U0C0*/ -/*DX0C(Input) -> P1.0*/ -/*SCLKOUT(ALT6) -> P0.7*/ -/*WA(ALT6) -> P0.9*/ -#define MASTER_CHANNEL XMC_I2S0_CH0 -#define MASTER_MRST PORT0, 11 -#define INPUT_SOURCE USIC0_C0_DX0_P1_0 -#define MASTER_SCLK PORT0, 7 -#define MASTER_WACLK PORT0, 9 - -#endif - -typedef struct XMC_I2S -{ - XMC_GPIO_CONFIG_t input_config; - XMC_GPIO_CONFIG_t sclk_config; - XMC_GPIO_CONFIG_t wa_config; - IRQn_Type protocol_irq_num; - uint32_t protocol_irq_service_request; -} XMC_I2S_t; - -extern XMC_I2S_t i2s_config; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libraries/LED/Readme.md b/libraries/LED/Readme.md index e8ba79f5..082ca67b 100644 --- a/libraries/LED/Readme.md +++ b/libraries/LED/Readme.md @@ -5,8 +5,8 @@ **Author** | : | Paul Carpenter | | | PC Services | | | www.pcserviceselectronics.co.uk -**Version** | : | V1.0.3 -**Updated** | : | August 2022 +**Version** | : | V1.0.4 +**Updated** | : | March 2023 Date | : | July 2018 Infineon XMC-for-Arduino LED Library, to assist in making board agnostic examples that @@ -42,18 +42,20 @@ models of board so we end up with XMC1100 XMC2GO | High | No | High XMC1100 XMC H Bridge2GO | High| No | High XMC1300 Boot Kit | Low | No | Low - XMC1300 Sense2GOL | Low| No | Low + XMC1300 Sense2GO | Low| No | Low XMC1400 Arduino Kit | Low | Yes | High XMC4200 Platform2Go | High| No | High XMC4400 Platform2Go | High| No | High XMC4700 Relax Kit | High| No | High XMC4700 Relax Kit Lite | High| No | High +** NOTE ** After Version 2.0 of XMC-for-Arduino, some boards were dropped (e.g. XMC1300 Sense2GO) they are still shown here for those using old versions of XMC-for-Arduino, and for history. + [Back to top](#table-of-contents) ### LEDs on Different Boards Matrix of available on board LED names or LED they map to, known currently. -| LED Macro | XMC1100
Boot Kit | XMC1100
XMC2GO | XMC1100
HBRIDGE2GO | XMC1300
Boot Kit | XMC1300
Sense2GOL | XMC1400
Arduino Kit | XMC4200
Platform2Go | XMC4400
Platform2Go | XMC4700
Relax Kit | XMC4700
Relax Kit Lite | +| LED Macro | XMC1100
Boot Kit | XMC1100
XMC2GO | XMC1100
HBRIDGE2GO | XMC1300
Boot Kit | XMC1300
Sense2GO | XMC1400
Arduino Kit | XMC4200
Platform2Go | XMC4400
Platform2Go | XMC4700
Relax Kit | XMC4700
Relax Kit Lite | | --- | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | LED_BUILTIN | Y | LED1 | LED1 | LED1 | LED1 | Y | LED1 | LED1 | LED1 | LED1 LED1 | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y diff --git a/libraries/LED/library.properties b/libraries/LED/library.properties index 9efebbf2..8a6976eb 100644 --- a/libraries/LED/library.properties +++ b/libraries/LED/library.properties @@ -1,6 +1,6 @@ name=LED -version=1.0.3 -author=Infineon Technologies AG +version=1.0.4 +author=Paul Carpenter, PC services, www.pcserviceselectronics.co.uk maintainer=Infineon Technologies AG sentence=This library allows you to enable as well as control the on board LEDs of the XMC microcontrollers. paragraph= This library allows you to enable as well as control the on boards LEDs on Infineon XMC boards, in a way that works across ANY board. diff --git a/libraries/LED/src/LED.cpp b/libraries/LED/src/LED.cpp index 083dcb2d..3f574340 100644 --- a/libraries/LED/src/LED.cpp +++ b/libraries/LED/src/LED.cpp @@ -61,14 +61,28 @@ pinMode( pin, OUTPUT ); /* Set LED On for specified pin */ void LED::On( int pin ) { -digitalWrite( pin, XMC_LED_ON ); +if( pin == LED_BUILTIN ) +#ifdef XMC_LED_BUILTIN_REVERSED + digitalWrite( pin, false ); +#else + digitalWrite( pin, true ); +#endif +else + digitalWrite( pin, XMC_LED_ON ); } /* Set LED Off for specified pin */ void LED::Off( int pin ) { -digitalWrite( pin, !XMC_LED_ON ); +if( pin == LED_BUILTIN ) +#ifdef XMC_LED_BUILTIN_REVERSED + digitalWrite( pin, true ); +#else + digitalWrite( pin, false ); +#endif +else + digitalWrite( pin, !XMC_LED_ON ); } diff --git a/libraries/SPI/src/HW_SPI.cpp b/libraries/SPI/src/HW_SPI.cpp index cb27fac4..ca16c44c 100644 --- a/libraries/SPI/src/HW_SPI.cpp +++ b/libraries/SPI/src/HW_SPI.cpp @@ -99,18 +99,18 @@ void SPIClass::init() /* Configure the data input line selected */ XMC_SPI_CH_SetInputSource(XMC_SPI_config->channel, XMC_SPI_CH_INPUT_DIN0, (uint8_t)XMC_SPI_config->input_source); + /* Start the SPI_Channel */ + XMC_SPI_CH_Start(XMC_SPI_config->channel); + + /* Initialize SPI SCLK out pin */ + XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_SPI_config->sclkout.port, (uint8_t)XMC_SPI_config->sclkout.pin, &(XMC_SPI_config->sclkout_config)); + /* Configure the input pin properties */ XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_SPI_config->miso.port, (uint8_t)XMC_SPI_config->miso.pin, &(XMC_SPI_config->miso_config)); /* Configure the output pin properties */ XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_SPI_config->mosi.port, (uint8_t)XMC_SPI_config->mosi.pin, &(XMC_SPI_config->mosi_config)); - /* Initialize SPI SCLK out pin */ - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_SPI_config->sclkout.port, (uint8_t)XMC_SPI_config->sclkout.pin, &(XMC_SPI_config->sclkout_config)); - - /* Start the SPI_Channel */ - XMC_SPI_CH_Start(XMC_SPI_config->channel); - interruptMode = SPI_IMODE_NONE; interruptSave = 0; interruptMask = 0; @@ -122,28 +122,8 @@ void SPIClass::end() // Only disable HW when USIC is used for SPI if((XMC_SPI_config->channel->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_SPI) { - XMC_GPIO_CONFIG_t default_input_port_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, -#if UC_FAMILY == XMC1 - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD -#endif - }; - - XMC_GPIO_CONFIG_t default_output_port_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL, - .output_level = XMC_GPIO_OUTPUT_LEVEL_LOW, -#if UC_FAMILY == XMC1 - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD -#endif - }; - XMC_SPI_CH_Stop(XMC_SPI_config->channel); - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_SPI_config->miso.port, (uint8_t)XMC_SPI_config->miso.pin, &default_input_port_config); - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_SPI_config->mosi.port, (uint8_t)XMC_SPI_config->mosi.pin, &default_output_port_config); - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_SPI_config->sclkout.port, (uint8_t)XMC_SPI_config->sclkout.pin, &default_output_port_config); - XMC_SPI_config->channel->DXCR[XMC_USIC_CH_INPUT_DX0] = (uint32_t)(XMC_SPI_config->channel->DXCR[XMC_USIC_CH_INPUT_DX0] | (USIC_CH_DX0CR_DSEN_Msk)) & (~USIC_CH_DX0CR_INSW_Msk); XMC_USIC_CH_SetInputSource(XMC_SPI_config->channel, XMC_USIC_CH_INPUT_DX0, XMC_INPUT_A); } diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index b20b3c17..ee23f807 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -59,10 +59,8 @@ #define SPI_CLOCK_DIV128 128 -#if !defined(USE_SW_SPI) -#include "utility/xmc_spi_conf.h" -#else -#include "utility/SW_SPI.h" +#if defined(USE_SW_SPI) +#include "SW_SPI.h" #endif //#define pin_cs 10 diff --git a/libraries/SPI/src/utility/SW_SPI.h b/libraries/SPI/src/SW_SPI.h similarity index 100% rename from libraries/SPI/src/utility/SW_SPI.h rename to libraries/SPI/src/SW_SPI.h diff --git a/libraries/SPI/src/utility/xmc_spi_conf.c b/libraries/SPI/src/utility/xmc_spi_conf.c deleted file mode 100644 index 9f0557ec..00000000 --- a/libraries/SPI/src/utility/xmc_spi_conf.c +++ /dev/null @@ -1,417 +0,0 @@ -/** - * xmc_spi_conf.c - Utility file for the SPI library. - * - * Copyright (c) 2018 Infineon Technologies AG - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//**************************************************************************** -// @Project Includes -//**************************************************************************** -#include "xmc_spi_conf.h" - -#if defined(XMC1100_XMC2GO) -XMC_SPI_t XMC_SPI_0 = -{ - .channel = XMC_SPI0_CH1, - .channel_config = { - .baudrate = 15984375U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)7 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)6 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source = XMC_INPUT_C, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)8 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - } -}; - -#elif defined(XMC1100_Boot_Kit) || defined(XMC1300_Boot_Kit) || defined(XMC1400_Boot_Kit) -XMC_SPI_t XMC_SPI_0 = -{ - .channel = XMC_SPI0_CH0, - .channel_config = { - .baudrate = 15984375U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT1_BASE, - .pin = (uint8_t)1 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT1_BASE, - .pin = (uint8_t)0 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source = XMC_INPUT_C, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)7 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - } -}; - -#elif defined(XMC1400_Arduino_Kit) -XMC_SPI_t XMC_SPI_0 = -{ - .channel = XMC_SPI1_CH1, - .channel_config = { - .baudrate = 15984375U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)1 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT9, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)0 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source = XMC_INPUT_A, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)3 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT8, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - } -}; - - -#elif defined(XMC4400_Platform2GO) -XMC_SPI_t XMC_SPI_0 = -{ - .channel = XMC_SPI1_CH1, - .channel_config = { - .baudrate = 20003906U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT1_BASE, - .pin = (uint8_t)9 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)0 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - }, - .input_source = XMC_INPUT_D, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT1_BASE, - .pin = (uint8_t)8 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, -}; - -#elif defined(XMC4200_Platform2GO) -XMC_SPI_t XMC_SPI_0 = -{ - .channel = XMC_SPI1_CH1, - .channel_config = { - .baudrate = 20003906U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT1_BASE, - .pin = (uint8_t)9 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)0 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - }, - .input_source = XMC_INPUT_D, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT1_BASE, - .pin = (uint8_t)8 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, -}; - -#elif defined(XMC4700_Relax_Kit) -XMC_SPI_t XMC_SPI_0 = -{ - .channel = XMC_SPI2_CH0, - .channel_config = { - .baudrate = 20003906U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)8 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)7 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - }, - .input_source = XMC_INPUT_C, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)9 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, -}; - -XMC_SPI_t XMC_SPI_1 = -{ - .channel = XMC_SPI0_CH1, - .channel_config = { - .baudrate = 20003906U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)5 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT4_BASE, - .pin = (uint8_t)0 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - }, - .input_source = XMC_INPUT_E, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)6 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, -}; - -XMC_SPI_t XMC_SPI_2 = -{ - .channel = XMC_SPI2_CH1, - .channel_config = { - .baudrate = 20003906U, - .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, - .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, - .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE - }, - .mosi = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)11 - }, - .mosi_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, - .miso = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)12 - }, - .miso_config = { - .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - }, - .input_source = XMC_INPUT_D, - .sclkout = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)13 - }, - .sclkout_config = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM - }, -}; - -// Will overwrite Serial -//XMC_SPI_t XMC_SPI_3 = -//{ -// .channel = XMC_SPI0_CH0, -// .channel_config = { -// .baudrate = 20003906U, -// .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, -// .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, -// .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE -// }, -// .mosi = { -// .port = (XMC_GPIO_PORT_t*)PORT5_BASE, -// .pin = (uint8_t)1 -// }, -// .mosi_config = { -// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, -// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, -// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM -// }, -// .miso = { -// .port = (XMC_GPIO_PORT_t*)PORT5_BASE, -// .pin = (uint8_t)0 -// }, -// .miso_config = { -// .mode = XMC_GPIO_MODE_INPUT_TRISTATE, -// }, -// .input_source = XMC_INPUT_D, -// .sclkout = { -// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, -// .pin = (uint8_t)8 -// }, -// .sclkout_config = { -// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, -// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, -// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM -// }, -//}; - -// Will overwrite Serial1 -//XMC_SPI_t XMC_SPI_4 = -//{ -// .channel = XMC_SPI1_CH0, -// .channel_config = { -// .baudrate = 20003906U, -// .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, -// .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, -// .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE -// }, -// .mosi = { -// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, -// .pin = (uint8_t)5 -// }, -// .mosi_config = { -// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, -// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, -// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM -// }, -// .miso = { -// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, -// .pin = (uint8_t)4 -// }, -// .miso_config = { -// .mode = XMC_GPIO_MODE_INPUT_TRISTATE, -// }, -// .input_source = XMC_INPUT_A, -// .sclkout = { -// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, -// .pin = (uint8_t)11 -// }, -// .sclkout_config = { -// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, -// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, -// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM -// }, -//}; -#endif - -//**************************************************************************** -// END OF FILE -//**************************************************************************** diff --git a/libraries/SPI/src/utility/xmc_spi_conf.h b/libraries/SPI/src/utility/xmc_spi_conf.h deleted file mode 100644 index 440b0e7f..00000000 --- a/libraries/SPI/src/utility/xmc_spi_conf.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * xmc_spi_conf.h - Utility file for the SPI library. - * - * Copyright (c) 2018 Infineon Technologies AG - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef XMC_SPI_CONF_H -#define XMC_SPI_CONF_H - -//**************************************************************************** -// @Project Includes -//**************************************************************************** -#include -#include - -//**************************************************************************** -// @Typedefs -//**************************************************************************** - -typedef struct XMC_SPI -{ - XMC_USIC_CH_t* channel ; - XMC_SPI_CH_CONFIG_t channel_config ; - XMC_PORT_PIN_t mosi ; - XMC_GPIO_CONFIG_t mosi_config ; - XMC_PORT_PIN_t miso ; - XMC_GPIO_CONFIG_t miso_config ; - XMC_USIC_INPUT_t input_source ; - XMC_PORT_PIN_t sclkout ; - XMC_GPIO_CONFIG_t sclkout_config ; -} XMC_SPI_t; - -#define XMC_SPI_default XMC_SPI_0 - -#if defined(XMC1100_XMC2GO) -#define NUM_SPI 1 -extern XMC_SPI_t XMC_SPI_0; - -#elif defined(XMC1100_Boot_Kit) || defined(XMC1300_Boot_Kit) || defined(XMC1400_Boot_Kit) -#define NUM_SPI 1 -extern XMC_SPI_t XMC_SPI_0; - -#elif defined(XMC1400_Arduino_Kit) -#define NUM_SPI 1 -extern XMC_SPI_t XMC_SPI_0; - -#elif defined(XMC4400_Platform2GO) -#define NUM_SPI 1 -extern XMC_SPI_t XMC_SPI_0; - -#elif defined(XMC4200_Platform2GO) -#define NUM_SPI 1 -extern XMC_SPI_t XMC_SPI_0; - -#elif defined(XMC4700_Relax_Kit) -#define NUM_SPI 3 -#define XMC_SPI_for_xmc_SD XMC_SPI_1 -extern XMC_SPI_t XMC_SPI_0; -extern XMC_SPI_t XMC_SPI_1; -extern XMC_SPI_t XMC_SPI_2; -//extern XMC_SPI_t XMC_SPI_3; -//extern XMC_SPI_t XMC_SPI_4; -#else -#error XMC Board not supported -#endif - - -#endif /* XMC_SPI_CONF_H */ diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 3f5287f8..94baa2a3 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -96,10 +96,7 @@ void TwoWire::begin(void) 0, XMC_USIC_CH_FIFO_SIZE_16WORDS, (uint32_t)(15)); - - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->sda.port, (uint8_t)XMC_I2C_config->sda.pin, &(XMC_I2C_config->sda_config)); - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->scl.port, (uint8_t)XMC_I2C_config->scl.pin, &(XMC_I2C_config->scl_config)); - + XMC_USIC_CH_SetInterruptNodePointer(XMC_I2C_config->channel, XMC_USIC_CH_INTERRUPT_NODE_POINTER_PROTOCOL, XMC_I2C_config->protocol_irq_service_request); @@ -109,6 +106,9 @@ void TwoWire::begin(void) XMC_I2C_CH_EnableEvent(XMC_I2C_config->channel, (uint32_t)(XMC_I2C_CH_EVENT_NACK | XMC_I2C_CH_EVENT_DATA_LOST | XMC_I2C_CH_EVENT_ARBITRATION_LOST | XMC_I2C_CH_EVENT_ERROR)); 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)); + XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->scl.port, (uint8_t)XMC_I2C_config->scl.pin, &(XMC_I2C_config->scl_config)); } void TwoWire::begin(uint8_t address) @@ -126,9 +126,6 @@ void TwoWire::begin(uint8_t address) 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_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->sda.port, (uint8_t)XMC_I2C_config->sda.pin, &(XMC_I2C_config->sda_config)); - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->scl.port, (uint8_t)XMC_I2C_config->scl.pin, &(XMC_I2C_config->scl_config)); - XMC_USIC_CH_SetInterruptNodePointer(XMC_I2C_config->channel, XMC_USIC_CH_INTERRUPT_NODE_POINTER_RECEIVE, XMC_I2C_config->slave_receive_irq_service_request); @@ -154,6 +151,9 @@ void TwoWire::begin(uint8_t address) XMC_I2C_CH_EnableEvent(XMC_I2C_config->channel, (uint32_t)((uint32_t)XMC_I2C_CH_EVENT_SLAVE_READ_REQUEST | (uint32_t)XMC_I2C_CH_EVENT_STOP_CONDITION_RECEIVED)); 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)); + XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->scl.port, (uint8_t)XMC_I2C_config->scl.pin, &(XMC_I2C_config->scl_config)); } void TwoWire::begin(int address) @@ -166,19 +166,7 @@ void TwoWire::end(void) // Only disable HW when USIC is used for I2C if((XMC_I2C_config->channel->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_I2C) { - - XMC_GPIO_CONFIG_t default_output_port_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, -#if UC_FAMILY == XMC1 - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD -#endif - }; - - XMC_I2C_CH_Stop(XMC_I2C_config->channel); - - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->sda.port, (uint8_t)XMC_I2C_config->sda.pin, &default_output_port_config); - XMC_GPIO_Init((XMC_GPIO_PORT_t*)XMC_I2C_config->scl.port, (uint8_t)XMC_I2C_config->scl.pin, &default_output_port_config); + XMC_I2C_CH_Stop(XMC_I2C_config->channel); XMC_USIC_CH_SetInputSource(XMC_I2C_config->channel, XMC_USIC_CH_INPUT_DX0, XMC_INPUT_A); XMC_USIC_CH_SetInputSource(XMC_I2C_config->channel, XMC_USIC_CH_INPUT_DX1, XMC_INPUT_A); diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index b23508de..9c36ae1a 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -29,7 +29,6 @@ // @Project Includes //**************************************************************************** #include -#include "utility/xmc_i2c_conf.h" //**************************************************************************** // @Defines diff --git a/libraries/Wire/src/utility/xmc_i2c_conf.c b/libraries/Wire/src/utility/xmc_i2c_conf.c deleted file mode 100644 index 4ad905ec..00000000 --- a/libraries/Wire/src/utility/xmc_i2c_conf.c +++ /dev/null @@ -1,298 +0,0 @@ -/** - * xmc_i2c_conf.c - Utility file for the I2C/Wire library. - * - * Copyright (c) 2018 Infineon Technologies AG - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//**************************************************************************** -// @Project Includes -//**************************************************************************** -#include "xmc_i2c_conf.h" - -#if defined(XMC1100_XMC2GO) -XMC_I2C_t XMC_I2C_0 = -{ - .channel = XMC_I2C0_CH1, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)10 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)11 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source_dx0 = XMC_INPUT_F, - .input_source_dx1 = XMC_INPUT_E, - .slave_receive_irq_num = (IRQn_Type) USIC0_4_IRQn, - .slave_receive_irq_service_request = 4 , - .protocol_irq_num = (IRQn_Type) USIC0_5_IRQn, - .protocol_irq_service_request = 5 -}; - -XMC_I2C_t XMC_I2C_1 = -{ - .channel = XMC_I2C0_CH0, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)15 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)14 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source_dx0 = XMC_INPUT_B, - .input_source_dx1 = XMC_INPUT_A, - .slave_receive_irq_num = (IRQn_Type) USIC0_2_IRQn, - .slave_receive_irq_service_request = 2 , - .protocol_irq_num = (IRQn_Type) USIC0_3_IRQn, - .protocol_irq_service_request = 3 -}; - -#elif defined(XMC1100_Boot_Kit) || defined(XMC1300_Boot_Kit) || defined(XMC1400_Boot_Kit) -XMC_I2C_t XMC_I2C_0 = -{ - .channel = XMC_I2C0_CH0, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)1 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)0 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source_dx0 = XMC_INPUT_F, - .input_source_dx1 = XMC_INPUT_E, - .slave_receive_irq_num = (IRQn_Type) USIC0_4_IRQn, - .slave_receive_irq_service_request = 4 , - .protocol_irq_num = (IRQn_Type) USIC0_5_IRQn, - .protocol_irq_service_request = 5 -}; - -#elif defined(XMC1400_Arduino_Kit) -XMC_I2C_t XMC_I2C_0 = -{ - .channel = XMC_I2C0_CH0, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)1 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)0 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source_dx0 = XMC_INPUT_F, - .input_source_dx1 = XMC_INPUT_E, - .slave_receive_irq_num = (IRQn_Type) USIC0_4_IRQn, - .slave_receive_irq_service_request = 4 , - .protocol_irq_num = (IRQn_Type) USIC0_5_IRQn, - .protocol_irq_service_request = 5 -}; - - -#elif defined (XMC4400_Platform2GO) -XMC_I2C_t XMC_I2C_0 = -{ - .channel = XMC_I2C0_CH1, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)5 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)0 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .input_source_dx0 = XMC_INPUT_B, - .input_source_dx1 = XMC_INPUT_B, - .slave_receive_irq_num = (IRQn_Type) 91, - .slave_receive_irq_service_request = 1 , - .protocol_irq_num = (IRQn_Type) 92, - .protocol_irq_service_request = 2 -}; - -#elif defined (XMC4200_Platform2GO) -XMC_I2C_t XMC_I2C_0 = -{ - .channel = XMC_I2C0_CH1, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT2_BASE, - .pin = (uint8_t)5 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)0 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .input_source_dx0 = XMC_INPUT_B, - .input_source_dx1 = XMC_INPUT_B, - .slave_receive_irq_num = (IRQn_Type) 84, - .slave_receive_irq_service_request = 1 , - .protocol_irq_num = (IRQn_Type) 85, - .protocol_irq_service_request = 2 -}; - - -#elif defined(XMC4700_Relax_Kit) -XMC_I2C_t XMC_I2C_0 = -{ - .channel = XMC_I2C1_CH1, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT3_BASE, - .pin = (uint8_t)15 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)13 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .input_source_dx0 = XMC_INPUT_A, - .input_source_dx1 = XMC_INPUT_B, - .slave_receive_irq_num = (IRQn_Type) 91, - .slave_receive_irq_service_request = 1 , - .protocol_irq_num = (IRQn_Type) 92, - .protocol_irq_service_request = 2 -}; -XMC_I2C_t XMC_I2C_1 = -{ - .channel = XMC_I2C1_CH0, - .channel_config = { - .baudrate = (uint32_t)(100000U), - .address = 0U - }, - .sda = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)5 - }, - .sda_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .scl = { - .port = (XMC_GPIO_PORT_t*)PORT0_BASE, - .pin = (uint8_t)11 - }, - .scl_config = { - .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH - }, - .input_source_dx0 = XMC_INPUT_B, - .input_source_dx1 = XMC_INPUT_A, - .slave_receive_irq_num = (IRQn_Type) 93, - .slave_receive_irq_service_request = 3 , - .protocol_irq_num = (IRQn_Type) 94, - .protocol_irq_service_request = 4 -}; -#endif - -//**************************************************************************** -// END OF FILE -//**************************************************************************** diff --git a/libraries/Wire/src/utility/xmc_i2c_conf.h b/libraries/Wire/src/utility/xmc_i2c_conf.h deleted file mode 100644 index 936d5284..00000000 --- a/libraries/Wire/src/utility/xmc_i2c_conf.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * xmc_i2c_conf.h - Utility file for the I2C/Wire library. - * - * Copyright (c) 2018 Infineon Technologies AG - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef XMC_I2C_CONF_H -#define XMC_I2C_CONF_H - -//**************************************************************************** -// @Project Includes -//**************************************************************************** -#include -#include - - -//**************************************************************************** -// @Typedefs -//**************************************************************************** -typedef struct XMC_I2C -{ - XMC_USIC_CH_t* channel; - XMC_I2C_CH_CONFIG_t channel_config; - XMC_PORT_PIN_t sda; - XMC_GPIO_CONFIG_t sda_config; - XMC_PORT_PIN_t scl; - XMC_GPIO_CONFIG_t scl_config; - XMC_USIC_INPUT_t input_source_dx0; - XMC_USIC_INPUT_t input_source_dx1; - IRQn_Type slave_receive_irq_num; - uint32_t slave_receive_irq_service_request; - IRQn_Type protocol_irq_num; - uint32_t protocol_irq_service_request; -} XMC_I2C_t; - -#define XMC_I2C_default XMC_I2C_0 - -#if defined(XMC1100_XMC2GO) -#define NUM_I2C 2 -extern XMC_I2C_t XMC_I2C_0; -extern XMC_I2C_t XMC_I2C_1; - -#elif defined(XMC1100_Boot_Kit) || defined(XMC1300_Boot_Kit) || defined(XMC1400_Boot_Kit) -#define NUM_I2C 1 -extern XMC_I2C_t XMC_I2C_0; - -#elif defined(XMC1400_Arduino_Kit) -#define NUM_I2C 1 -extern XMC_I2C_t XMC_I2C_0; - -#elif defined(XMC4400_Platform2GO) -#define NUM_I2C 1 -extern XMC_I2C_t XMC_I2C_0; - -#elif defined(XMC4200_Platform2GO) -#define NUM_I2C 1 -extern XMC_I2C_t XMC_I2C_0; - -#elif defined(XMC4700_Relax_Kit) -#define NUM_I2C 2 -extern XMC_I2C_t XMC_I2C_0; -extern XMC_I2C_t XMC_I2C_1; - - -#else -#error XMC Board not supported -#endif - -#endif /* XMC_I2C_CONF_H */ diff --git a/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h b/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h index 73973ecf..e8eb4787 100644 --- a/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h +++ b/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h @@ -50,6 +50,8 @@ extern const uint8_t NUM_ANALOG_INPUTS; #define NUM_SERIAL 1 #define NUM_TONE_PINS 4 #define NUM_TASKS_VARIANT 8 +#define NUM_SPI 1 +#define NUM_I2C 1 // Indicate unit has RTC/Alarm for simpler RTC control #define HAS_RTC @@ -83,6 +85,29 @@ extern uint8_t MOSI; extern uint8_t MISO; extern uint8_t SCK; +// XMC_I2S defines +/*U0C1*/ +/*DX0C(Input) -> P0.6*/ +/*SCLKOUT(ALT6) -> P0.8*/ +/*WA(ALT6) -> P0.9*/ +#define MASTER_CHANNEL XMC_I2S0_CH1 +#define MASTER_MRST PORT0, 6 +#define INPUT_SOURCE USIC0_C1_DX0_P0_6 +#define MASTER_SCLK PORT0, 8 +#define MASTER_WACLK PORT0, 9 + +// Uncomment this to use the second I2S interface, +// uses some of the same pins as SPI! +// /*U0C0*/ +// /*DX0C(Input) -> P1.0*/ +// /*SCLKOUT(ALT6) -> P0.7*/ +// /*WA(ALT6) -> P0.9*/ +// #define MASTER_CHANNEL XMC_I2S0_CH0 +// #define MASTER_MRST PORT0, 11 +// #define INPUT_SOURCE USIC0_C0_DX0_P1_0 +// #define MASTER_SCLK PORT0, 7 +// #define MASTER_WACLK PORT0, 9 + #define A0 0 #define A1 1 #define A2 2 @@ -170,6 +195,7 @@ const uint8_t mapping_pin_PWM4[][ 2 ] = { { 9, 3 }, { 10, 4 }, { 11, 5 }, + { 20, 6 }, { 255, 255 } }; /* Configurations of PWM channels for CCU4 type */ @@ -180,7 +206,8 @@ XMC_PWM4_t mapping_pwm4[] = {CCU40, CCU40_CC43, 3, mapping_port_pin[6], P0_3_AF_CCU40_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 6 P0.3 {CCU40, CCU40_CC42, 2, mapping_port_pin[9], P0_8_AF_CCU40_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 9 P0.8 {CCU40, CCU40_CC43, 3, mapping_port_pin[10], P0_9_AF_CCU40_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 10 P0.9 - {CCU40, CCU40_CC41, 1, mapping_port_pin[11], P1_1_AF_CCU40_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED} // PWM disabled 11 P1.1 + {CCU40, CCU40_CC41, 1, mapping_port_pin[11], P1_1_AF_CCU40_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 11 P1.1 + {CCU40, CCU40_CC42, 2, mapping_port_pin[20], P2_10_AF_CCU40_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED} // PWM disabled 20 P2.10 }; const uint8_t NUM_PWM = ( sizeof( mapping_pwm4 ) / sizeof( XMC_PWM4_t ) ); const uint8_t NUM_PWM4 = ( sizeof( mapping_pwm4 ) / sizeof( XMC_PWM4_t ) ); @@ -245,6 +272,101 @@ XMC_UART_t XMC_UART_0 = HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); +// SPI instance +XMC_SPI_t XMC_SPI_0 = +{ + .channel = XMC_SPI0_CH0, + .channel_config = { + .baudrate = 15984375U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)1 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)0 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source = XMC_INPUT_C, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)7 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + } +}; + +//I2C instance +XMC_I2C_t XMC_I2C_0 = +{ + .channel = XMC_I2C0_CH0, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)1 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)0 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source_dx0 = XMC_INPUT_F, + .input_source_dx1 = XMC_INPUT_E, + .slave_receive_irq_num = (IRQn_Type) USIC0_4_IRQn, + .slave_receive_irq_service_request = 4 , + .protocol_irq_num = (IRQn_Type) USIC0_5_IRQn, + .protocol_irq_service_request = 5 +}; + +// XMC_I2S instance +XMC_I2S_t i2s_config = +{ + .input_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .sclk_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .wa_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .protocol_irq_num = (IRQn_Type) USIC0_2_IRQn, + .protocol_irq_service_request = 2 +}; + // Serial Interrupt and event handling #ifdef __cplusplus extern "C" { diff --git a/variants/XMC1100/config/XMC1100_XMC2GO/pins_arduino.h b/variants/XMC1100/config/XMC1100_XMC2GO/pins_arduino.h index ade4a129..8afaa445 100644 --- a/variants/XMC1100/config/XMC1100_XMC2GO/pins_arduino.h +++ b/variants/XMC1100/config/XMC1100_XMC2GO/pins_arduino.h @@ -53,6 +53,8 @@ extern const uint8_t NUM_ANALOG_INPUTS; #define NUM_SERIAL 1 #define NUM_TONE_PINS 4 #define NUM_TASKS_VARIANT 8 +#define NUM_SPI 1 +#define NUM_I2C 2 // Indicate unit has RTC/Alarm #define HAS_RTC 1 @@ -83,6 +85,17 @@ extern uint8_t MOSI; extern uint8_t MISO; extern uint8_t SCK; +// XMC_I2S defines +/*U0C1*/ +/*DX0C(Input) -> P0.6*/ +/*SCLKOUT(ALT6) -> P0.8*/ +/*WA(ALT6) -> P0.9*/ +#define MASTER_CHANNEL XMC_I2S0_CH1 +#define MASTER_MRST PORT0, 6 +#define INPUT_SOURCE USIC0_C1_DX0_P0_6 +#define MASTER_SCLK PORT0, 8 +#define MASTER_WACLK PORT0, 9 + #define A0 0 #define A1 1 #define A2 2 @@ -201,10 +214,138 @@ XMC_UART_t XMC_UART_0 = #endif .irq_num = USIC0_0_IRQn, .irq_service_request = 0 - }; + }; HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); +// SPI instance +XMC_SPI_t XMC_SPI_0 = +{ + .channel = XMC_SPI0_CH1, + .channel_config = { + .baudrate = 15984375U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)7 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)6 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source = XMC_INPUT_C, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)8 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + } +}; + +// Two I2C instances possible +XMC_I2C_t XMC_I2C_0 = +{ + .channel = XMC_I2C0_CH1, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)10 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)11 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source_dx0 = XMC_INPUT_F, + .input_source_dx1 = XMC_INPUT_E, + .slave_receive_irq_num = (IRQn_Type) USIC0_4_IRQn, + .slave_receive_irq_service_request = 4 , + .protocol_irq_num = (IRQn_Type) USIC0_5_IRQn, + .protocol_irq_service_request = 5 +}; + +XMC_I2C_t XMC_I2C_1 = +{ + .channel = XMC_I2C0_CH0, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)15 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)14 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source_dx0 = XMC_INPUT_B, + .input_source_dx1 = XMC_INPUT_A, + .slave_receive_irq_num = (IRQn_Type) USIC0_2_IRQn, + .slave_receive_irq_service_request = 2 , + .protocol_irq_num = (IRQn_Type) USIC0_3_IRQn, + .protocol_irq_service_request = 3 +}; + +// XMC_I2S instance +XMC_I2S_t i2s_config = +{ + .input_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .sclk_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .wa_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .protocol_irq_num = (IRQn_Type) USIC0_2_IRQn, + .protocol_irq_service_request = 2 +}; + // Serial Interrupt and event handling #ifdef __cplusplus extern "C" { diff --git a/variants/XMC1300/config/XMC1300_Boot_Kit/pins_arduino.h b/variants/XMC1300/config/XMC1300_Boot_Kit/pins_arduino.h index 8a866af5..85b17a49 100755 --- a/variants/XMC1300/config/XMC1300_Boot_Kit/pins_arduino.h +++ b/variants/XMC1300/config/XMC1300_Boot_Kit/pins_arduino.h @@ -40,6 +40,8 @@ /* On board LED is ON when digital output is 0, LOW, False, OFF */ #define XMC_LED_ON 0 +/* On board LED_BUILTIN is NOT standard LED is ON when digital output is 0, LOW, False, OFF */ +#define XMC_LED_BUILTIN_REVERSED 1 // Following were defines now evaluated by compilation as const variables // After definitions of associated mapping arrays @@ -54,6 +56,8 @@ extern const uint8_t NUM_ANALOG_INPUTS; #define NUM_SERIAL 1 #define NUM_TONE_PINS 4 #define NUM_TASKS_VARIANT 8 +#define NUM_SPI 1 +#define NUM_I2C 1 // Indicate unit has RTC/Alarm #define HAS_RTC 1 @@ -267,6 +271,79 @@ XMC_UART_t XMC_UART_0 = HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); +//SPI instance +XMC_SPI_t XMC_SPI_0 = +{ + .channel = XMC_SPI0_CH0, + .channel_config = { + .baudrate = 15984375U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)1 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)0 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source = XMC_INPUT_C, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)7 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + } +}; + +//I2C instance +XMC_I2C_t XMC_I2C_0 = +{ + .channel = XMC_I2C0_CH0, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)1 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)0 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source_dx0 = XMC_INPUT_F, + .input_source_dx1 = XMC_INPUT_E, + .slave_receive_irq_num = (IRQn_Type) USIC0_4_IRQn, + .slave_receive_irq_service_request = 4 , + .protocol_irq_num = (IRQn_Type) USIC0_5_IRQn, + .protocol_irq_service_request = 5 +}; + // Serial Interrupt and event handling #ifdef __cplusplus extern "C" { diff --git a/variants/XMC1300/linker_script_128k.ld b/variants/XMC1300/linker_script_128k.ld deleted file mode 100755 index 8e2773c6..00000000 --- a/variants/XMC1300/linker_script_128k.ld +++ /dev/null @@ -1,288 +0,0 @@ -/** - * @file XMC1300x0128.ld - * @date 2021-01-11 - ~ - * @cond - ********************************************************************************************************************* - * Linker file for the GNU C Compiler v1.10 - * Supported devices: XMC130x-ANY package with 128kB Flash and 16kB RAM - * - * Updated January 2021 for any 128kB Flash device - * - * Copyright (c) 2015-2016, Infineon Technologies AG - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with - * Infineon Technologies AG dave@infineon.com). - ********************************************************************************************************************* - * - * Change History - * -------------- - * - * 2015-07-07: - * - Product splitting - * - Copyright notice update - * - * 2015-11-24: - * - Compatibility with GCC 4.9 2015q2 - * - * 2016-03-15: - * - Add assertion to check that region SRAM_combined does not overflowed no_init section - * - * 2016-06-07: - * - Add XMC1302-Q040X0200 - * - * 2018-03-08: - * - Change default XMC1xxx stack size - * - Move Stack to top of RAM below no_init for more standard and safer location - * - Could mean startup_XMC1xxx.S could be shortened - * - * 2021-01-11: - * - Split script to different flash size files for Boot Kit and Sense2GoL - * - * @endcond - * - */ - -OUTPUT_FORMAT("elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(Reset_Handler) - -MEMORY -{ - FLASH(RX) : ORIGIN = 0x10001000, LENGTH = 0x20000 - SRAM(!RX) : ORIGIN = 0x20000000, LENGTH = 0x4000 -} - -stack_size = DEFINED(stack_size) ? stack_size : 1024; -no_init_size = 4; - -SECTIONS -{ - /* TEXT section */ - - .text : - { - sText = .; - KEEP(*(.reset)); - *(.text .text.* .gnu.linkonce.t.*); - - /* C++ Support */ - KEEP(*(.init)) - KEEP(*(.fini)) - - /* .ctors */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - - /* .dtors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.rodata .rodata.*) - *(.gnu.linkonce.r*) - . = ALIGN(4); - } > FLASH - - .eh_frame_hdr : ALIGN (4) - { - KEEP (*(.eh_frame_hdr)) - } > FLASH - - .eh_frame : ALIGN (4) - { - KEEP (*(.eh_frame)) - } > FLASH - - /* Exception handling, exidx needs a dedicated section */ - .ARM.extab : ALIGN(4) - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - . = ALIGN(4); - __exidx_start = .; - .ARM.exidx : ALIGN(4) - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - . = ALIGN(4); - - /* End of RO-DATA and start of LOAD region for the veneers */ - eROData = . ; - - /* DSRAM layout (Lowest to highest)*/ - /* Veneer <-> DATA <-> ram_code <-> BSS <-> HEAP <-> memory gap <-> Stack <-> no_init */ - - .VENEER_Code ABSOLUTE(0x2000000C): AT(eROData) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - VeneerStart = .; - KEEP(*(.XmcVeneerCode)); - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - VeneerEnd = .; - } > SRAM - - VeneerSize = ABSOLUTE(VeneerEnd) - ABSOLUTE(VeneerStart); - - /* Standard DATA and user defined DATA/BSS/CONST sections */ - DataLoadAddr = eROData + VeneerSize; - .data : AT(DataLoadAddr) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __data_start = .; - *(vtable) - * (.data); - * (.data*); - *(*.data); - *(.gnu.linkonce.d*) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __data_end = .; - } > SRAM - __data_size = __data_end - __data_start; - - .ram_code : AT(DataLoadAddr + __data_size) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __ram_code_start = .; - /* functions with __attribute__ ((section (".ram_code")))*/ - *(.ram_code) - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __ram_code_end = .; - } > SRAM - __ram_code_load = LOADADDR (.ram_code); - __ram_code_size = __ram_code_end - __ram_code_start; - - /* BSS section */ - .bss (NOLOAD) : - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __bss_start = .; - * (.bss); - * (.bss*); - * (COMMON); - *(.gnu.linkonce.b*) - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __bss_end = .; - Heap_Bank1_Start = .; - } > SRAM - __bss_size = __bss_end - __bss_start; - - _stack_begin = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); - - /* Dummy section for stack */ - Stack _stack_begin (NOLOAD) : - { - . = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); - Heap_Bank1_End = .; - end = Heap_Bank1_End; - __stack_start = .; - . = . + stack_size; - __stack_end = .; - __initial_sp = .; - } > SRAM - - /* Heap - Bank1*/ - - Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; - - ASSERT(Heap_Bank1_Start <= Heap_Bank1_End, "bss section SRAM overflowed stack section") - - /* .no_init section contains SystemCoreClock. See system_XMC_xxxx.c file */ - .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : - { - * (.no_init); - } > SRAM - - - /DISCARD/ : - { - *(.comment) - } - - .stab 0 (NOLOAD) : { *(.stab) } - .stabstr 0 (NOLOAD) : { *(.stabstr) } - - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_pubtypes 0 : { *(.debug_pubtypes) } - - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - - /* DWARF 2.1 */ - .debug_ranges 0 : { *(.debug_ranges) } - - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - - /* Build attributes */ - .build_attributes 0 : { *(.ARM.attributes) } -} diff --git a/variants/XMC1300/linker_script_32k.ld b/variants/XMC1300/linker_script_32k.ld deleted file mode 100755 index 4520c188..00000000 --- a/variants/XMC1300/linker_script_32k.ld +++ /dev/null @@ -1,288 +0,0 @@ -/** - * @file XMC1300x0032.ld - * @date 2021-01-11 - ~ - * @cond - ********************************************************************************************************************* - * Linker file for the GNU C Compiler v1.10 - * Supported devices: XMC130x-ANY package with 32kB Flash and 16kB RAM - * - * Updated January 2021 for any 32kB Flash device - * - * Copyright (c) 2015-2016, Infineon Technologies AG - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with - * Infineon Technologies AG dave@infineon.com). - ********************************************************************************************************************* - * - * Change History - * -------------- - * - * 2015-07-07: - * - Product splitting - * - Copyright notice update - * - * 2015-11-24: - * - Compatibility with GCC 4.9 2015q2 - * - * 2016-03-15: - * - Add assertion to check that region SRAM_combined does not overflowed no_init section - * - * 2016-06-07: - * - Add XMC1302-Q040X0200 - * - * 2018-03-08: - * - Change default XMC1xxx stack size - * - Move Stack to top of RAM below no_init for more standard and safer location - * - Could mean startup_XMC1xxx.S could be shortened - * - * 2021-01-11: - * - Split script to different flash size files for Boot Kit and Sense2GoL - * - * @endcond - * - */ - -OUTPUT_FORMAT("elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(Reset_Handler) - -MEMORY -{ - FLASH(RX) : ORIGIN = 0x10001000, LENGTH = 0x8000 - SRAM(!RX) : ORIGIN = 0x20000000, LENGTH = 0x4000 -} - -stack_size = DEFINED(stack_size) ? stack_size : 1024; -no_init_size = 4; - -SECTIONS -{ - /* TEXT section */ - - .text : - { - sText = .; - KEEP(*(.reset)); - *(.text .text.* .gnu.linkonce.t.*); - - /* C++ Support */ - KEEP(*(.init)) - KEEP(*(.fini)) - - /* .ctors */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - - /* .dtors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.rodata .rodata.*) - *(.gnu.linkonce.r*) - . = ALIGN(4); - } > FLASH - - .eh_frame_hdr : ALIGN (4) - { - KEEP (*(.eh_frame_hdr)) - } > FLASH - - .eh_frame : ALIGN (4) - { - KEEP (*(.eh_frame)) - } > FLASH - - /* Exception handling, exidx needs a dedicated section */ - .ARM.extab : ALIGN(4) - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - . = ALIGN(4); - __exidx_start = .; - .ARM.exidx : ALIGN(4) - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - . = ALIGN(4); - - /* End of RO-DATA and start of LOAD region for the veneers */ - eROData = . ; - - /* DSRAM layout (Lowest to highest)*/ - /* Veneer <-> DATA <-> ram_code <-> BSS <-> HEAP <-> memory gap <-> Stack <-> no_init */ - - .VENEER_Code ABSOLUTE(0x2000000C): AT(eROData) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - VeneerStart = .; - KEEP(*(.XmcVeneerCode)); - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - VeneerEnd = .; - } > SRAM - - VeneerSize = ABSOLUTE(VeneerEnd) - ABSOLUTE(VeneerStart); - - /* Standard DATA and user defined DATA/BSS/CONST sections */ - DataLoadAddr = eROData + VeneerSize; - .data : AT(DataLoadAddr) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __data_start = .; - *(vtable) - * (.data); - * (.data*); - *(*.data); - *(.gnu.linkonce.d*) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __data_end = .; - } > SRAM - __data_size = __data_end - __data_start; - - .ram_code : AT(DataLoadAddr + __data_size) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __ram_code_start = .; - /* functions with __attribute__ ((section (".ram_code")))*/ - *(.ram_code) - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __ram_code_end = .; - } > SRAM - __ram_code_load = LOADADDR (.ram_code); - __ram_code_size = __ram_code_end - __ram_code_start; - - /* BSS section */ - .bss (NOLOAD) : - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __bss_start = .; - * (.bss); - * (.bss*); - * (COMMON); - *(.gnu.linkonce.b*) - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __bss_end = .; - Heap_Bank1_Start = .; - } > SRAM - __bss_size = __bss_end - __bss_start; - - _stack_begin = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); - - /* Dummy section for stack */ - Stack _stack_begin (NOLOAD) : - { - . = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); - Heap_Bank1_End = .; - end = Heap_Bank1_End; - __stack_start = .; - . = . + stack_size; - __stack_end = .; - __initial_sp = .; - } > SRAM - - /* Heap - Bank1*/ - - Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; - - ASSERT(Heap_Bank1_Start <= Heap_Bank1_End, "bss section SRAM overflowed stack section") - - /* .no_init section contains SystemCoreClock. See system_XMC_xxxx.c file */ - .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : - { - * (.no_init); - } > SRAM - - - /DISCARD/ : - { - *(.comment) - } - - .stab 0 (NOLOAD) : { *(.stab) } - .stabstr 0 (NOLOAD) : { *(.stabstr) } - - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_pubtypes 0 : { *(.debug_pubtypes) } - - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - - /* DWARF 2.1 */ - .debug_ranges 0 : { *(.debug_ranges) } - - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - - /* Build attributes */ - .build_attributes 0 : { *(.ARM.attributes) } -} diff --git a/variants/XMC1300/linker_script_64k.ld b/variants/XMC1300/linker_script_64k.ld deleted file mode 100755 index 38fe4ae7..00000000 --- a/variants/XMC1300/linker_script_64k.ld +++ /dev/null @@ -1,288 +0,0 @@ -/** - * @file XMC1300x0064.ld - * @date 2021-01-11 - ~ - * @cond - ********************************************************************************************************************* - * Linker file for the GNU C Compiler v1.10 - * Supported devices: XMC130x-ANY package with 64kB Flash and 16kB RAM - * - * Updated January 2021 for any 64kB Flash device - * - * Copyright (c) 2015-2016, Infineon Technologies AG - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the distribution. - * - * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with - * Infineon Technologies AG dave@infineon.com). - ********************************************************************************************************************* - * - * Change History - * -------------- - * - * 2015-07-07: - * - Product splitting - * - Copyright notice update - * - * 2015-11-24: - * - Compatibility with GCC 4.9 2015q2 - * - * 2016-03-15: - * - Add assertion to check that region SRAM_combined does not overflowed no_init section - * - * 2016-06-07: - * - Add XMC1302-Q040X0200 - * - * 2018-03-08: - * - Change default XMC1xxx stack size - * - Move Stack to top of RAM below no_init for more standard and safer location - * - Could mean startup_XMC1xxx.S could be shortened - * - * 2021-01-11: - * - Split script to different flash size files for Boot Kit and Sense2GoL - * - * @endcond - * - */ - -OUTPUT_FORMAT("elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(Reset_Handler) - -MEMORY -{ - FLASH(RX) : ORIGIN = 0x10001000, LENGTH = 0x10000 - SRAM(!RX) : ORIGIN = 0x20000000, LENGTH = 0x4000 -} - -stack_size = DEFINED(stack_size) ? stack_size : 1024; -no_init_size = 4; - -SECTIONS -{ - /* TEXT section */ - - .text : - { - sText = .; - KEEP(*(.reset)); - *(.text .text.* .gnu.linkonce.t.*); - - /* C++ Support */ - KEEP(*(.init)) - KEEP(*(.fini)) - - /* .ctors */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - - /* .dtors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.rodata .rodata.*) - *(.gnu.linkonce.r*) - . = ALIGN(4); - } > FLASH - - .eh_frame_hdr : ALIGN (4) - { - KEEP (*(.eh_frame_hdr)) - } > FLASH - - .eh_frame : ALIGN (4) - { - KEEP (*(.eh_frame)) - } > FLASH - - /* Exception handling, exidx needs a dedicated section */ - .ARM.extab : ALIGN(4) - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - . = ALIGN(4); - __exidx_start = .; - .ARM.exidx : ALIGN(4) - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - __exidx_end = .; - . = ALIGN(4); - - /* End of RO-DATA and start of LOAD region for the veneers */ - eROData = . ; - - /* DSRAM layout (Lowest to highest)*/ - /* Veneer <-> DATA <-> ram_code <-> BSS <-> HEAP <-> memory gap <-> Stack <-> no_init */ - - .VENEER_Code ABSOLUTE(0x2000000C): AT(eROData) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - VeneerStart = .; - KEEP(*(.XmcVeneerCode)); - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - VeneerEnd = .; - } > SRAM - - VeneerSize = ABSOLUTE(VeneerEnd) - ABSOLUTE(VeneerStart); - - /* Standard DATA and user defined DATA/BSS/CONST sections */ - DataLoadAddr = eROData + VeneerSize; - .data : AT(DataLoadAddr) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __data_start = .; - *(vtable) - * (.data); - * (.data*); - *(*.data); - *(.gnu.linkonce.d*) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __data_end = .; - } > SRAM - __data_size = __data_end - __data_start; - - .ram_code : AT(DataLoadAddr + __data_size) - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __ram_code_start = .; - /* functions with __attribute__ ((section (".ram_code")))*/ - *(.ram_code) - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __ram_code_end = .; - } > SRAM - __ram_code_load = LOADADDR (.ram_code); - __ram_code_size = __ram_code_end - __ram_code_start; - - /* BSS section */ - .bss (NOLOAD) : - { - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __bss_start = .; - * (.bss); - * (.bss*); - * (COMMON); - *(.gnu.linkonce.b*) - . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ - __bss_end = .; - Heap_Bank1_Start = .; - } > SRAM - __bss_size = __bss_end - __bss_start; - - _stack_begin = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); - - /* Dummy section for stack */ - Stack _stack_begin (NOLOAD) : - { - . = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); - Heap_Bank1_End = .; - end = Heap_Bank1_End; - __stack_start = .; - . = . + stack_size; - __stack_end = .; - __initial_sp = .; - } > SRAM - - /* Heap - Bank1*/ - - Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; - - ASSERT(Heap_Bank1_Start <= Heap_Bank1_End, "bss section SRAM overflowed stack section") - - /* .no_init section contains SystemCoreClock. See system_XMC_xxxx.c file */ - .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : - { - * (.no_init); - } > SRAM - - - /DISCARD/ : - { - *(.comment) - } - - .stab 0 (NOLOAD) : { *(.stab) } - .stabstr 0 (NOLOAD) : { *(.stabstr) } - - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_pubtypes 0 : { *(.debug_pubtypes) } - - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - - /* DWARF 2.1 */ - .debug_ranges 0 : { *(.debug_ranges) } - - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - - /* Build attributes */ - .build_attributes 0 : { *(.ARM.attributes) } -} diff --git a/variants/XMC1400/config/XMC1400_Arduino_Kit/pins_arduino.h b/variants/XMC1400/config/XMC1400_Arduino_Kit/pins_arduino.h index 122a7008..77b110c4 100644 --- a/variants/XMC1400/config/XMC1400_Arduino_Kit/pins_arduino.h +++ b/variants/XMC1400/config/XMC1400_Arduino_Kit/pins_arduino.h @@ -50,6 +50,8 @@ extern const uint8_t NUM_ANALOG_INPUTS; #define NUM_SERIAL 1 #define NUM_TONE_PINS 4 #define NUM_TASKS_VARIANT 8 +#define NUM_SPI 1 +#define NUM_I2C 1 // Indicate unit has RTC/Alarm #define HAS_RTC 1 @@ -270,6 +272,79 @@ XMC_UART_t XMC_UART_0 = HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); +//SPI instance +XMC_SPI_t XMC_SPI_0 = +{ + .channel = XMC_SPI1_CH1, + .channel_config = { + .baudrate = 15984375U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)1 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT9, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)0 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source = XMC_INPUT_A, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)3 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT8, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + } +}; + +//I2C instance +XMC_I2C_t XMC_I2C_0 = +{ + .channel = XMC_I2C0_CH0, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)1 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)0 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT7, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source_dx0 = XMC_INPUT_F, + .input_source_dx1 = XMC_INPUT_E, + .slave_receive_irq_num = (IRQn_Type) USIC0_4_IRQn, + .slave_receive_irq_service_request = 4 , + .protocol_irq_num = (IRQn_Type) USIC0_5_IRQn, + .protocol_irq_service_request = 5 +}; + // Serial Interrupt and event handling #ifdef __cplusplus extern "C" { diff --git a/variants/XMC4200/config/XMC4200_Platform2GO/pins_arduino.h b/variants/XMC4200/config/XMC4200_Platform2GO/pins_arduino.h index edc90ce4..074bb9aa 100644 --- a/variants/XMC4200/config/XMC4200_Platform2GO/pins_arduino.h +++ b/variants/XMC4200/config/XMC4200_Platform2GO/pins_arduino.h @@ -55,6 +55,8 @@ extern const uint8_t NUM_ANALOG_OUTPUTS; #define NUM_SERIAL 1 #define NUM_TONE_PINS 7 #define NUM_TASKS_VARIANT 12 +#define NUM_SPI 1 +#define NUM_I2C 1 // Indicate unit has RTC/Alarm #define HAS_RTC 1 @@ -303,6 +305,76 @@ HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); // Object instantiated of the HardwareSerial class for UART ONBOARD interface HardwareSerial Serial1( &XMC_UART_1, &rx_buffer_1, &tx_buffer_1 ); +//SPI instance +XMC_SPI_t XMC_SPI_0 = +{ + .channel = XMC_SPI1_CH1, + .channel_config = { + .baudrate = 20003906U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)9 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)0 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + }, + .input_source = XMC_INPUT_D, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)8 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, +}; + +//I2C instance +XMC_I2C_t XMC_I2C_0 = +{ + .channel = XMC_I2C0_CH1, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)5 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)0 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .input_source_dx0 = XMC_INPUT_B, + .input_source_dx1 = XMC_INPUT_B, + .slave_receive_irq_num = (IRQn_Type) 84, + .slave_receive_irq_service_request = 1 , + .protocol_irq_num = (IRQn_Type) 85, + .protocol_irq_service_request = 2 +}; + // Serial Interrupt and event handling #ifdef __cplusplus extern "C" { diff --git a/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h b/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h index 6f00e7c2..f75c2c95 100644 --- a/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h +++ b/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h @@ -55,6 +55,8 @@ extern const uint8_t NUM_ANALOG_OUTPUTS; #define NUM_SERIAL 1 #define NUM_TONE_PINS 16 #define NUM_TASKS_VARIANT 32 +#define NUM_SPI 1 +#define NUM_I2C 1 // Indicate unit has RTC/Alarm #define HAS_RTC 1 @@ -355,6 +357,76 @@ XMC_UART_t XMC_UART_0 = // Single Hardware Serial object for both UART interfaces HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); +//SPI instance +XMC_SPI_t XMC_SPI_0 = +{ + .channel = XMC_SPI1_CH1, + .channel_config = { + .baudrate = 20003906U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)9 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)0 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + }, + .input_source = XMC_INPUT_D, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT1_BASE, + .pin = (uint8_t)8 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, +}; + +//I2C instance +XMC_I2C_t XMC_I2C_0 = +{ + .channel = XMC_I2C0_CH1, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT2_BASE, + .pin = (uint8_t)5 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)0 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .input_source_dx0 = XMC_INPUT_B, + .input_source_dx1 = XMC_INPUT_B, + .slave_receive_irq_num = (IRQn_Type) 91, + .slave_receive_irq_service_request = 1 , + .protocol_irq_num = (IRQn_Type) 92, + .protocol_irq_service_request = 2 +}; + // Serial Interrupt and event handling #ifdef __cplusplus diff --git a/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h b/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h index 0a5fe31d..29dcd245 100644 --- a/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h +++ b/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h @@ -58,6 +58,11 @@ extern const uint8_t NUM_ANALOG_OUTPUTS; #define NUM_SERIAL 2 #define NUM_TONE_PINS 16 #define NUM_TASKS_VARIANT 32 +#define NUM_SPI 3 +#define NUM_I2C 2 + +// to use SPI_for_xmc_SD if desired by user +#define XMC_SPI_for_xmc_SD XMC_SPI_1 // Indicate unit has RTC/Alarm #define HAS_RTC 1 @@ -91,6 +96,20 @@ static const uint8_t MOSI_SD = PIN_SPI_MOSI_SD; static const uint8_t MISO_SD = PIN_SPI_MISO_SD; static const uint8_t SCK_SD = PIN_SPI_SCK_SD; +// XMC_I2S defines +/*U2C0*/ +/*DX0C -> P3.7*/ +/*SCLKOUT(ALT1) -> P3.9*/ +/*WA(ALT1) -> P3.10*/ +#define MASTER_CHANNEL XMC_I2S2_CH0 +// master transmit slave receive +#define MASTER_MTSR PORT3, 8 +// master receive slave transmit +#define MASTER_MRST PORT3, 7 +#define INPUT_SOURCE USIC2_C0_DX0_P3_7 +#define MASTER_SCLK PORT3, 9 +#define MASTER_WACLK PORT3, 10 + #define A0 0 #define A1 1 #define A2 2 @@ -424,6 +443,267 @@ HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); // On-board port HardwareSerial Serial1( &XMC_UART_1, &rx_buffer_1, &tx_buffer_1 ); +//Three SPI instances possible +XMC_SPI_t XMC_SPI_0 = +{ + .channel = XMC_SPI2_CH0, + .channel_config = { + .baudrate = 20003906U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)8 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)7 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + }, + .input_source = XMC_INPUT_C, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)9 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, +}; + +XMC_SPI_t XMC_SPI_1 = +{ + .channel = XMC_SPI0_CH1, + .channel_config = { + .baudrate = 20003906U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)5 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT4_BASE, + .pin = (uint8_t)0 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + }, + .input_source = XMC_INPUT_E, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)6 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, +}; + +XMC_SPI_t XMC_SPI_2 = +{ + .channel = XMC_SPI2_CH1, + .channel_config = { + .baudrate = 20003906U, + .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, + .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, + .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE + }, + .mosi = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)11 + }, + .mosi_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, + .miso = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)12 + }, + .miso_config = { + .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + }, + .input_source = XMC_INPUT_D, + .sclkout = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)13 + }, + .sclkout_config = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM + }, +}; + +//Only two serial objects are possible: Serial and Serial1 so anymore serial interfaces has to overwrite/reuse the existing serial objects +// Will overwrite Serial +//XMC_SPI_t XMC_SPI_3 = +//{ +// .channel = XMC_SPI0_CH0, +// .channel_config = { +// .baudrate = 20003906U, +// .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, +// .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, +// .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE +// }, +// .mosi = { +// .port = (XMC_GPIO_PORT_t*)PORT5_BASE, +// .pin = (uint8_t)1 +// }, +// .mosi_config = { +// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, +// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, +// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM +// }, +// .miso = { +// .port = (XMC_GPIO_PORT_t*)PORT5_BASE, +// .pin = (uint8_t)0 +// }, +// .miso_config = { +// .mode = XMC_GPIO_MODE_INPUT_TRISTATE, +// }, +// .input_source = XMC_INPUT_D, +// .sclkout = { +// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, +// .pin = (uint8_t)8 +// }, +// .sclkout_config = { +// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, +// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, +// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM +// }, +//}; + +// Will overwrite Serial1 +//XMC_SPI_t XMC_SPI_4 = +//{ +// .channel = XMC_SPI1_CH0, +// .channel_config = { +// .baudrate = 20003906U, +// .bus_mode = (XMC_SPI_CH_BUS_MODE_t)XMC_SPI_CH_BUS_MODE_MASTER, +// .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS, +// .parity_mode = XMC_USIC_CH_PARITY_MODE_NONE +// }, +// .mosi = { +// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, +// .pin = (uint8_t)5 +// }, +// .mosi_config = { +// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, +// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, +// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM +// }, +// .miso = { +// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, +// .pin = (uint8_t)4 +// }, +// .miso_config = { +// .mode = XMC_GPIO_MODE_INPUT_TRISTATE, +// }, +// .input_source = XMC_INPUT_A, +// .sclkout = { +// .port = (XMC_GPIO_PORT_t*)PORT0_BASE, +// .pin = (uint8_t)11 +// }, +// .sclkout_config = { +// .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, +// .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, +// .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM +// }, +//}; + +//Two I2C instances possible +XMC_I2C_t XMC_I2C_0 = +{ + .channel = XMC_I2C1_CH1, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT3_BASE, + .pin = (uint8_t)15 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)13 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .input_source_dx0 = XMC_INPUT_A, + .input_source_dx1 = XMC_INPUT_B, + .slave_receive_irq_num = (IRQn_Type) 91, + .slave_receive_irq_service_request = 1 , + .protocol_irq_num = (IRQn_Type) 92, + .protocol_irq_service_request = 2 +}; +XMC_I2C_t XMC_I2C_1 = +{ + .channel = XMC_I2C1_CH0, + .channel_config = { + .baudrate = (uint32_t)(100000U), + .address = 0U + }, + .sda = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)5 + }, + .sda_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .scl = { + .port = (XMC_GPIO_PORT_t*)PORT0_BASE, + .pin = (uint8_t)11 + }, + .scl_config = { + .mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH + }, + .input_source_dx0 = XMC_INPUT_B, + .input_source_dx1 = XMC_INPUT_A, + .slave_receive_irq_num = (IRQn_Type) 93, + .slave_receive_irq_service_request = 3 , + .protocol_irq_num = (IRQn_Type) 94, + .protocol_irq_service_request = 4 +}; + +// XMC_I2S instance +XMC_I2S_t i2s_config = +{ + .input_config = {.mode = XMC_GPIO_MODE_INPUT_TRISTATE, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, + .sclk_config = {.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, + .wa_config = {.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1, .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH}, + .protocol_irq_num = (IRQn_Type)USIC2_2_IRQn, + .protocol_irq_service_request = 2 +}; + // Serial Interrupt and event handling #ifdef __cplusplus extern "C" {