Skip to content

Commit

Permalink
Merge pull request #183 from techpaul/master
Browse files Browse the repository at this point in the history
Improve Maintainability of pins_arduino.h
  • Loading branch information
techpaul authored May 22, 2022
2 parents 318e421 + 3bf5951 commit 4379305
Show file tree
Hide file tree
Showing 14 changed files with 1,705 additions and 590 deletions.
810 changes: 810 additions & 0 deletions package/package_infineon_index.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions resources/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Resources Folder
## Linked resources for Wiki and other documentation
This folder contains sub-folders for documentation resources, primarily to link to files
and images for wiki.
66 changes: 66 additions & 0 deletions resources/wiki/xmc4700-X1-X2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Additional pins for port X1 starting here,,,,
Description,Pin,Port,X1 pin,Duplicate
PWM42-2 / PWM12,36,P3.4,1,
I2C_1 SDA // SPI_4 MOSI,37,P0.5,3,
PWM80-2 / PWM10,38,P0.3,5,
PWM80-1 / PWM9,39,P0.1,7,
,40,P0.10,9,
,41,P3.2,11,
,42,P3.1,13,
A6 / ADC Input,43,P15.6 (INPUT ONLY),15,
A7 / ADC Input,44,P15.5 (INPUT ONLY),17,
A8 / ADC Input,45,P15.3 (INPUT ONLY),19,
A9 / ADC Input,46,P14.15 (INPUT ONLY),21,
A10 / ADC Input,47,P14.13 (INPUT ONLY),23,
A11 / ADC Input,48,P14.7 (INPUT ONLY),25,
A12 / ADC Input,49,P15.15 (INPUT ONLY),27,
DAC0 // A13 / ADC Input,50,P14.9,29
,51,P2.13,31
,52,P5.10,33
PWM80-0 / PWM6,53,P5.11,34
,54,P1.14,32
DAC1 // A14 / ADC Input,55,P14.8,30
A15 / ADC Input,56,P15.14 (INPUT ONLY),28
A16 / ADC Input,57,P14.6 (INPUT ONLY),26
A17 / ADC Input,58,P14.12 (INPUT ONLY),24
A18 / ADC Input,59,P14.14 (INPUT ONLY),22
A19 / ADC Input,60,P15.2 (INPUT ONLY),20
A20 / ADC Input,61,P15.4 (INPUT ONLY),18
A21 / ADC Input,62,P15.7 (INPUT ONLY),16
PWM42-0 / PWM7,63,P3.0,14
PWM80-1 / PWM8,64,P0.9,12
,65,P0.0,10
,66,P0.2,8
SPI_4 MISO ,67,P0.4,6
PWM80-3 / PWM11,68,P0.6,4
I2C_1 SCL // SPI_4 SCLK ,69,P0.11,2
Additional pins for port X2 starting here,,,
Description,Pin,Port,X2 pin
SPI_2 SCLK,70,P3.13,1
SPI_2 MOSI,71,P3.11,3
PWM40-1 / PWM21,72,P0.14,5
,73,P3.14,7
,74,P0.7,9
,75,P1.2,11
,76,P6.1,13
,77,P5.3,15
PWM43-0 / PWM17,78,P6.5,17
PWM81-0 / PWM16,79,P1.15,19
SPI_3 MOSI,80,P5.1,21
PWM81-2 / PWM15,81,P5.3,23
PWM81-1 / PWM14,82,P5.5,25
PWM81-0 / PWM13,83,P5.7,27
,84,P2.6,28
,85,P5.6,26
,86,P5.4,24
,87,P5.2,22
SPI_3 MISO,88,P5.0,20
,89,P6.6,18
PWM43-1 / PWM18,90,P6.4,16
PWM43-3 / PWM19,91,P6.2,14
,92,P6.0,12
SPI_3 SCLK,93,P0.8,10
,94,P3.3,8
PWM40-0 / PWM20,95,P0.15,6
PWM40-3 / PWM22,96,P0.12,4,
ECAT0.P1_LINK_ACT,97,P3.12,2,YES Pin 23
63 changes: 47 additions & 16 deletions tests/testdefines/testdefines.ino
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* Example of how to access XMC defines and use for debug
*
* Updated 8-Feb-2020 Paul Carpenter
* Updated 1-Jul-2020 Paul Carpenter - Prepare architecture change to xmc
*/
// Linker symbols to get flash/RAM usage
#include <Arduino.h>

// Linker symbols to get falsh/RAM usage
#if( UC_FAMILY == XMC1 )
extern char VeneerStart, VeneerEnd, eROData;
#endif
Expand All @@ -17,13 +14,17 @@ extern char sText, __initial_sp, __stack_start, __data_start, __data_end;

uint32_t temp, code_size;

void setup( )
void setup()
{
delay( 60 );
Serial.begin( 115200, SERIAL_8N1 );
Serial.println( "PC Services - XMC-for-Arduino useful defines example" );
Serial.print( "Built on: " );
Serial.print( __DATE__ );
Serial.print( " " );
Serial.println( __TIME__ );

#ifdef XMC_BOARD
Serial.read();
str2( XMC_BOARD );
Serial.write( '\t' );
str1( XMC_BOARD );
Expand All @@ -43,6 +44,11 @@ str2( ARDUINO_ARM_XMC );
Serial.write( '\t' );
str1( ARDUINO_ARM_XMC );
#endif
#if defined ARDUINO_ARCH_CORTEX-M4
str2( ARDUINO_ARM_XMC );
Serial.write( '\t' );
str1( ARDUINO_ARM_XMC );
#endif
#if defined UC_RAM
str2( UC_RAM );
Serial.print( "\t\t" );
Expand All @@ -57,16 +63,10 @@ str1( F_CPU );
str2( ARDUINO );
Serial.print( "\t\t" );
str1( ARDUINO );
#if defined ARDUINO_ARCH_ARM
str2( ARDUINO_ARCH_ARM );
Serial.write( ' ' );
str1( ARDUINO_ARCH_ARM );
#endif
#if defined ARDUINO_ARCH_XMC
str2( ARDUINO_ARCH_XMC );
Serial.write( ' ' );
str1( ARDUINO_ARCH_XMC );
#endif

Serial.print( "Library Version\t" );
Serial.print( XMC_LIB_MAJOR_VERSION );
Serial.print( '.' );
Expand Down Expand Up @@ -113,9 +113,40 @@ Serial.println( code_size );
Serial.print( "Ram less Stack\t" );
temp = &Heap_Bank1_Start - &__data_start;
Serial.println( temp );

Serial.print( "\nCapabilities\nDigital Pins\t" );
Serial.println( NUM_DIGITAL );
Serial.print( "PWM4\t\t" );
Serial.println( NUM_PWM4 );
#ifdef CCU8V2
Serial.print( "PWM8\t\t" );
Serial.println( NUM_PWM8 );
#endif
Serial.print( "PWM\t\t" );
Serial.println( NUM_PWM );
Serial.print( "Ints\t\t" );
Serial.println( NUM_INTERRUPT );
Serial.print( "ADC\t\t" );
Serial.println( NUM_ANALOG_INPUTS );
#ifdef DAC
Serial.print( "DAC\t\t" );
Serial.println( NUM_ANALOG_OUTPUTS );
#endif

str2( NUM_LEDS );
Serial.write( '\t' );
str1( NUM_LEDS );
#ifdef BUTTON1
str2( NUM_BUTTONS );
Serial.write( '\t' );
str1( NUM_BUTTONS );
#endif
str2( NUM_SERIAL );
Serial.write( '\t' );
str1( NUM_SERIAL );
}


void loop( )
void loop()
{
}
66 changes: 40 additions & 26 deletions variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@
// @Defines
//****************************************************************************
// XMC_BOARD for stringifying into serial or other text outputs/logs
// Note the actual name XMC and number MUST have a character between
// Note the actual name XMC and number MUST have a character between
// to avoid issues with other defined macros e.g. XMC1100
#define XMC_BOARD XMC 1100 Boot Kit

/* On board LED is ON when digital output is 0, LOW, False, OFF */
#define XMC_LED_ON 0

#define NUM_ANALOG_INPUTS 8
#define NUM_PWM 4
// Following were defines now evaluated by compilation as const variables
// After definitions of associated mapping arrays
extern const uint8_t NUM_DIGITAL;
extern const uint8_t GND;
extern const uint8_t NUM_PWM4;
extern const uint8_t NUM_PWM;
extern const uint8_t NUM_INTERRUPT;
extern const uint8_t NUM_ANALOG_INPUTS;
#define NUM_LEDS 7
#define NUM_INTERRUPT 2
#define NUM_SERIAL 1
#define NUM_TONE_PINS 4
#define NUM_TASKS_VARIANT 8
Expand All @@ -61,14 +67,14 @@

#define PWM4_TIMER_PERIOD (2041U) // Generate 490Hz @fCCU=1MHz

#define PCLK 64000000u
#define PCLK 64000000u

#define PIN_SPI_SS 10
#define PIN_SPI_MOSI 11
#define PIN_SPI_MISO 12
#define PIN_SPI_SCK 13

extern uint8_t SS;
extern uint8_t SS;
extern uint8_t MOSI;
extern uint8_t MISO;
extern uint8_t SCK;
Expand Down Expand Up @@ -97,23 +103,11 @@ extern uint8_t SCK;
#define LED4 1 // Extended LEDs P1.3
#define LED5 2 // Extended LEDs P1.4
#define LED6 31 // Extended LEDs P1.5
#define GND 32 // GND

#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))

#ifdef ARDUINO_MAIN

/* Mapping of Arduino Pins to PWM4 channels as pin and PWM4 channel
last entry 255 for both parts.
Putting both parts in array means if a PWM4 channel gets reassigned for
another function later a gap in channel numbers will not mess things up */
const uint8_t mapping_pin_PWM4[][ 2 ] = {
{ 3, 0 },
{ 4, 1 },
{ 6, 2 },
{ 9, 3 },
{ 255, 255 } };

// Mapping of digital pins and comments
const XMC_PORT_PIN_t mapping_port_pin[] =
{
/* 0 */ {XMC_GPIO_PORT1, 2}, // RX / LED 3 output P1.2
Expand Down Expand Up @@ -149,23 +143,42 @@ const XMC_PORT_PIN_t mapping_port_pin[] =
/* 30 */ {XMC_GPIO_PORT0, 13},// AUX / GPIO P0.13
/* 31 */ {XMC_GPIO_PORT1, 5} // LED 6 output P1.5
};
const uint8_t GND = ( sizeof( mapping_port_pin ) / sizeof( XMC_PORT_PIN_t ) );
const uint8_t NUM_DIGITAL = ( sizeof( mapping_port_pin ) / sizeof( XMC_PORT_PIN_t ) );;

const XMC_PIN_INTERRUPT_t mapping_interrupt[] =
{
{
/* 0 */ {CCU40, CCU40_CC40, 0, 0, CCU40_IN0_U0C0_DX2INS},
/* 1 */ {CCU40, CCU40_CC40, 0, 1, CCU40_IN0_P0_0}
};
};
const uint8_t NUM_INTERRUPT = ( sizeof( mapping_interrupt ) / sizeof( XMC_PIN_INTERRUPT_t ) );

/* Mapping of Arduino Pins to PWM4 channels as pin and index in PWM4 channel
mapping array XMC_PWM4_t mapping_pwm4[]
last entry 255 for both parts.
Putting both parts in array means if a PWM4 channel gets reassigned for
another function later a gap in channel numbers will not mess things up */
const uint8_t mapping_pin_PWM4[][ 2 ] = {
{ 3, 0 },
{ 4, 1 },
{ 6, 2 },
{ 9, 3 },
{ 255, 255 } };

/* Configurations of PWM channels for CCU4 type */
XMC_PWM4_t mapping_pwm4[] =
{
{
{CCU40, CCU40_CC40, 0, mapping_port_pin[3], P0_0_AF_CCU40_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 3 P0.0
{CCU40, CCU40_CC41, 1, mapping_port_pin[4], P0_1_AF_CCU40_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 4 P0.1
{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
};
};
const uint8_t NUM_PWM = ( sizeof( mapping_pwm4 ) / sizeof( XMC_PWM4_t ) );
const uint8_t NUM_PWM4 = ( sizeof( mapping_pwm4 ) / sizeof( XMC_PWM4_t ) );

/* Analog Pin mappings and configurations */
XMC_ADC_t mapping_adc[] =
{
{
{VADC, 0, DISABLED},
{VADC, 1, DISABLED},
{VADC, 2, DISABLED},
Expand All @@ -174,7 +187,8 @@ XMC_ADC_t mapping_adc[] =
{VADC, 7, DISABLED},
{VADC, 5, DISABLED},
{VADC, 6, DISABLED}
};
};
const uint8_t NUM_ANALOG_INPUTS = ( sizeof( mapping_adc ) / sizeof( XMC_ADC_t ) );

/*
* UART objects
Expand Down
Loading

0 comments on commit 4379305

Please sign in to comment.