FreeRTOSをFITやCG(や追々PDG2でも?)と一緒に使うサンプルプログラムをCSplusでビルド出来るプロジェクトにしてみた

こんにちは。NoMaYです。

別スレッドで、FreeRTOS kernel+FITのサンプルプログラムやFreeRTOS kernel+コード生成機能で生成されたソースを含むサンプルプログラムがあることに気付いたのですが、残念ながら、e2 studio v5のプロジェクトしか含まれておらずCS+のプロジェクトが含まれていませんでした。そこで、プロジェクトを変換してCS+でビルド出来るようにしてみました。また、変換したプロジェクトを以下のzipファイルに固めました。

FreeRTOS_kernel_and_FIT_CG_20171230_1.zip    758KB
FreeRTOS_kernel_and_FIT_CG_20171230_2.zip    562KB
FreeRTOS_kernel_and_FIT_CG_20171230_3.zip    908KB
FreeRTOS_kernel_and_FIT_CG_20171230_3'.zip    568KB

そのサンプルプログラムは以下のものです。ちなみに、(1)を見ていて気付いたのですが、どうも非公式ながらルネサスさんの社内には、r_bsp_rtosとか、r_cmt_rtos_rxとか、更にはFreeRTOSをFITモジュール化したものまで、あるようです。なお、(3)はコード生成機能で生成されたソースはあるもののコード生成機能の設定情報が初期値のまま(設定をセーブし忘れた?)でしたので、ソースから設定情報を推測して復元してみたのですが、コード生成プラグインのバージョンが異なる為か、コードを再生成すると若干異なるソースや追加されるソースが生成されましたので、予めコードを再生成させておいた(3')も作ってみました。

(1) an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\
(2) an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\

RX231 Group Serial Transfer Demo using RX real-time OS Package
Mar.31.17 Source, Project
( Firmware Integration Technology(FIT) / FreeRTOS )
( e2 studio project / CC-RX )
www.renesas.com/ja-jp/doc/products/mpumcu/apn/rx/002/r01an3783es0100-rx231.pdf
www.renesas.com/ja-jp/software/D6001053.html



(3) FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\
(3') FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\

FreeRTOS for Renesas RX231 (RXv2)
Supporting GCC, IAR and Renesas compilers
www.freertos.org/RX231_RTOS_Renesas_GCC_IAR.html
sourceforge.net/projects/freertos/files/FreeRTOS/V10.0.1/



プロジェクトの変換は、基本的にはrcpcファイルをe2 studio(今回はv5.4.0を使用)でエクスポートしてCS+で読み込むという手順で行いましたが、以下のようなCS+では正しく取り扱えないe2 studio(というかEclipseやCDT)の機能を利用している箇所がありますので、その後に地道に手作業で修正を行いました。

・ リンクされたフォルダ
・ コンフィグレーション設定に応じた複数のサブフォルダに同名で内容の異なるソースファイルを置く

また、うまくe2 studioからCS+へ引き継がれない以下の設定に関しても、手作業で修正を行いました。

・ コード生成先フォルダ(e2 studio側は変更不可ですがCS+側は変更可能なのでCS+側へは引き継げる筈だが)
・ リンク順序(e2 studio v5.4.0ではmapとrcpcで順序が異なる、e2 studio v6.1.0はv5.4.0と順序が異なる)

更に、それらに加え、以下のようなプロジェクトの変更も行いました。

・ 毎回全ビルドになってしまうトラブルへの対処
・ 日ごろ心がけようと思っている設定

以下はCS+で読み込んだ後の作業で私が使っていたメモです。

共通
・ プロジェクト構造の修正(ちょっと(3)と(3')では意地になってしまったが)
・ (3)と(3')のみ:コード生成先フォルダをcg_src→src\cg_srcへ修正
・ (3)と(3')のみ:r_cg_main.cをビルドから除外
・ (3)のみ:再生成時に追加されるr_cg_icu_user.cとr_cg_port_user.cをビルドから除外した状態で追加
・ (3')のみ:r_cg_interrupt_handler.hはGCC向けにコード生成したものの残骸のようなので削除
・ リンク順序を修正(e2 studioとCS+で同じmotファイルになるように)
・ インクルードパスの修正
・ ソースリストファイルを出力する
・ C/C++ソースを出力する
・ インクルードファイルが存在しないソースの扱い:再コンパイル/アセンブルしない

コンパイルオプション
・ クロスリファレンス情報を出力する

リンクオプション
・ リンケージリストファイルを出力する:はい(リスト内容=すべて)
・ スタック使用量情報ファイルを出力する:はい
・ 合計セクションサイズを出力する:はい

zipファイルの内容は以下の通りです。

(1) an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\

e2 studioでのmapファイルは詳細出力(All)に変えています。(rcpcファイルをエクスポートした後に変更)
rcpcファイルをエクスポートした時点では、元々のプロジェクトから設定を変更していません。
e2 studio V5.4.0でのmotファイルとCS+ for CC(V6.00.00(2017/10/05版))でのmotファイルは一致しました。
(当方特有の事情でCC-RX V2.03を使用しました。元々のプロジェクトではV2.05が使用されています。)

an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\RX231_realtime_OS_pkg.mtpj
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\RX231_realtime_OS_pkg.rcpe
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\プロジェクト変換情報_RX231_realtime_OS_pkg.txt
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\RX231_realtime_OS_pkg.rcpc
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\USBPeripheral_LinkOrder_from_MAP_file_for_CS+.mtls
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\USB_Host_LinkOrder_from_MAP_file_for_CS+.mtls
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\USBPeripheral_csp_build\RX231_realtime_OS_pkg.map
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\USBPeripheral_e2v540_build\RX231_realtime_OS_pkg.map
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\USB_host_csp_build\RX231_realtime_OS_pkg.map
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\USB_host_e2v540_build\RX231_realtime_OS_pkg.map

(2) an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\

e2 studioでのmapファイルは詳細出力(All)に変えています。(rcpcファイルをエクスポートした後に変更)
なお、アプリケーションノートの手順に従ってe2 studioのプロジェクトを完成させる必要があります。
そして、プロジェクトを完成させた後に、rcpcファイルをエクスポートするようにしました。
e2 studio V5.4.0でのmotファイルとCS+ for CC(V6.00.00(2017/10/05版))でのmotファイルは一致しました。
(当方特有の事情でCC-RX V2.03を使用しました。元々のプロジェクトではV2.05が使用されています。)

an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\serial_transfer.mtpj
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\serial_transfer.rcpe
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\プロジェクト変換情報_serial_transfer.txt
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\serial_transfer.rcpc
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\LinkOrder_from_MAP_file_for_CS+.mtls
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\Debug_csp_build\serial_transfer.map
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\Debug_e2v540_build\serial_transfer.map
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\HardwareDebug_csp_build\serial_transfer.map
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\HardwareDebug_e2v540_build\serial_transfer.map
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\r_config\modified\r_irq_rx_config.h
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\r_config\modified\r_sci_rx_config.h
an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\Settings_of_IncludePaths_and_Macros.xml

(3) FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\

元々のFreeRTOSv10.0.1のcgproject.cgpは今回復元されたファイルで上書きされます。
e2 studioでのmapファイルは詳細出力(All)に変えています。(rcpcファイルをエクスポートした後に変更)
rcpcファイルをエクスポートした時点では、元々のプロジェクトから設定を変更していません。
e2 studio V5.4.0でのmotファイルとCS+ for CC(V6.00.00(2017/10/05版))でのmotファイルは一致しました。
(当方特有の事情でCC-RX V2.03を使用しましたが、元々のプロジェクトでもV2.03が使用されています。)

FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\RTOSDemo.mtpj
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\RTOSDemo.rcpe
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\RTOSDemo.rcpc
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\プロジェクト変換情報_RTOSDemo.txt
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\.settings\CodeGenerator\cgproject.cgp
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\LinkOrder_from_MAP_file_for_CS+.mtls
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\HardwareDebug_csp_build\RTOSDemo.map
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\HardwareDebug_e2v540_build\RTOSDemo.map

(3') FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\

CS+のみです。
CS+ for CC (V6.00.00(2017/10/05版))でコード生成させています。
(当方特有の事情でCC-RX V2.03を使用しました。)

FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\RTOSDemo.mtpj
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\RTOSDemo.rcpe
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\HardwareDebug_csp_build\RTOSDemo.map
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\Blinky_Demo\main_blinky.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_cgc.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_cgc.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_cgc_user.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_dbsct.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_hardware_setup.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_icu.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_icu.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_icu_user.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_intprg.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_macrodriver.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_main.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_port.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_port.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_port_user.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_resetprg.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_sbrk.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_sbrk.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_stacksct.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_userdefine.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_vect.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\cg_src\r_cg_vecttbl.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\Full_Demo\IntQueueTimer.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\Full_Demo\IntQueueTimer.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\Full_Demo\main_full.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\Renesas_Code\stacksct.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\Renesas_Code\typedefine.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\Renesas_Code\vect.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\FreeRTOSConfig.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\iodefine.h
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\main.c
FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\src\rskrx231def.h

以下、雰囲気が分かるような画面コピーです。

(1) an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\RX231_realtime_OS_pkg\





(2) an-r01an3783es0100-rx231-connectivity\RX231_FreeRTOS_pkg\Demo\serial_transfer\








(3) FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_e2studio\




(3') FreeRTOSv10.0.1\FreeRTOS\Demo\RX200_RX231-RSK_Renesas_CS+\










Parents
  • こんにちは。NoMaYです。

    作業結果的に、st1011さんが移植されたRX65N_TB_FreeRTOS_Full_Demo版を、FreeRTOS 10.2.1のソースとe2 studio v7.4.0で生成したFreeRTOSプロジェクトのソースを使って、CS+プロジェクトへ焼き直した形になりました。以下、プロジェクトのファイル一式です。(CS+ V8.01+CC-RX V2.03でビルド)(e2 studio用.project/.cproject等を同梱(zipファイルをe2 studioに直接インポート可能)) なお、長時間運転は検証中です。

    tb_rx65n_scfg_freertos_ccrx_c_csplus_20190522.zip    872KB

    なお、プロジェクトのベースは先日「RenesasさんからRXマイコンの低価格Target Boardが出たのでサンプルプログラムをCSplus projectへ変換してみようと思います」のスレッドに投稿したものです。コード生成する時は、そのスレッドに書いたように、RXスマートコンフィグレータの設定をデフォルトの[コンポーネントが存在する場合は何もしない]のままにして下さい。また、IDコードとして、そのスレッドに書いたように、RXスマートコンフィグレータ上で同じIDコードを設定しています。

    今回、スタンドアロン版のスマートコンフィグレータがRXファミリ Renesas FreeRTOSモジュールに現状では未対応のようでしたので、BSPモジュールのRTOSサポートを有効にする為に、r_bsp_config.hに以下の小細工(赤文字箇所)を追加しました。(そして、コンパイルオプションのマクロ定義でBSP_CFG_RTOS_USED=1を設定することにしました。) また、r_bsp_config.hでのRTOS System Timerの選択(緑文字箇所)がFreeRTOSConfig.hに引き継がれるようにする為(緑文字箇所)に、freertos_start.hに小細工(緑文字箇所)を追加しました。

    r_bsp_config.h

    /* This macro lets other modules no if a RTOS is being used.
       0 = RTOS is not used.
       1 = FreeRTOS is used.
       2 = embOS is used.(This is not available.)
       3 = MicroC_OS is used.(This is not available.)
       4 = RI600V4 or RI600PX is used.(This is not available.)
    */
    #if !defined(BSP_CFG_RTOS_USED) || (BSP_CFG_RTOS_USED == 0)
    #if defined(BSP_CFG_RTOS_USED)
    #undef BSP_CFG_RTOS_USED
    #endif
    #define BSP_CFG_RTOS_USED               (0) /* Generated value. Do not edit this manually */
    #endif

    /* This macro is used to select which CMT channel used for system timer of RTOS.
     * The setting of this macro is only valid if the macro BSP_CFG_RTOS_USED is set to a value other than 0. */
    #if (BSP_CFG_RTOS_USED != 0)
    /* Setting value.
     * 0      = CMT channel 0 used for system timer of RTOS (recommended to be used for RTOS).
     * 1      = CMT channel 1 used for system timer of RTOS.
     * 2      = CMT channel 2 used for system timer of RTOS.
     * 3      = CMT channel 3 used for system timer of RTOS.
     * Others = Invalid. */
    #define BSP_CFG_RTOS_SYSTEM_TIMER       (3)
    #endif

    freertos_start.h

    /* Interrupt vector of CMT channel used for system timer of RTOS */
    #ifndef BSP_CFG_RTOS_SYSTEM_TIMER
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is necessary."
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 0
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT0_CMI0
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 1
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT1_CMI1
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 2
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT2_CMI2
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 3
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT3_CMI3
    #else
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is invalid."
    #endif

    FreeRTOSConfig.h

    #define configTICK_VECTOR                       BSP_RTOS_SYSTEM_TIMER_VECTOR

    なお、e2 studioで生成したFreeRTOSプロジェクトのFreeRTOSConfig.hでは、CPU動作周波数と内蔵周辺動作周波数はBSPモジュールの値が引き継がれるようになっていましたので、今回のFreeRTOSConfig.hも同じ(青文字箇所)ようにしています。

    FreeRTOSConfig.h

    #define configCPU_CLOCK_HZ              ( BSP_ICLK_HZ )
    #define configPERIPHERAL_CLOCK_HZ       ( BSP_PCLKB_HZ )

    あと、今回のFreeRTOSConfig.hでは、FreeRTOS 10.2.0からサポートされた以下のマクロ定義も追加しました。

    FreeRTOSConfig.h

    #define configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H    1

    今回、デモ関数は以下のようにfreertos_start.cのProcessing_Before_Start_Kernel()から呼び出す(橙文字箇所)ようにしました。

    freertos_start.c

    void Processing_Before_Start_Kernel(void)
    {
        ...略...

    #if( FREERTOS_USER_MAIN == 1 )
        /************** task creation ****************************/
        /* Main task. */
        ret = xTaskCreate(main_task, "MAIN_TASK", 512, NULL, 3, NULL);
        if (pdPASS != ret)
        {
            while(1)
            {
                /* Failed! Task can not be created. */
            }
        }
    #else

        /* Configure the hardware ready to run the demo. */
        prvSetupHardware();

        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
        of this file. */
        #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
        {
            main_blinky();
        }
        #else
        {
            main_full();
        }
        #endif

    #endif

    } /* End of function Processing_Before_Start_Kernel() */

    ちなみに、以下のTBボードのサンプルプログラムのmain()そのままであるmain_task()もFreeRTOSConfig.hでFREERTOS_USER_MAINのデファインを1に切り替えることで実行出来ます。

    tb_rx65n_main.c

    void main_task(void *pvParameters)
    {
        (void) pvParameters;

        LED0 = LED_OFF;
        LED1 = LED_OFF;

        if (SW1_PUSH == SW1) /* SW1: PUSH = Manual Mode, Other = Auto Mode */
        {
            R_Config_ICU_IRQ4_Start();
        }
        else
        {
            R_Config_CMT0_Start();
        }
        while(1)
        {
            ; /* Blink LED0, LED1 Alternately by Interrupt */
        }
    }

    以下、今回のFreeRTOSConfig.hとfreertos_start.cとfreertos_start.hの全体です。

    FreeRTOSConfig.h

    5224.FreeRTOSConfig_h_20190522.txt
    /*
     * FreeRTOS Kernel V10.2.1
     * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy of
     * this software and associated documentation files (the "Software"), to deal in
     * the Software without restriction, including without limitation the rights to
     * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
     * the Software, and to permit persons to whom the Software is furnished to do so,
     * subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in all
     * copies or substantial portions of the Software.
     *
     * 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
     * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
     * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     *
     * http://www.FreeRTOS.org
     * http://aws.amazon.com/freertos
     *
     * 1 tab == 4 spaces!
     */
    
    #ifndef FREERTOS_CONFIG_H
    #define FREERTOS_CONFIG_H
    
    /* Prevent Renesas headers redefining some stdint.h types. */
    #define __TYPEDEF__	1
    
    /*-----------------------------------------------------------
     * Application specific definitions.
     *
     * These definitions should be adjusted for your particular hardware and
     * application requirements.
     *
     * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
     * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
     *
     * See http://www.freertos.org/a00110.html
     *----------------------------------------------------------*/
    
    #define configUSE_PREEMPTION			1
    #define configUSE_IDLE_HOOK				1
    #define configUSE_TICK_HOOK				1
    #define configCPU_CLOCK_HZ				( BSP_ICLK_HZ )
    #define configPERIPHERAL_CLOCK_HZ		( BSP_PCLKB_HZ )
    #define configTICK_RATE_HZ				( ( TickType_t ) 1000 )
    #define configMINIMAL_STACK_SIZE		( ( unsigned short ) 140 )
    #define configTOTAL_HEAP_SIZE			( ( size_t ) ( 300 * 1024 ) )
    #define configMAX_TASK_NAME_LEN			( 12 )
    #define configUSE_TRACE_FACILITY		1
    #define configUSE_16_BIT_TICKS			0
    #define configIDLE_SHOULD_YIELD			1
    #define configUSE_CO_ROUTINES 			0
    #define configUSE_MUTEXES				1
    #define configGENERATE_RUN_TIME_STATS	0
    #define configCHECK_FOR_STACK_OVERFLOW	2
    #define configUSE_RECURSIVE_MUTEXES		1
    #define configQUEUE_REGISTRY_SIZE		20
    #define configUSE_MALLOC_FAILED_HOOK	1
    #define configUSE_APPLICATION_TASK_TAG	0
    #define configUSE_QUEUE_SETS			1
    #define configUSE_COUNTING_SEMAPHORES	1
    #define configMAX_PRIORITIES			( 7 )
    #define configMAX_CO_ROUTINE_PRIORITIES	( 2 )
    
    /* This demo makes use of one or more example stats formatting functions.  These
    format the raw data provided by the uxTaskGetSystemState() function in to human
    readable ASCII form.  See the notes in the implementation of vTaskList() within
    FreeRTOS/Source/tasks.c for limitations. */
    #define configUSE_STATS_FORMATTING_FUNCTIONS	1
    
    /* Software timer definitions. */
    #define configUSE_TIMERS				1
    #define configTIMER_TASK_PRIORITY		( configMAX_PRIORITIES - 1 )
    #define configTIMER_QUEUE_LENGTH		5
    #define configTIMER_TASK_STACK_DEPTH	( configMINIMAL_STACK_SIZE )
    
    /* The interrupt priority used by the kernel itself for the tick interrupt and
    the pended interrupt.  This would normally be the lowest priority. */
    #define configKERNEL_INTERRUPT_PRIORITY			1
    
    /* The maximum interrupt priority from which FreeRTOS API calls can be made.
    Interrupts that use a priority above this will not be effected by anything the
    kernel is doing. */
    #define configMAX_SYSCALL_INTERRUPT_PRIORITY	4
    
    /* The peripheral used to generate the tick interrupt is configured as part of
    the application code.  This constant should be set to the vector number of the
    peripheral chosen.  As supplied this is CMT0. */
    #define configTICK_VECTOR						BSP_RTOS_SYSTEM_TIMER_VECTOR
    
    /* When the FIT configurator or the Smart Configurator is used, platform.h has
    to be used. */
    #define configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H	1
    
    /* 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		0
    #define INCLUDE_vTaskSuspend				1
    #define INCLUDE_vTaskDelayUntil				1
    #define INCLUDE_vTaskDelay					1
    #define INCLUDE_uxTaskGetStackHighWaterMark	1
    #define INCLUDE_xTaskGetSchedulerState		1
    #define INCLUDE_eTaskGetState				1
    #define INCLUDE_xTimerPendFunctionCall		1
    
    void vAssertCalled( void );
    #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled()
    
    /* Override some of the priorities set in the common demo tasks.  This is
    required to ensure flase positive timing errors are not reported. */
    #define bktPRIMARY_PRIORITY		( configMAX_PRIORITIES - 3 )
    #define bktSECONDARY_PRIORITY	( configMAX_PRIORITIES - 4 )
    #define intqHIGHER_PRIORITY		( configMAX_PRIORITIES - 3 )
    
    /* Set FREERTOS_USER_MAIN to one to run an user main other than test/demo main. */
    #define FREERTOS_USER_MAIN					0
    
    /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
    or 0 to run the more comprehensive test and demo application. */
    #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY	0
    
    /* Additional definitions for the more comprehensive test and demo application. */
    #define configSUPPORT_DYNAMIC_ALLOCATION	1
    #define configAPPLICATION_ALLOCATED_HEAP	1
    
    #endif /* FREERTOS_CONFIG_H */
    


    freertos_start.c
    5224.freertos_start_c_20190522.txt
    /*******************************************************************************
    * DISCLAIMER
    * This software is supplied by Renesas Electronics Corporation and is only 
    * intended for use with Renesas products. No other uses are authorized. This 
    * software is owned by Renesas Electronics Corporation and is protected under
    * all applicable laws, including copyright laws.
    * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
    * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
    * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
    * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
    * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 
    * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 
    * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
    * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
    * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    * Renesas reserves the right, without notice, to make changes to this software
    * and to discontinue the availability of this software. By using this software,
    * you agree to the additional terms and conditions found by accessing the 
    * following link:
    * http://www.renesas.com/disclaimer
    * Copyright (C) 2018 Renesas Electronics Corporation. All rights reserved.    
    *******************************************************************************/
    /*******************************************************************************
    * File Name    : freertos_start.c
    * Version      : 1.0
    * Description  : Contains FreeRTOS user-defined functions.
    ******************************************************************************/
    /*****************************************************************************
    * History : DD.MM.YYYY Version  Description
    *         : 30.06.2016 1.00     First Release
    ******************************************************************************/
    
    /******************************************************************************
    Includes   <System Includes> , "Project Includes"
    ******************************************************************************/
    #include "platform.h"
    #include "freertos_start.h"
    
    #if (BSP_CFG_RTOS_USED == 1)
    
    #if (RTOS_USB_SUPPORT == 1)
    #include "r_usb_basic_if.h"
    #include "r_usb_cstd_rtos.h"
    #endif
    
    /******************************************************************************
    Macro definitions
    ******************************************************************************/
    
    /******************************************************************************
    Typedef definitions
    ******************************************************************************/
    
    /******************************************************************************
    Private global variables and functions
    ******************************************************************************/
    
    /************* semaphore initialization *****************/
    
    /******************************************************************************
    Exported global variables (to be accessed by other files)
    ******************************************************************************/
    
    /* Allocate a large heap for the full demo. */
    #if configAPPLICATION_ALLOCATED_HEAP == 1
        #pragma section OSW
        uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
        #pragma section
    #endif /* #if configAPPLICATION_ALLOCATED_HEAP == 1 */
    
    /******************************************************************************
    Exported global functions (to be accessed by other files)
    ******************************************************************************/
    
    /* FreeRTOS's system timer. */
    void vApplicationSetupTimerInterrupt(void);
    
    /* Hook functions used by FreeRTOS. */
    void vAssertCalled(void);
    void vApplicationIdleHook(void);
    void vApplicationTickHook(void);
    void vApplicationMallocFailedHook(void);
    void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName);
    
    /* FreeRTOS's processing before start the kernel. */
    void Processing_Before_Start_Kernel(void);
    
    /* Main task. */
    extern void main_task(void *pvParameters);
    
    /*
     * Only the comprehensive demo uses application hook (callback) functions.  See
     * http://www.freertos.org/a00016.html for more information.
     */
    void vFullDemoTickHookFunction( void );
    void vFullDemoIdleFunction( void );
    
    /*
     * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
     * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
     */
    #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
        extern void main_blinky( void );
    #else
        extern void main_full( void );
    #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */
    
    static void prvSetupHardware( void );
    void vParTestInitialise( void );
    
    /******************************************************************************
    * Function Name: vApplicationSetupTimerInterrupt
    * Description  : Initialize system timer for FreeRTOS with tick interrupt 1ms.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationSetupTimerInterrupt(void)
    {
    	/* CMT channel 0 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 0)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 0. */
        MSTP( CMT0 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR0.BIT.STR0 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT0.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT0.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT0, CMI0)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT0, CMI0) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT0, CMI0) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 0. */
        CMT.CMSTR0.BIT.STR0 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 0) */
    
        /* CMT channel 1 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 1)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 1. */
        MSTP( CMT1 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR0.BIT.STR1 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT1.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT1.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT1.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT1, CMI1)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT1, CMI1) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT1, CMI1) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 1. */
        CMT.CMSTR0.BIT.STR1 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 1) */
    
        /* CMT channel 2 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 2)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 2. */
        MSTP( CMT2 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR1.BIT.STR2 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT2.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT2.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT2.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT2, CMI2)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT2, CMI2) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT2, CMI2) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 2. */
        CMT.CMSTR1.BIT.STR2 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 2) */
    
        /* CMT channel 3 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 3)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 3. */
        MSTP( CMT3 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR1.BIT.STR3 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT3.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT3.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT3.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT3, CMI3)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT3, CMI3) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT3, CMI3) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 3. */
        CMT.CMSTR1.BIT.STR3 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 3) */
    
    } /* End of function vApplicationSetupTimerInterrupt() */
    
    /******************************************************************************
    * Function Name: vAssertCalled
    * Description  : This function is used to validate the input parameters.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vAssertCalled(void)
    {
        volatile unsigned long ul = 0;
    
        taskENTER_CRITICAL();
        {
            /* Use the debugger to set ul to a non-zero value in order to step out
            of this function to determine why it was called. */
            while( 0 == ul )
            {
                portNOP();
            }
        }
        taskEXIT_CRITICAL();
    
    } /* End of function vAssertCalled() */
    
    /******************************************************************************
    * Function Name: vApplicationIdleHook
    * Description  : This function will be called on each cycle of the idle task.
    *                NOTE: vApplicationIdleHook() MUST NOT CALL A FUNCTION
    *                      THAT MIGHT BLOCK UNDER ANY CIRCUMSTANCES.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationIdleHook(void)
    {
        /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
        to 1 in FreeRTOSConfig.h.  It will be called on each iteration of the idle
        task.  It is essential that code added to this hook function never attempts
        to block in any way (for example, call xQueueReceive() with a block time
        specified, or call vTaskDelay()).  If application tasks make use of the
        vTaskDelete() API function to delete themselves then it is also important
        that vApplicationIdleHook() is permitted to return to its calling function,
        because it is the responsibility of the idle task to clean up memory
        allocated by the kernel to any task that has since deleted itself. */
    
        #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
        {
            /* Call the idle task processing used by the full demo.  The simple
            blinky demo does not use the idle task hook. */
            vFullDemoIdleFunction();
        }
        #endif
    } /* End of function vApplicationIdleHook() */
    
    /******************************************************************************
    * Function Name: vApplicationTickHook
    * Description  : This function will be called every tick interrupt.
    *                NOTE: vApplicationTickHook() EXECUTES FROM WITHIN AN ISR,
    *                      SO MUST BE VERY SHORT AND NOT USE MUCH STACK.
    *                      IN ADDITION, NOT CALL ANY APIs WITHOUT "FromISR" OR
    *                      "FROM_ISR" AT THE END.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationTickHook(void)
    {
        /* This function will be called by each tick interrupt if
        configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h.  User code can be
        added here, but the tick hook is called from an interrupt context, so
        code must not attempt to block, and only the interrupt safe FreeRTOS API
        functions can be used (those that end in FromISR()). */
    
        #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
        {
            vFullDemoTickHookFunction();
        }
        #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */
    } /* End of function vApplicationTickHook() */
    
    /******************************************************************************
    * Function Name: vApplicationMallocFailedHook
    * Description  : This function is to capture the failure while
    *                memory allocation.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationMallocFailedHook(void)
    {
        /* Called if a call to pvPortMalloc() fails because there is insufficient
        free memory available in the FreeRTOS heap.  pvPortMalloc() is called
        internally by FreeRTOS API functions that create tasks, queues, software
        timers, and semaphores.  The size of the FreeRTOS heap is set by the
        configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
    
        taskDISABLE_INTERRUPTS();
        for( ; ; )
        {
            /* Loop here */
        };
    
    } /* End of function vApplicationMallocFailedHook() */
    
    /******************************************************************************
    * Function Name: vApplicationStackOverflowHook
    * Description  : Hook function is to capture the failure when the stack size
    *                is insufficient for processing.
    * Arguments    : pxTask -
    *                    Task handler
    *                pcTaskName -
    *                    Pointer of where to store the task's name
    * Return Value : None.
    ******************************************************************************/
    void vApplicationStackOverflowHook(TaskHandle_t pxTask, signed char *pcTaskName)
    {
        ( void ) pcTaskName;
        ( void ) pxTask;
    
        /* Run time stack overflow checking is performed if
        configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook
        function is called if a stack overflow is detected. */
    
        taskDISABLE_INTERRUPTS();
        for( ; ; )
        {
            /* Loop here */
        };
    
    } /* End of function vApplicationStackOverflowHook() */
    
    /******************************************************************************
    * Function Name : Processing_Before_Start_Kernel
    * Description   : Create a main task, FreeRTOS's objects (e.g. mailbox, task,
    *                 semaphore, mutex...) if required.
    * Arguments     : None.
    * Return value  : None.
    ******************************************************************************/
    void Processing_Before_Start_Kernel(void)
    {
        BaseType_t ret;
    
        /************** semaphore creation ***********************/
    
    
        /************** mutex creation ***************************/
    
    
        /************** queues creation **************************/
    
    
        /************** event groups creation ********************/
    
    
        /************** mailbox creation *************************/
    
    
        /************** memory pool creation *********************/
    
        /** USB RTOS Configuration **/
    #if (RTOS_USB_SUPPORT == 1)
        usb_rtos_err_t err = usb_rtos_configuration();
        if (UsbRtos_Success != err)
        {
            while(1)
            {
                /** Failure of UsbRtos Configuration **/
            }
        }
    #endif
    
        Kernel_Object_init();
    
    #if( FREERTOS_USER_MAIN == 1 )
        /************** task creation ****************************/
        /* Main task. */
        ret = xTaskCreate(main_task, "MAIN_TASK", 512, NULL, 3, NULL);
        if (pdPASS != ret)
        {
            while(1)
            {
                /* Failed! Task can not be created. */
            }
        }
    #else
    
        /* Configure the hardware ready to run the demo. */
        prvSetupHardware();
    
        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
        of this file. */
        #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
        {
            main_blinky();
        }
        #else
        {
            main_full();
        }
        #endif
    
    #endif
    
    } /* End of function Processing_Before_Start_Kernel() */
    
    static void prvSetupHardware( void )
    {
        /* Set up the ports used by the LED outputs (the name ParTest is now
        obsolete - it originally came from "parallel port test"). */
        vParTestInitialise();
    }
    
    #endif /* (BSP_CFG_RTOS_USED == 1) */
    
    
    


    freertos_start.h
    4666.freertos_start_h_20190522.txt
    /*******************************************************************************
    * DISCLAIMER
    * This software is supplied by Renesas Electronics Corporation and is only 
    * intended for use with Renesas products. No other uses are authorized. This 
    * software is owned by Renesas Electronics Corporation and is protected under
    * all applicable laws, including copyright laws.
    * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
    * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
    * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
    * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
    * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 
    * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 
    * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
    * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
    * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    * Renesas reserves the right, without notice, to make changes to this software
    * and to discontinue the availability of this software. By using this software,
    * you agree to the additional terms and conditions found by accessing the 
    * following link:
    * http://www.renesas.com/disclaimer
    * Copyright (C) 2018 Renesas Electronics Corporation. All rights reserved.    
    *******************************************************************************/
    /*******************************************************************************
    * File Name    : freertos_start.h
    * Version      : 1.0
    * Description  : FreeRTOS's user-defined functions header file.
    ******************************************************************************/
    /*****************************************************************************
    * History : DD.MM.YYYY Version  Description
    *         : 30.06.2016 1.00     First Release
    ******************************************************************************/
    
    #ifndef FREERTOS_START_H_
    #define FREERTOS_START_H_
    
    /******************************************************************************
    Macro definitions
    ******************************************************************************/
    /* USB FIT module support macro */
    #define RTOS_USB_SUPPORT   0
    
    /* Interrupt vector of CMT channel used for system timer of RTOS */
    #ifndef BSP_CFG_RTOS_SYSTEM_TIMER
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is necessary."
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 0
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT0_CMI0
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 1
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT1_CMI1
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 2
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT2_CMI2
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 3
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT3_CMI3
    #else
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is invalid."
    #endif
    
    /******************************************************************************
    Typedef definitions
    ******************************************************************************/
    
    /******************************************************************************
    Exported global variables
    ******************************************************************************/
    /************* semaphore handler *****************/
    
    
    /************* mutex handler *********************/
    
    
    /************** queues handler *******************/
    
    
    /************** event groups handler *************/
    
    
    /************** mailbox handler ******************/
    
    
    /************** memory pool handler **************/
    
    
    /************** task handler *********************/
    
    
    /******************************************************************************
    Exported global functions (to be accessed by other files)
    ******************************************************************************/
    extern void Processing_Before_Start_Kernel(void);
    extern void Kernel_Object_init(void);
    
    #endif /* FREERTOS_START_H_ */
    


    以下、CS+の画面コピーです。

Reply
  • こんにちは。NoMaYです。

    作業結果的に、st1011さんが移植されたRX65N_TB_FreeRTOS_Full_Demo版を、FreeRTOS 10.2.1のソースとe2 studio v7.4.0で生成したFreeRTOSプロジェクトのソースを使って、CS+プロジェクトへ焼き直した形になりました。以下、プロジェクトのファイル一式です。(CS+ V8.01+CC-RX V2.03でビルド)(e2 studio用.project/.cproject等を同梱(zipファイルをe2 studioに直接インポート可能)) なお、長時間運転は検証中です。

    tb_rx65n_scfg_freertos_ccrx_c_csplus_20190522.zip    872KB

    なお、プロジェクトのベースは先日「RenesasさんからRXマイコンの低価格Target Boardが出たのでサンプルプログラムをCSplus projectへ変換してみようと思います」のスレッドに投稿したものです。コード生成する時は、そのスレッドに書いたように、RXスマートコンフィグレータの設定をデフォルトの[コンポーネントが存在する場合は何もしない]のままにして下さい。また、IDコードとして、そのスレッドに書いたように、RXスマートコンフィグレータ上で同じIDコードを設定しています。

    今回、スタンドアロン版のスマートコンフィグレータがRXファミリ Renesas FreeRTOSモジュールに現状では未対応のようでしたので、BSPモジュールのRTOSサポートを有効にする為に、r_bsp_config.hに以下の小細工(赤文字箇所)を追加しました。(そして、コンパイルオプションのマクロ定義でBSP_CFG_RTOS_USED=1を設定することにしました。) また、r_bsp_config.hでのRTOS System Timerの選択(緑文字箇所)がFreeRTOSConfig.hに引き継がれるようにする為(緑文字箇所)に、freertos_start.hに小細工(緑文字箇所)を追加しました。

    r_bsp_config.h

    /* This macro lets other modules no if a RTOS is being used.
       0 = RTOS is not used.
       1 = FreeRTOS is used.
       2 = embOS is used.(This is not available.)
       3 = MicroC_OS is used.(This is not available.)
       4 = RI600V4 or RI600PX is used.(This is not available.)
    */
    #if !defined(BSP_CFG_RTOS_USED) || (BSP_CFG_RTOS_USED == 0)
    #if defined(BSP_CFG_RTOS_USED)
    #undef BSP_CFG_RTOS_USED
    #endif
    #define BSP_CFG_RTOS_USED               (0) /* Generated value. Do not edit this manually */
    #endif

    /* This macro is used to select which CMT channel used for system timer of RTOS.
     * The setting of this macro is only valid if the macro BSP_CFG_RTOS_USED is set to a value other than 0. */
    #if (BSP_CFG_RTOS_USED != 0)
    /* Setting value.
     * 0      = CMT channel 0 used for system timer of RTOS (recommended to be used for RTOS).
     * 1      = CMT channel 1 used for system timer of RTOS.
     * 2      = CMT channel 2 used for system timer of RTOS.
     * 3      = CMT channel 3 used for system timer of RTOS.
     * Others = Invalid. */
    #define BSP_CFG_RTOS_SYSTEM_TIMER       (3)
    #endif

    freertos_start.h

    /* Interrupt vector of CMT channel used for system timer of RTOS */
    #ifndef BSP_CFG_RTOS_SYSTEM_TIMER
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is necessary."
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 0
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT0_CMI0
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 1
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT1_CMI1
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 2
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT2_CMI2
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 3
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT3_CMI3
    #else
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is invalid."
    #endif

    FreeRTOSConfig.h

    #define configTICK_VECTOR                       BSP_RTOS_SYSTEM_TIMER_VECTOR

    なお、e2 studioで生成したFreeRTOSプロジェクトのFreeRTOSConfig.hでは、CPU動作周波数と内蔵周辺動作周波数はBSPモジュールの値が引き継がれるようになっていましたので、今回のFreeRTOSConfig.hも同じ(青文字箇所)ようにしています。

    FreeRTOSConfig.h

    #define configCPU_CLOCK_HZ              ( BSP_ICLK_HZ )
    #define configPERIPHERAL_CLOCK_HZ       ( BSP_PCLKB_HZ )

    あと、今回のFreeRTOSConfig.hでは、FreeRTOS 10.2.0からサポートされた以下のマクロ定義も追加しました。

    FreeRTOSConfig.h

    #define configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H    1

    今回、デモ関数は以下のようにfreertos_start.cのProcessing_Before_Start_Kernel()から呼び出す(橙文字箇所)ようにしました。

    freertos_start.c

    void Processing_Before_Start_Kernel(void)
    {
        ...略...

    #if( FREERTOS_USER_MAIN == 1 )
        /************** task creation ****************************/
        /* Main task. */
        ret = xTaskCreate(main_task, "MAIN_TASK", 512, NULL, 3, NULL);
        if (pdPASS != ret)
        {
            while(1)
            {
                /* Failed! Task can not be created. */
            }
        }
    #else

        /* Configure the hardware ready to run the demo. */
        prvSetupHardware();

        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
        of this file. */
        #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
        {
            main_blinky();
        }
        #else
        {
            main_full();
        }
        #endif

    #endif

    } /* End of function Processing_Before_Start_Kernel() */

    ちなみに、以下のTBボードのサンプルプログラムのmain()そのままであるmain_task()もFreeRTOSConfig.hでFREERTOS_USER_MAINのデファインを1に切り替えることで実行出来ます。

    tb_rx65n_main.c

    void main_task(void *pvParameters)
    {
        (void) pvParameters;

        LED0 = LED_OFF;
        LED1 = LED_OFF;

        if (SW1_PUSH == SW1) /* SW1: PUSH = Manual Mode, Other = Auto Mode */
        {
            R_Config_ICU_IRQ4_Start();
        }
        else
        {
            R_Config_CMT0_Start();
        }
        while(1)
        {
            ; /* Blink LED0, LED1 Alternately by Interrupt */
        }
    }

    以下、今回のFreeRTOSConfig.hとfreertos_start.cとfreertos_start.hの全体です。

    FreeRTOSConfig.h

    5224.FreeRTOSConfig_h_20190522.txt
    /*
     * FreeRTOS Kernel V10.2.1
     * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy of
     * this software and associated documentation files (the "Software"), to deal in
     * the Software without restriction, including without limitation the rights to
     * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
     * the Software, and to permit persons to whom the Software is furnished to do so,
     * subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in all
     * copies or substantial portions of the Software.
     *
     * 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
     * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
     * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     *
     * http://www.FreeRTOS.org
     * http://aws.amazon.com/freertos
     *
     * 1 tab == 4 spaces!
     */
    
    #ifndef FREERTOS_CONFIG_H
    #define FREERTOS_CONFIG_H
    
    /* Prevent Renesas headers redefining some stdint.h types. */
    #define __TYPEDEF__	1
    
    /*-----------------------------------------------------------
     * Application specific definitions.
     *
     * These definitions should be adjusted for your particular hardware and
     * application requirements.
     *
     * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
     * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
     *
     * See http://www.freertos.org/a00110.html
     *----------------------------------------------------------*/
    
    #define configUSE_PREEMPTION			1
    #define configUSE_IDLE_HOOK				1
    #define configUSE_TICK_HOOK				1
    #define configCPU_CLOCK_HZ				( BSP_ICLK_HZ )
    #define configPERIPHERAL_CLOCK_HZ		( BSP_PCLKB_HZ )
    #define configTICK_RATE_HZ				( ( TickType_t ) 1000 )
    #define configMINIMAL_STACK_SIZE		( ( unsigned short ) 140 )
    #define configTOTAL_HEAP_SIZE			( ( size_t ) ( 300 * 1024 ) )
    #define configMAX_TASK_NAME_LEN			( 12 )
    #define configUSE_TRACE_FACILITY		1
    #define configUSE_16_BIT_TICKS			0
    #define configIDLE_SHOULD_YIELD			1
    #define configUSE_CO_ROUTINES 			0
    #define configUSE_MUTEXES				1
    #define configGENERATE_RUN_TIME_STATS	0
    #define configCHECK_FOR_STACK_OVERFLOW	2
    #define configUSE_RECURSIVE_MUTEXES		1
    #define configQUEUE_REGISTRY_SIZE		20
    #define configUSE_MALLOC_FAILED_HOOK	1
    #define configUSE_APPLICATION_TASK_TAG	0
    #define configUSE_QUEUE_SETS			1
    #define configUSE_COUNTING_SEMAPHORES	1
    #define configMAX_PRIORITIES			( 7 )
    #define configMAX_CO_ROUTINE_PRIORITIES	( 2 )
    
    /* This demo makes use of one or more example stats formatting functions.  These
    format the raw data provided by the uxTaskGetSystemState() function in to human
    readable ASCII form.  See the notes in the implementation of vTaskList() within
    FreeRTOS/Source/tasks.c for limitations. */
    #define configUSE_STATS_FORMATTING_FUNCTIONS	1
    
    /* Software timer definitions. */
    #define configUSE_TIMERS				1
    #define configTIMER_TASK_PRIORITY		( configMAX_PRIORITIES - 1 )
    #define configTIMER_QUEUE_LENGTH		5
    #define configTIMER_TASK_STACK_DEPTH	( configMINIMAL_STACK_SIZE )
    
    /* The interrupt priority used by the kernel itself for the tick interrupt and
    the pended interrupt.  This would normally be the lowest priority. */
    #define configKERNEL_INTERRUPT_PRIORITY			1
    
    /* The maximum interrupt priority from which FreeRTOS API calls can be made.
    Interrupts that use a priority above this will not be effected by anything the
    kernel is doing. */
    #define configMAX_SYSCALL_INTERRUPT_PRIORITY	4
    
    /* The peripheral used to generate the tick interrupt is configured as part of
    the application code.  This constant should be set to the vector number of the
    peripheral chosen.  As supplied this is CMT0. */
    #define configTICK_VECTOR						BSP_RTOS_SYSTEM_TIMER_VECTOR
    
    /* When the FIT configurator or the Smart Configurator is used, platform.h has
    to be used. */
    #define configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H	1
    
    /* 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		0
    #define INCLUDE_vTaskSuspend				1
    #define INCLUDE_vTaskDelayUntil				1
    #define INCLUDE_vTaskDelay					1
    #define INCLUDE_uxTaskGetStackHighWaterMark	1
    #define INCLUDE_xTaskGetSchedulerState		1
    #define INCLUDE_eTaskGetState				1
    #define INCLUDE_xTimerPendFunctionCall		1
    
    void vAssertCalled( void );
    #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled()
    
    /* Override some of the priorities set in the common demo tasks.  This is
    required to ensure flase positive timing errors are not reported. */
    #define bktPRIMARY_PRIORITY		( configMAX_PRIORITIES - 3 )
    #define bktSECONDARY_PRIORITY	( configMAX_PRIORITIES - 4 )
    #define intqHIGHER_PRIORITY		( configMAX_PRIORITIES - 3 )
    
    /* Set FREERTOS_USER_MAIN to one to run an user main other than test/demo main. */
    #define FREERTOS_USER_MAIN					0
    
    /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
    or 0 to run the more comprehensive test and demo application. */
    #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY	0
    
    /* Additional definitions for the more comprehensive test and demo application. */
    #define configSUPPORT_DYNAMIC_ALLOCATION	1
    #define configAPPLICATION_ALLOCATED_HEAP	1
    
    #endif /* FREERTOS_CONFIG_H */
    


    freertos_start.c
    5224.freertos_start_c_20190522.txt
    /*******************************************************************************
    * DISCLAIMER
    * This software is supplied by Renesas Electronics Corporation and is only 
    * intended for use with Renesas products. No other uses are authorized. This 
    * software is owned by Renesas Electronics Corporation and is protected under
    * all applicable laws, including copyright laws.
    * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
    * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
    * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
    * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
    * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 
    * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 
    * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
    * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
    * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    * Renesas reserves the right, without notice, to make changes to this software
    * and to discontinue the availability of this software. By using this software,
    * you agree to the additional terms and conditions found by accessing the 
    * following link:
    * http://www.renesas.com/disclaimer
    * Copyright (C) 2018 Renesas Electronics Corporation. All rights reserved.    
    *******************************************************************************/
    /*******************************************************************************
    * File Name    : freertos_start.c
    * Version      : 1.0
    * Description  : Contains FreeRTOS user-defined functions.
    ******************************************************************************/
    /*****************************************************************************
    * History : DD.MM.YYYY Version  Description
    *         : 30.06.2016 1.00     First Release
    ******************************************************************************/
    
    /******************************************************************************
    Includes   <System Includes> , "Project Includes"
    ******************************************************************************/
    #include "platform.h"
    #include "freertos_start.h"
    
    #if (BSP_CFG_RTOS_USED == 1)
    
    #if (RTOS_USB_SUPPORT == 1)
    #include "r_usb_basic_if.h"
    #include "r_usb_cstd_rtos.h"
    #endif
    
    /******************************************************************************
    Macro definitions
    ******************************************************************************/
    
    /******************************************************************************
    Typedef definitions
    ******************************************************************************/
    
    /******************************************************************************
    Private global variables and functions
    ******************************************************************************/
    
    /************* semaphore initialization *****************/
    
    /******************************************************************************
    Exported global variables (to be accessed by other files)
    ******************************************************************************/
    
    /* Allocate a large heap for the full demo. */
    #if configAPPLICATION_ALLOCATED_HEAP == 1
        #pragma section OSW
        uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
        #pragma section
    #endif /* #if configAPPLICATION_ALLOCATED_HEAP == 1 */
    
    /******************************************************************************
    Exported global functions (to be accessed by other files)
    ******************************************************************************/
    
    /* FreeRTOS's system timer. */
    void vApplicationSetupTimerInterrupt(void);
    
    /* Hook functions used by FreeRTOS. */
    void vAssertCalled(void);
    void vApplicationIdleHook(void);
    void vApplicationTickHook(void);
    void vApplicationMallocFailedHook(void);
    void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName);
    
    /* FreeRTOS's processing before start the kernel. */
    void Processing_Before_Start_Kernel(void);
    
    /* Main task. */
    extern void main_task(void *pvParameters);
    
    /*
     * Only the comprehensive demo uses application hook (callback) functions.  See
     * http://www.freertos.org/a00016.html for more information.
     */
    void vFullDemoTickHookFunction( void );
    void vFullDemoIdleFunction( void );
    
    /*
     * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
     * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
     */
    #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
        extern void main_blinky( void );
    #else
        extern void main_full( void );
    #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */
    
    static void prvSetupHardware( void );
    void vParTestInitialise( void );
    
    /******************************************************************************
    * Function Name: vApplicationSetupTimerInterrupt
    * Description  : Initialize system timer for FreeRTOS with tick interrupt 1ms.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationSetupTimerInterrupt(void)
    {
    	/* CMT channel 0 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 0)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 0. */
        MSTP( CMT0 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR0.BIT.STR0 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT0.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT0.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT0, CMI0)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT0, CMI0) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT0, CMI0) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 0. */
        CMT.CMSTR0.BIT.STR0 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 0) */
    
        /* CMT channel 1 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 1)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 1. */
        MSTP( CMT1 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR0.BIT.STR1 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT1.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT1.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT1.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT1, CMI1)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT1, CMI1) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT1, CMI1) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 1. */
        CMT.CMSTR0.BIT.STR1 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 1) */
    
        /* CMT channel 2 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 2)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 2. */
        MSTP( CMT2 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR1.BIT.STR2 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT2.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT2.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT2.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT2, CMI2)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT2, CMI2) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT2, CMI2) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 2. */
        CMT.CMSTR1.BIT.STR2 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 2) */
    
        /* CMT channel 3 is configured as RTOS's system timer. */
    #if (BSP_CFG_RTOS_SYSTEM_TIMER == 3)
        /* Protect off. */
        SYSTEM.PRCR.WORD = 0xA502;
    
        /* Enable compare match timer 3. */
        MSTP( CMT3 ) = 0;
    
        /* Stop counter. */
        CMT.CMSTR1.BIT.STR3 = 0;
    
        /* Protect on. */
        SYSTEM.PRCR.WORD = 0xA500;
    
        /* Enable interrupt on compare match.
         * Divide the PCLK by 8. */
        CMT3.CMCR.WORD = 0x00C0; // CKS=00b,CMIE=1; PCLK/8,Compare match interrupt (CMIn) enabled @60MHz
    
        /* Set the compare match value. */
        CMT3.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ )) / 8 - 1);
    
        /* Clear counter. */
        CMT3.CMCNT = 0;
    
        /* Clear any previously pending interrupts. */
        IR(CMT3, CMI3)  = 0;
    
        /* Enable the interrupt. */
        IEN(CMT3, CMI3) = 1;
    
        /* Set its priority to the application defined kernel priority. */
        IPR(CMT3, CMI3) = configKERNEL_INTERRUPT_PRIORITY;
    
        /* Start the timer 3. */
        CMT.CMSTR1.BIT.STR3 = 1;
    #endif /* (BSP_CFG_RTOS_SYSTEM_TIMER == 3) */
    
    } /* End of function vApplicationSetupTimerInterrupt() */
    
    /******************************************************************************
    * Function Name: vAssertCalled
    * Description  : This function is used to validate the input parameters.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vAssertCalled(void)
    {
        volatile unsigned long ul = 0;
    
        taskENTER_CRITICAL();
        {
            /* Use the debugger to set ul to a non-zero value in order to step out
            of this function to determine why it was called. */
            while( 0 == ul )
            {
                portNOP();
            }
        }
        taskEXIT_CRITICAL();
    
    } /* End of function vAssertCalled() */
    
    /******************************************************************************
    * Function Name: vApplicationIdleHook
    * Description  : This function will be called on each cycle of the idle task.
    *                NOTE: vApplicationIdleHook() MUST NOT CALL A FUNCTION
    *                      THAT MIGHT BLOCK UNDER ANY CIRCUMSTANCES.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationIdleHook(void)
    {
        /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
        to 1 in FreeRTOSConfig.h.  It will be called on each iteration of the idle
        task.  It is essential that code added to this hook function never attempts
        to block in any way (for example, call xQueueReceive() with a block time
        specified, or call vTaskDelay()).  If application tasks make use of the
        vTaskDelete() API function to delete themselves then it is also important
        that vApplicationIdleHook() is permitted to return to its calling function,
        because it is the responsibility of the idle task to clean up memory
        allocated by the kernel to any task that has since deleted itself. */
    
        #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
        {
            /* Call the idle task processing used by the full demo.  The simple
            blinky demo does not use the idle task hook. */
            vFullDemoIdleFunction();
        }
        #endif
    } /* End of function vApplicationIdleHook() */
    
    /******************************************************************************
    * Function Name: vApplicationTickHook
    * Description  : This function will be called every tick interrupt.
    *                NOTE: vApplicationTickHook() EXECUTES FROM WITHIN AN ISR,
    *                      SO MUST BE VERY SHORT AND NOT USE MUCH STACK.
    *                      IN ADDITION, NOT CALL ANY APIs WITHOUT "FromISR" OR
    *                      "FROM_ISR" AT THE END.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationTickHook(void)
    {
        /* This function will be called by each tick interrupt if
        configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h.  User code can be
        added here, but the tick hook is called from an interrupt context, so
        code must not attempt to block, and only the interrupt safe FreeRTOS API
        functions can be used (those that end in FromISR()). */
    
        #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
        {
            vFullDemoTickHookFunction();
        }
        #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */
    } /* End of function vApplicationTickHook() */
    
    /******************************************************************************
    * Function Name: vApplicationMallocFailedHook
    * Description  : This function is to capture the failure while
    *                memory allocation.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vApplicationMallocFailedHook(void)
    {
        /* Called if a call to pvPortMalloc() fails because there is insufficient
        free memory available in the FreeRTOS heap.  pvPortMalloc() is called
        internally by FreeRTOS API functions that create tasks, queues, software
        timers, and semaphores.  The size of the FreeRTOS heap is set by the
        configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
    
        taskDISABLE_INTERRUPTS();
        for( ; ; )
        {
            /* Loop here */
        };
    
    } /* End of function vApplicationMallocFailedHook() */
    
    /******************************************************************************
    * Function Name: vApplicationStackOverflowHook
    * Description  : Hook function is to capture the failure when the stack size
    *                is insufficient for processing.
    * Arguments    : pxTask -
    *                    Task handler
    *                pcTaskName -
    *                    Pointer of where to store the task's name
    * Return Value : None.
    ******************************************************************************/
    void vApplicationStackOverflowHook(TaskHandle_t pxTask, signed char *pcTaskName)
    {
        ( void ) pcTaskName;
        ( void ) pxTask;
    
        /* Run time stack overflow checking is performed if
        configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook
        function is called if a stack overflow is detected. */
    
        taskDISABLE_INTERRUPTS();
        for( ; ; )
        {
            /* Loop here */
        };
    
    } /* End of function vApplicationStackOverflowHook() */
    
    /******************************************************************************
    * Function Name : Processing_Before_Start_Kernel
    * Description   : Create a main task, FreeRTOS's objects (e.g. mailbox, task,
    *                 semaphore, mutex...) if required.
    * Arguments     : None.
    * Return value  : None.
    ******************************************************************************/
    void Processing_Before_Start_Kernel(void)
    {
        BaseType_t ret;
    
        /************** semaphore creation ***********************/
    
    
        /************** mutex creation ***************************/
    
    
        /************** queues creation **************************/
    
    
        /************** event groups creation ********************/
    
    
        /************** mailbox creation *************************/
    
    
        /************** memory pool creation *********************/
    
        /** USB RTOS Configuration **/
    #if (RTOS_USB_SUPPORT == 1)
        usb_rtos_err_t err = usb_rtos_configuration();
        if (UsbRtos_Success != err)
        {
            while(1)
            {
                /** Failure of UsbRtos Configuration **/
            }
        }
    #endif
    
        Kernel_Object_init();
    
    #if( FREERTOS_USER_MAIN == 1 )
        /************** task creation ****************************/
        /* Main task. */
        ret = xTaskCreate(main_task, "MAIN_TASK", 512, NULL, 3, NULL);
        if (pdPASS != ret)
        {
            while(1)
            {
                /* Failed! Task can not be created. */
            }
        }
    #else
    
        /* Configure the hardware ready to run the demo. */
        prvSetupHardware();
    
        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
        of this file. */
        #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
        {
            main_blinky();
        }
        #else
        {
            main_full();
        }
        #endif
    
    #endif
    
    } /* End of function Processing_Before_Start_Kernel() */
    
    static void prvSetupHardware( void )
    {
        /* Set up the ports used by the LED outputs (the name ParTest is now
        obsolete - it originally came from "parallel port test"). */
        vParTestInitialise();
    }
    
    #endif /* (BSP_CFG_RTOS_USED == 1) */
    
    
    


    freertos_start.h
    4666.freertos_start_h_20190522.txt
    /*******************************************************************************
    * DISCLAIMER
    * This software is supplied by Renesas Electronics Corporation and is only 
    * intended for use with Renesas products. No other uses are authorized. This 
    * software is owned by Renesas Electronics Corporation and is protected under
    * all applicable laws, including copyright laws.
    * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
    * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
    * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
    * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
    * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 
    * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 
    * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
    * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
    * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    * Renesas reserves the right, without notice, to make changes to this software
    * and to discontinue the availability of this software. By using this software,
    * you agree to the additional terms and conditions found by accessing the 
    * following link:
    * http://www.renesas.com/disclaimer
    * Copyright (C) 2018 Renesas Electronics Corporation. All rights reserved.    
    *******************************************************************************/
    /*******************************************************************************
    * File Name    : freertos_start.h
    * Version      : 1.0
    * Description  : FreeRTOS's user-defined functions header file.
    ******************************************************************************/
    /*****************************************************************************
    * History : DD.MM.YYYY Version  Description
    *         : 30.06.2016 1.00     First Release
    ******************************************************************************/
    
    #ifndef FREERTOS_START_H_
    #define FREERTOS_START_H_
    
    /******************************************************************************
    Macro definitions
    ******************************************************************************/
    /* USB FIT module support macro */
    #define RTOS_USB_SUPPORT   0
    
    /* Interrupt vector of CMT channel used for system timer of RTOS */
    #ifndef BSP_CFG_RTOS_SYSTEM_TIMER
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is necessary."
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 0
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT0_CMI0
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 1
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT1_CMI1
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 2
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT2_CMI2
    #elif BSP_CFG_RTOS_SYSTEM_TIMER == 3
        #define BSP_RTOS_SYSTEM_TIMER_VECTOR    _CMT3_CMI3
    #else
        #error "Setting BSP_CFG_RTOS_SYSTEM_TIMER is invalid."
    #endif
    
    /******************************************************************************
    Typedef definitions
    ******************************************************************************/
    
    /******************************************************************************
    Exported global variables
    ******************************************************************************/
    /************* semaphore handler *****************/
    
    
    /************* mutex handler *********************/
    
    
    /************** queues handler *******************/
    
    
    /************** event groups handler *************/
    
    
    /************** mailbox handler ******************/
    
    
    /************** memory pool handler **************/
    
    
    /************** task handler *********************/
    
    
    /******************************************************************************
    Exported global functions (to be accessed by other files)
    ******************************************************************************/
    extern void Processing_Before_Start_Kernel(void);
    extern void Kernel_Object_init(void);
    
    #endif /* FREERTOS_START_H_ */
    


    以下、CS+の画面コピーです。

Children
No Data