Skip to main content

TriCore TC27D terminal


HW: ShieldBuddy TC275

info

BaseFramework에는 Bsp가 기본 라이브러리로 제공되지 않습니다. BaseFramework를 프로젝트 시작으로 사용하는 경우 iLLD를 다운로드 받아 BaseSw를 교체해주시거나 필요한 라이브러리만 추가해주시기 바랍니다.

  • Ifx_Shell.h: Shell functions.
  • Ifx_Console.h: Main Console module.
  • Assert.h: Assert functions.

Ifx_Shell_Command

typedef boolean (*Ifx_Shell_Call)(pchar args, void *data, IfxStdIf_DPipe *io);
typedef struct {
pchar commandLine;
pchar help;
void * data;
Ifx_Shell_Call call;
} Ifx_Shell_Command;

Examples

info

폴더를 새로 생성한 경우 clean projet 후, 다시 빌드해야 합니다.

0_Src/AppSw/Tricore/TC27D_lib/Config/Ifx_IntPrioDef.h를 만들고 아래와 같이 작성합니다.

#pragma once

#define IFX_INTPRIO_ASCLIN3_TX 1
#define IFX_INTPRIO_ASCLIN3_RX 2
#define IFX_INTPRIO_ASCLIN3_ER 3

0_Src/AppSw/Tricore/TC27D_lib/shell_interface/shell_interface.h

#pragma once

#include "IfxAsclin_Asc.h"
#include "Ifx_Console.h"
#include "Ifx_Shell.h"

#define SHELL_ASC_TX_BUFFER_SIZE 2048
#define SHELL_ASC_RX_BUFFER_SIZE 512

#define SHELL_ASC_BAUDRATE 115200

typedef struct {
uint8 tx[SHELL_ASC_TX_BUFFER_SIZE + sizeof(Ifx_Fifo) + 8];
uint8 rx[SHELL_ASC_RX_BUFFER_SIZE + sizeof(Ifx_Fifo) + 8];
} shell_asc_buffer_t;

typedef struct {
shell_asc_buffer_t buffer;
IfxAsclin_Asc asc;
IfxStdIf_DPipe dpipe;
Ifx_Shell shell;
} shell_interface_t;

void shell_init(void);
void shell_run(void);

0_Src/AppSw/Tricore/TC27D_lib/shell_interface/shell_interface.c

#include "Assert.h"
#include "IfxAsclin_PinMap.h"
#include "IfxCpu_Irq.h"
#include "Ifx_IntPrioDef.h"
#include "shell_interface.h"

shell_interface_t shell_interface;

IFX_INTERRUPT(asclin3_tx_isr, 0, IFX_INTPRIO_ASCLIN3_TX) {
IfxStdIf_DPipe_onTransmit(&shell_interface.dpipe);
}
IFX_INTERRUPT(asclin3_rx_isr, 0, IFX_INTPRIO_ASCLIN3_RX) {
IfxStdIf_DPipe_onReceive(&shell_interface.dpipe);
}
IFX_INTERRUPT(asclin3_er_isr, 0, IFX_INTPRIO_ASCLIN3_ER) {
IfxStdIf_DPipe_onError(&shell_interface.dpipe);
}

const Ifx_Shell_Command shell_commands[] = {{
"help",
SHELL_HELP_DESCRIPTION_TEXT,
&shell_interface.shell,
&Ifx_Shell_showHelp,
},
IFX_SHELL_COMMAND_LIST_END};

static void shell_asc_init(void) {
// create module config
IfxAsclin_Asc_Config ascConfig;
IfxAsclin_Asc_initModuleConfig(&ascConfig, &MODULE_ASCLIN3);

// set the desired baudrate
ascConfig.baudrate.prescaler = 1;
ascConfig.baudrate.baudrate
= SHELL_ASC_BAUDRATE; // FDR values will be calculated in initModule

// ISR priorities and interrupt target
ascConfig.interrupt.txPriority = IFX_INTPRIO_ASCLIN3_TX;
ascConfig.interrupt.rxPriority = IFX_INTPRIO_ASCLIN3_RX;
ascConfig.interrupt.erPriority = IFX_INTPRIO_ASCLIN3_ER;
ascConfig.interrupt.typeOfService
= IfxCpu_Irq_getTos(IfxCpu_getCoreIndex());

// FIFO configuration
ascConfig.txBuffer = shell_interface.buffer.tx;
ascConfig.txBufferSize = SHELL_ASC_TX_BUFFER_SIZE;
ascConfig.rxBuffer = shell_interface.buffer.rx;
ascConfig.rxBufferSize = SHELL_ASC_RX_BUFFER_SIZE;

// pin configuration
const IfxAsclin_Asc_Pins pins
= {NULL,
IfxPort_InputMode_pullUp, // CTS pin not used
&IfxAsclin3_RXD_P32_2_IN,
IfxPort_InputMode_pullUp, // Rx pin
NULL,
IfxPort_OutputMode_pushPull, // RTS pin not used
&IfxAsclin3_TX_P15_7_OUT,
IfxPort_OutputMode_pushPull, // Tx pin
IfxPort_PadDriver_cmosAutomotiveSpeed1};
ascConfig.pins = &pins;
IfxAsclin_Asc_initModule(&shell_interface.asc, &ascConfig);
}

void shell_init(void) {
shell_asc_init();

IfxAsclin_Asc_stdIfDPipeInit(&shell_interface.dpipe, &shell_interface.asc);
Ifx_Console_init(&shell_interface.dpipe);
Ifx_Assert_setStandardIo(&shell_interface.dpipe);

Ifx_Shell_Config shell_config;
Ifx_Shell_initConfig(&shell_config);
shell_config.standardIo = &shell_interface.dpipe;
shell_config.commandList[0] = &shell_commands[0];

Ifx_Shell_init(&shell_interface.shell, &shell_config);

Ifx_Console_print(
"Enter 'help' to see the available commands" ENDL IFX_CFG_SHELL_PROMPT);
}

void shell_run(void) { Ifx_Shell_process(&shell_interface.shell); }