Skip to content

Commit 12ef8b0

Browse files
committed
💚 fix error in DSPIC performance
2 parents d056edd + 263a52c commit 12ef8b0

36 files changed

Lines changed: 1628 additions & 66 deletions

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,8 @@ Project/MPLAB-*/RMP.X/disassembly
8686
Project/MPLAB-*/RMP.X/dist
8787

8888
#ATMEL Studio specific
89-
Project/ATS-*/.vs/
89+
Project/ATS-*/.vs/
90+
91+
#E2STUDIO specific
92+
Project/E2STUDIO-*/.eclipse/
93+
21.6 KB
Binary file not shown.
23.1 KB
Binary file not shown.

Include/Kernel/rmp_kernel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Description : The header file for the kernel.
5959
#define RMP_MSGQ_USED (1U)
6060

6161
/* States of blocking message queues */
62-
#define RMP_BMQ_FREE (0U)
63-
#define RMP_BMQ_USED (1U)
62+
#define RMP_BMQ_FREE (0U)
63+
#define RMP_BMQ_USED (1U)
6464

6565
/* Error codes */
6666
/* This error is thread related */
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/******************************************************************************
2+
Filename : rmp_platform_r5f104pj.h
3+
Author : lht
4+
Date : 24/04/2024
5+
Licence : The Unlicense; see LICENSE for details.
6+
Description: The configuration file for R5F104PJ.
7+
******************************************************************************/
8+
9+
/* Define ********************************************************************/
10+
/* The iodefine library */
11+
#include "iodefine.h"
12+
13+
/* Debugging */
14+
#define RMP_ASSERT_CORRECT (0U)
15+
/* The maximum number of preemption priority levels in the system.
16+
* This parameter must be divisible by the word length - 32 is usually sufficient */
17+
#define RMP_PREEMPT_PRIO_NUM (16U)
18+
/* The maximum number of slices allowed */
19+
#define RMP_SLICE_MAX (32000U)
20+
/* The maximum number of semaphore counts allowed */
21+
#define RMP_SEM_CNT_MAX (100U)
22+
/* Are we using custom hooks? */
23+
#define RMP_HOOK_EXTRA (0U)
24+
/* The stzck size of the init thread */
25+
#define RMP_INIT_STACK_SIZE (256U)
26+
/* The mask/unmask interrupt operations - can be adjusted to fit your own levels */
27+
#define RMP_INT_MASK() RMP_Int_Disable()
28+
#define RMP_INT_UNMASK() RMP_Int_Enable()
29+
30+
/* The tick timer value */
31+
#define RMP_RL78_TICK_VAL (16000U)
32+
33+
/* Other low-level initialization stuff - clock and serial.
34+
* This is the default initialization sequence. If you wish to supply
35+
* your own, just redirect this macro to a custom function, or do your
36+
* initialization stuff in the initialization hook (RMP_Start_Hook). */
37+
#define RMP_RL78_LOWLVL_INIT() \
38+
{ \
39+
PIOR0=0x00U; \
40+
PIOR1=0x00U; \
41+
/* Set fMX */ \
42+
CMC=0x40U|0x01U; \
43+
OSTS=0x07U; \
44+
MSTOP=0U; \
45+
while((OSTC&0xFFU)!=0xFFU); \
46+
/* Set fMAIN */ \
47+
MCM0=0U; \
48+
/* Set fSUB */ \
49+
XTSTOP=1U; \
50+
OSMC=0x10U; \
51+
/* Set fCLK */ \
52+
CSS=0U; \
53+
/* Set fIH */ \
54+
HIOSTOP=0U; \
55+
WDTIMK=1U; \
56+
IAWCTL=0x00U; \
57+
/* SAU0 and UART1 initial setting */ \
58+
SAU0EN=1U; \
59+
SPS0=0x0004U; \
60+
ST0|=0x0004U; \
61+
/* Disable interrupt INTST1,INTSR1,INTSRE1 */ \
62+
STMK1=1U; \
63+
STIF1=0U; \
64+
SRMK1=1U; \
65+
SRIF1=0U; \
66+
SREMK1=1U; \
67+
SREIF1=0U; \
68+
/* Set INTST1 low priority */ \
69+
STPR11=1U; \
70+
STPR01=1U; \
71+
SMR02=0x0020U|0x0002U|0x0001U; \
72+
SCR02=0x8000U|0x0080U|0x0010U|0x0007U; \
73+
SDR02=0xCE00U; \
74+
SO0|=0x0004U; \
75+
SOL0|=0x0000U; \
76+
/* Enable UART1 output */ \
77+
SOE0|=0x0004U; \
78+
/* Set TxD1 pin */ \
79+
PMC0&=0xFBU; \
80+
P0|=0x04U; \
81+
PM0&=0xFBU; \
82+
/* Output level normal */ \
83+
SO0|=0x0004U; \
84+
/* Enable UART1 output */ \
85+
SOE0|=0x0004U; \
86+
/* Enable UART1 transmit */ \
87+
SS0|=0x0004U; \
88+
} \
89+
while(0)
90+
#define RMP_RL78_TIM_CLR() (TMIF00=0U)
91+
92+
#define RMP_RL78_PUTCHAR(CHAR) \
93+
{ \
94+
TXD1=(rmp_u8_t)(CHAR); \
95+
while(STIF1==0U); \
96+
STIF1=0U; \
97+
} \
98+
while(0)
99+
/* End Define ****************************************************************/
100+
101+
/* End Of File ***************************************************************/
102+
103+
/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/******************************************************************************
2+
Filename : rmp_platform_rl78.h
3+
Author : lht
4+
Date : 04/24/2024
5+
Licence : The Unlicense; see LICENSE for details.
6+
Description : The header of "rmp_platform_rl78.c".
7+
******************************************************************************/
8+
9+
/* Define ********************************************************************/
10+
#ifdef __HDR_DEF__
11+
#ifndef __RMP_PLATFORM_RL78_DEF__
12+
#define __RMP_PLATFORM_RL78_DEF__
13+
#endif
14+
/*****************************************************************************/
15+
/* Basic Types ***************************************************************/
16+
#ifndef __RMP_S32_T__
17+
#define __RMP_S32_T__
18+
typedef signed long rmp_s32_t;
19+
#endif
20+
21+
#ifndef __RMP_S16_T__
22+
#define __RMP_S16_T__
23+
typedef signed int rmp_s16_t;
24+
#endif
25+
26+
#ifndef __RMP_S8_T__
27+
#define __RMP_S8_T__
28+
typedef signed char rmp_s8_t;
29+
#endif
30+
31+
#ifndef __RMP_U32_T__
32+
#define __RMP_U32_T__
33+
typedef unsigned long rmp_u32_t;
34+
#endif
35+
36+
#ifndef __RMP_U16_T__
37+
#define __RMP_U16_T__
38+
typedef unsigned int rmp_u16_t;
39+
#endif
40+
41+
#ifndef __RMP_U8_T__
42+
#define __RMP_U8_T__
43+
typedef unsigned char rmp_u8_t;
44+
#endif
45+
/* End Basic Types ***********************************************************/
46+
47+
/* Extended Types ************************************************************/
48+
#ifndef __RMP_PTR_T__
49+
#define __RMP_PTR_T__
50+
/* The typedef for the pointers - This is the raw style. Pointers must be unsigned */
51+
typedef rmp_u16_t rmp_ptr_t;
52+
#endif
53+
54+
#ifndef __RMP_CNT_T__
55+
#define __RMP_CNT_T__
56+
/* The typedef for the count variables */
57+
typedef long rmp_cnt_t;
58+
#endif
59+
60+
#ifndef __RMP_RET_T__
61+
#define __RMP_RET_T__
62+
/* The type for process return value */
63+
typedef rmp_s16_t rmp_ret_t;
64+
#endif
65+
/* End Extended Types ********************************************************/
66+
67+
/* System macros *************************************************************/
68+
/* Compiler "extern" keyword setting */
69+
#define EXTERN extern
70+
/* The order of bits in one CPU machine word */
71+
#define RMP_WORD_ORDER (4U)
72+
/* The maximum length of char printing */
73+
#define RMP_DEBUG_PRINT_MAX (255U)
74+
/* Full descending stack of rmp_ptr_t, word-addressing with 2-byte alignment */
75+
#define RMP_STACK_TYPE RMP_STACK_FULL_DESCEND
76+
#define RMP_STACK_ALIGN (1U)
77+
#define RMP_STACK_ELEM rmp_ptr_t
78+
#define RMP_STACK_STRUCT struct RMP_RL78_Stack
79+
/* MSB/LSB extraction */
80+
#define RMP_MSB_GET(VAL) RMP_MSB_Generic(VAL)
81+
#define RMP_LSB_GET(VAL) RMP_LSB_Generic(VAL)
82+
83+
/* The CPU and application specific macros are here */
84+
#include "rmp_platform_rl78_conf.h"
85+
/* End System macros *********************************************************/
86+
/* __HDR_DEF__ */
87+
#endif
88+
/* End Define ****************************************************************/
89+
90+
/* Struct ********************************************************************/
91+
#ifdef __HDR_STRUCT__
92+
#ifndef __RMP_PLATFORM_RL78_STRUCT__
93+
#define __RMP_PLATFORM_RL78_STRUCT__
94+
/* We used structs in the header */
95+
96+
/* Use defines in these headers */
97+
#define __HDR_DEF__
98+
#undef __HDR_DEF__
99+
/*****************************************************************************/
100+
struct RMP_RL78_Stack
101+
{
102+
/* The former is higher, latter is lower */
103+
rmp_u16_t CSES;
104+
rmp_u16_t HL;
105+
rmp_u16_t DE;
106+
rmp_u16_t BC;
107+
rmp_u16_t AX;
108+
rmp_u16_t PC;
109+
rmp_u16_t PSWPCH;
110+
};
111+
/*****************************************************************************/
112+
/* __RMP_PLATFORM_RL78_STRUCT__ */
113+
#endif
114+
/* __HDR_STRUCT__ */
115+
#endif
116+
/* End Struct ****************************************************************/
117+
118+
/* Private Variable **********************************************************/
119+
#if(!(defined __HDR_DEF__||defined __HDR_STRUCT__))
120+
#ifndef __RMP_PLATFORM_RL78_MEMBER__
121+
#define __RMP_PLATFORM_RL78_MEMBER__
122+
123+
/* In this way we can use the data structures and definitions in the headers */
124+
#define __HDR_DEF__
125+
126+
#undef __HDR_DEF__
127+
128+
#define __HDR_STRUCT__
129+
130+
#undef __HDR_STRUCT__
131+
132+
/* If the header is not used in the public mode */
133+
#ifndef __HDR_PUBLIC__
134+
/*****************************************************************************/
135+
136+
/*****************************************************************************/
137+
/* End Private Variable ******************************************************/
138+
139+
/* Private Function **********************************************************/
140+
/*****************************************************************************/
141+
142+
/*****************************************************************************/
143+
#define __EXTERN__
144+
/* End Private Function ******************************************************/
145+
146+
/* Public Variable ***********************************************************/
147+
/* __HDR_PUBLIC__ */
148+
#else
149+
#define __EXTERN__ EXTERN
150+
/* __HDR_PUBLIC__ */
151+
#endif
152+
153+
/*****************************************************************************/
154+
__EXTERN__ rmp_ptr_t _RMP_RL78_SP_Kern;
155+
156+
__EXTERN__ volatile rmp_u8_t RMP_RL78_Int_Act;
157+
__EXTERN__ volatile rmp_u8_t _RMP_RL78_Yield_Pend;
158+
/*****************************************************************************/
159+
160+
/* End Public Variable *******************************************************/
161+
162+
/* Public Function ***********************************************************/
163+
/*****************************************************************************/
164+
/* Interrupts */
165+
EXTERN void RMP_Int_Disable(void);
166+
EXTERN void RMP_Int_Enable(void);
167+
168+
EXTERN void _RMP_Start(rmp_ptr_t Entry, rmp_ptr_t Stack);
169+
EXTERN void _RMP_RL78_Yield(void);
170+
EXTERN void _RMP_Yield(void);
171+
172+
/* Initialization */
173+
__EXTERN__ rmp_ptr_t _RMP_Stack_Init(rmp_ptr_t Stack,
174+
rmp_ptr_t Size,
175+
rmp_ptr_t Entry,
176+
rmp_ptr_t Param);
177+
__EXTERN__ void _RMP_Lowlvl_Init(void);
178+
__EXTERN__ void RMP_Putchar(char Char);
179+
__EXTERN__ void _RMP_Plat_Hook(void);
180+
181+
/* Timer handler */
182+
__EXTERN__ void _RMP_RL78_Tim_Handler(void);
183+
/*****************************************************************************/
184+
/* Undefine "__EXTERN__" to avoid redefinition */
185+
#undef __EXTERN__
186+
/* __RMP_PLATFORM_RL78_MEMBER__ */
187+
#endif
188+
/* !(defined __HDR_DEF__||defined __HDR_STRUCT__) */
189+
#endif
190+
/* End Public Function *******************************************************/
191+
192+
/* End Of File ***************************************************************/
193+
194+
/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
;/*****************************************************************************
2+
;Filename : rmp_platform_rl78_ccrl.inc
3+
;Author : pry
4+
;Date : 25/02/2018
5+
;Description : The assembly part of the RMP RTOS. This is for RL78, and
6+
; contains macros to be included in all interrupt assembly code
7+
; as needed.
8+
;*****************************************************************************/
9+
10+
;/* Import *******************************************************************/
11+
;The kernel stack
12+
.EXTERN __RMP_RL78_SP_Kern
13+
;The current thread stack
14+
.EXTERN _RMP_SP_Cur
15+
;The interrupt active flag
16+
.EXTERN _RMP_RL78_Int_Act
17+
;The yield pending flag
18+
.EXTERN __RMP_RL78_Yield_Pend
19+
;Extract highest priority running thread
20+
.EXTERN __RMP_Run_High
21+
;Handler for RL78 timer interrupt
22+
.EXTERN __RMP_RL78_Tim_Handler
23+
;/* End Import ***************************************************************/
24+
25+
;/* Macro ********************************************************************/
26+
;/* Push everything to stack *************************************************/
27+
RMP_RL78_INT_SAVE .MACRO
28+
PUSH AX
29+
PUSH BC
30+
PUSH DE
31+
PUSH HL
32+
MOV A,ES
33+
MOV X,A
34+
MOV A,CS
35+
PUSH AX
36+
MOVW AX,SP
37+
MOVW !_RMP_SP_Cur,AX
38+
MOVW AX,!__RMP_RL78_SP_Kern
39+
MOVW SP,AX
40+
ONEB !_RMP_RL78_Int_Act
41+
.ENDM
42+
;/* Load everything from stack, and deal with pending yields if there is *****/
43+
RMP_RL78_INT_RESTORE .MACRO
44+
.LOCAL __RMP_RL78_Yield_Skip
45+
CMP0 !__RMP_RL78_Yield_Pend
46+
BZ $__RMP_RL78_Yield_Skip
47+
CLRB !__RMP_RL78_Yield_Pend
48+
CALL !!__RMP_Run_High
49+
__RMP_RL78_Yield_Skip:
50+
CLRB !_RMP_RL78_Int_Act
51+
MOVW AX,!_RMP_SP_Cur
52+
MOVW SP,AX
53+
POP AX
54+
MOV CS,A
55+
MOV A,X
56+
MOV ES,A
57+
POP HL
58+
POP DE
59+
POP BC
60+
POP AX
61+
RETI
62+
.ENDM
63+
;/* End Macro ****************************************************************/
64+
65+
;/* End Of File **************************************************************/
66+
67+
;/* Copyright (C) Evo-Devo Instrum. All rights reserved **********************/
68+

0 commit comments

Comments
 (0)