Skip to content

Commit

Permalink
spider: Add Serial example for g4mh
Browse files Browse the repository at this point in the history
  • Loading branch information
fsylvestre committed Nov 30, 2023
1 parent 2ba72f1 commit da75f97
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/rh850/serial/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

#stop on errors
set -e

if [[ ! -d "_build" ]]
then
mkdir _build
fi

echo "*** Run Goil ***"
goil --target=rh850/g4mh --templates=../../../goil/templates/ serial.oil
cd _build
echo "*** Run CMake ***"
cmake -G "Unix Makefiles" -D CMAKE_TOOLCHAIN_FILE=../serial/compiler.cmake ..
echo "*** Run Make ***"
make
39 changes: 39 additions & 0 deletions examples/rh850/serial/serial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "tpl_os.h"

#include "spider_serial.h"
#include "printf.h"

FUNC(int, OS_APPL_CODE) main(void)
{

StartOS(OSDEFAULTAPPMODE);
return 0;
}

volatile uint32 tmp = 0;

TASK(serial_rx)
{
uint8 uart_rx;

Serial_Init();

debug_printf("serial_rx task started\r\n");

while(1)
{
if (Serial_Rx(&uart_rx))
{
/* If received a char, send back the next one */
Serial_Tx(uart_rx+1);
}
}
}

TASK(serial_tx)
{
/* Send next alphabet letter each time*/
static uint8 uart_char=0;
uart_char = (uart_char+1) % 26;
Serial_Tx('a' + uart_char);
}
59 changes: 59 additions & 0 deletions examples/rh850/serial/serial.oil
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
OIL_VERSION = "4.2";

IMPLEMENTATION trampoline {
TASK {
UINT32 STACKSIZE = 2048 ;
} ;

ISR {
UINT32 STACKSIZE = 2048 ;
} ;
};

CPU serial {
OS config {
STATUS = EXTENDED;

BUILD = TRUE {
TRAMPOLINE_BASE_PATH = "../../../";
APP_SRC = "serial.c";
APP_NAME = "serial_exe";
LDFLAGS="-debug -nocompress -NOOPtimize -memory=high -nologo -SHow=ALL";
CFLAGS="-DHSCIF_1843200BPS -Xcpu=g4mh -g -g_line -Xfxu=off -Xasm_path=.";
LINKER = "rlink";
SYSTEM = CMAKE;

LIBRARY = serial;
};
SYSTEM_CALL = TRUE;
};

APPMODE std {};

TASK serial_rx {
PRIORITY = 1;
AUTOSTART = TRUE { APPMODE = std; };
ACTIVATION = 1;
SCHEDULE = FULL;
};

TASK serial_tx {
PRIORITY = 2;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
};

ALARM serial_serial {
COUNTER = SystemCounter;
ACTION = ACTIVATETASK {
TASK = serial_tx;
};
AUTOSTART = TRUE {
APPMODE = std;
ALARMTIME = 100;
CYCLETIME = 100;
};
};
};

0 comments on commit da75f97

Please sign in to comment.