Skip to content

Commit

Permalink
Adding demos for Infineon AURIX TC375 using AURIX Development Studio (#…
Browse files Browse the repository at this point in the history
…12)

* Adding demos for Infineon AURIX TC375 using AURIX Development Studio

* Refactoring to only include example specific files

* Add SPDX license identifier and update README.md

* Adding 'Debug Configuration' steps to the README
  • Loading branch information
schaazzz committed Jan 10, 2024
1 parent 44b2426 commit f78a2f4
Show file tree
Hide file tree
Showing 29 changed files with 979 additions and 0 deletions.
70 changes: 70 additions & 0 deletions AURIX_TC375_ADS/Blinky/Blinky.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**********************************************************************************************************************
* \file Blinky.c
* \copyright Copyright (C) Infineon Technologies AG 2023
*
* Use of this file is subject to the terms of use agreed between (i) you or the company in which ordinary course of
* business you are acting and (ii) Infineon Technologies AG or its licensees. If and as long as no such terms of use
* are agreed, use of this file is subject to following:
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and
* accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the
* Software is furnished to do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including the above license grant, this restriction
* and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all
* derivative works of the Software, unless such copies or derivative works are solely in the form of
* machine-executable object code generated by a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* SPDX-License-Identifier: BSL-1.0
*********************************************************************************************************************/

/*********************************************************************************************************************/
/*-----------------------------------------------------Includes------------------------------------------------------*/
/*********************************************************************************************************************/
#include "IfxPort_PinMap.h"
#include "Port/Io/IfxPort_Io.h"

#include "FreeRTOS.h"
#include "task.h"

/*********************************************************************************************************************/
/*-----------------------------------------------------Macros--------------------------------------------------------*/
/*********************************************************************************************************************/
#define LED_1 IfxPort_P00_5 /* Port/Pin for LED 1 */
#define LED1_BLINKY_PERIOD_MS (250) /* The period (in milliseconds) at which LED1 will blink */

/*********************************************************************************************************************/
/*---------------------------------------------Function Implementations----------------------------------------------*/
/*********************************************************************************************************************/
/* Initialization function for LED1 app */
static void task_init(void)
{
/* Setup the port/pin connected to LED1 to general output mode push-pull. This function can be
* used to initialize any port pin by specifying the port number, pin number and port pin mode.
*/
IfxPort_setPinMode(LED_1.port, LED_1.pinIndex, IfxPort_Mode_outputPushPullGeneral);
}

/* Task which runs the LED1 app */
void task_blinky(void *arg)
{
task_init();

while (1)
{
/* Toggle LED1 state */
IfxPort_setPinState(LED_1.port, LED_1.pinIndex, IfxPort_State_toggled);

/* Delay 250ms */
vTaskDelay(pdMS_TO_TICKS(LED1_BLINKY_PERIOD_MS));
}
}
103 changes: 103 additions & 0 deletions AURIX_TC375_ADS/Blinky/Configurations/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0

#define configCPU_CLOCK_HZ ( ( unsigned long ) 300000000UL )
#define configTICK_RATE_HZ ( ( TickType_t ) 1000UL )

#define configMAX_PRIORITIES ( 10 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32U * 1024U ) )
#define configMAX_TASK_NAME_LEN ( 16 )

#define configENABLE_BACKWARD_COMPATIBILITY 0
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configCHECK_FOR_STACK_OVERFLOW 1
#define configUSE_TICK_HOOK 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_MUTEXES 1
#define configRECORD_STACK_HIGH_ADDRESS 1

#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5

/* Software timer configuration. */
#define configUSE_TIMERS ( 1 )
#define configTIMER_TASK_PRIORITY ( 9 )
#define configTIMER_QUEUE_LENGTH ( 5 )
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE

/* Set the following definitions to 1 to include the API function, or zero
* to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1

////////////////////// Testing //////////////////////////////////////////////
#define INCLUDE_eTaskGetState 1
#define configPRINTF( X ) printf X
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3
#define configSTART_TASK_NOTIFY_TESTS 0
#define configSTART_TASK_NOTIFY_ARRAY_TESTS 0
#define configSTART_BLOCKING_QUEUE_TESTS 0
#define configSTART_SEMAPHORE_TESTS 0
#define configSTART_POLLED_QUEUE_TESTS 0
#define configSTART_INTEGER_MATH_TESTS 0
#define configSTART_GENERIC_QUEUE_TESTS 0
#define configSTART_PEEK_QUEUE_TESTS 0
#define configSTART_MATH_TESTS 0
#define configSTART_RECURSIVE_MUTEX_TESTS 0
#define configSTART_COUNTING_SEMAPHORE_TESTS 0
#define configSTART_QUEUE_SET_TESTS 0
#define configSTART_QUEUE_OVERWRITE_TESTS 0
#define configSTART_EVENT_GROUP_TESTS 0
#define configSTART_INTERRUPT_SEMAPHORE_TESTS 0
#define configSTART_QUEUE_SET_POLLING_TESTS 0
#define configSTART_BLOCK_TIME_TESTS 0
#define configSTART_ABORT_DELAY_TESTS 0
#define configSTART_MESSAGE_BUFFER_TESTS 0
#define configSTART_STREAM_BUFFER_TESTS 0
#define configSTART_STREAM_BUFFER_INTERRUPT_TESTS 0
#define configSTART_TIMER_TESTS 0
#define configSTART_INTERRUPT_QUEUE_TESTS 1
#define configSTART_REGISTER_TESTS 1
#define configSTART_DELETE_SELF_TESTS 0
////////////////////////////////////////////////////////////////////

/* Interrupt above priority 31 are not effected by critical sections, but cannot call interrupt safe FreeRTOS functions. */
#define configMAX_API_CALL_INTERRUPT_PRIORITY 31

/* Default definition of configASSERT(). */
#ifdef DEBUG
#ifdef __TASKING__
#define configASSERT( x ) if( ( x ) == 0 ) { __disable(); __debug(); }
#endif
#ifdef __clang__
#define configASSERT( x ) if( ( x ) == 0 ) { __builtin_tricore_disable(); __builtin_tricore_debug(); }
#endif
#else
#define configASSERT( x ) ((void)(x)) /* Empty macro to remove compiler warning(s) about unused variables */
#endif

/* AURIX TCxxx definitions */
#define configCONTEXT_INTERRUPT_PRIORITY 1
#define configTIMER_INTERRUPT_PRIORITY 2 /* This value must not be bigger then context priority */
#define configCPU_NR 0
#define configPROVIDE_SYSCALL_TRAP 0
#define configSYSCALL_CALL_DEPTH 2
#define configSTM ( ( uint32_t * ) (0xF0001000 + configCPU_NR*0x100 ) )
#define configSTM_SRC ( ( uint32_t * ) (0xF0038300 + configCPU_NR*0x8) )
#define configSTM_CLOCK_HZ ( 100000000 )
#define configSTM_DEBUG ( 1 )
#define configCONTEXT_SRC ( ( uint32_t * ) 0xF0038990 )

#endif /* FREERTOS_CONFIG_H */
88 changes: 88 additions & 0 deletions AURIX_TC375_ADS/Blinky/Cpu0_Main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**********************************************************************************************************************
* \file Cpu0_Main.c
* \copyright Copyright (C) Infineon Technologies AG 2023
*
* Use of this file is subject to the terms of use agreed between (i) you or the company in which ordinary course of
* business you are acting and (ii) Infineon Technologies AG or its licensees. If and as long as no such terms of use
* are agreed, use of this file is subject to following:
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and
* accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the
* Software is furnished to do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including the above license grant, this restriction
* and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all
* derivative works of the Software, unless such copies or derivative works are solely in the form of
* machine-executable object code generated by a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* SPDX-License-Identifier: BSL-1.0
*********************************************************************************************************************/
/*\title TC375 Basic FreeRTOS interrupt usage example
* \abstract This example shows how to get started with using the AURIX(TM) FreeRTOS port
* \description This examples shows FreeRTOS usage on AURIX(TM) TC375 using a simple task which toggles an LED every 250ms.
*
* \name iLLD_TC375_ADS_Blinky
* \version V1.0.0
* \board AURIX TC375 lite Kit, KIT_A2G_TC375_LITE, TC37xTP_A-Step
* \keywords AURIX, TC3XX, TC375, FreeRTOS, Blinky, Task, LED
* \documents See README.md
* \lastUpdated 2023-11-07
*********************************************************************************************************************/

/*********************************************************************************************************************/
/*-----------------------------------------------------Includes------------------------------------------------------*/
/*********************************************************************************************************************/
#include "IfxCpu.h"
#include "IfxScuWdt.h"

/* Scheduler includes */
#include "FreeRTOS.h"
#include "task.h"

IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;

/*********************************************************************************************************************/
/*------------------------------------------------Function Prototypes------------------------------------------------*/
/*********************************************************************************************************************/
void task_blinky(void *arg);

/*********************************************************************************************************************/
/*---------------------------------------------Function Implementations----------------------------------------------*/
/*********************************************************************************************************************/
void core0_main(void)
{
IfxCpu_enableInterrupts();

/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());

/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);

/* Create the Blinky task */
xTaskCreate(task_blinky, "BINKY", configMINIMAL_STACK_SIZE, NULL, 0, NULL);

/* Start the scheduler (this function will never return) */
vTaskStartScheduler();
}

/* Required FreeRTOS callback, called in case of a stack overflow.
* For the sake of simplicity, this function will loop indefinitely
* and the root cause can be confirmed by using a debugger
*/
void vApplicationStackOverflowHook (TaskHandle_t xTask, char *pcTaskName)
{
}
84 changes: 84 additions & 0 deletions AURIX_TC375_ADS/GPT12_Printf/Blinky.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**********************************************************************************************************************
* \file Blinky.c
* \copyright Copyright (C) Infineon Technologies AG 2023
*
* Use of this file is subject to the terms of use agreed between (i) you or the company in which ordinary course of
* business you are acting and (ii) Infineon Technologies AG or its licensees. If and as long as no such terms of use
* are agreed, use of this file is subject to following:
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and
* accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the
* Software is furnished to do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including the above license grant, this restriction
* and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all
* derivative works of the Software, unless such copies or derivative works are solely in the form of
* machine-executable object code generated by a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* SPDX-License-Identifier: BSL-1.0
*********************************************************************************************************************/

/*********************************************************************************************************************/
/*-----------------------------------------------------Includes------------------------------------------------------*/
/*********************************************************************************************************************/
#include "IfxPort_PinMap.h"
#include "Port/Io/IfxPort_Io.h"

#include <stdio.h>

#include "FreeRTOS.h"
#include "task.h"

/*********************************************************************************************************************/
/*------------------------------------------------------Macros-------------------------------------------------------*/
/*********************************************************************************************************************/
#define LED_1 IfxPort_P00_5 /* Port/Pin for LED 1 */
#define LED_2 IfxPort_P00_6 /* Port/Pin for LED 2 */
#define BUTTON_1 IfxPort_P00_7 /* Port/Pin for BUTTION 1 */

#define BLINKY_PERIOD_MS (250) /* The period of the blinky task */

/*********************************************************************************************************************/
/*---------------------------------------------Function Implementations----------------------------------------------*/
/*********************************************************************************************************************/
/* Initialize the IO ports/pins for LED1, LED2 and BUTTON1 */
static void task_init(void)
{
/* Set input mode for the BUTTON1 pin */
IfxPort_setPinMode(BUTTON_1.port, BUTTON_1.pinIndex, IfxPort_Mode_inputPullUp);

/* Setup the port/pin connected to LED1 and LED2 to general output mode push-pull */
IfxPort_setPinMode(LED_1.port, LED_1.pinIndex, IfxPort_Mode_outputPushPullGeneral);
IfxPort_setPinMode(LED_2.port, LED_2.pinIndex, IfxPort_Mode_outputPushPullGeneral);
}

/* Task which blinks LED1 at an interval of BLINKY_PERIOD_MS and toggles LED2 each time BUTTON1 is pressed */
void task_blinky(void *arg)
{

task_init();

while (1)
{
/* Toggle LED1 state */
IfxPort_setPinState(LED_1.port, LED_1.pinIndex, IfxPort_State_toggled);

/* If BUTTON_1 is pressed, toggle LED_2 */
if (IfxPort_getPinState(BUTTON_1.port, BUTTON_1.pinIndex) == 0) {
IfxPort_setPinState(LED_2.port, LED_2.pinIndex, IfxPort_State_toggled);
}

/* Delay 250ms */
vTaskDelay(pdMS_TO_TICKS(BLINKY_PERIOD_MS));

}
}

0 comments on commit f78a2f4

Please sign in to comment.