Skip to content

Commit

Permalink
⬆️ initial C28x port
Browse files Browse the repository at this point in the history
  • Loading branch information
hungry-foolish committed May 2, 2024
1 parent cc50a0a commit 8cd8762
Show file tree
Hide file tree
Showing 668 changed files with 171,215 additions and 10 deletions.
Binary file modified Document/Public/CN_M5P01_R5T2_User_Manual.doc
Binary file not shown.
Binary file modified Document/Public/CN_M5P01_R5T2_User_Manual.pdf
Binary file not shown.
7 changes: 1 addition & 6 deletions Include/Platform/A7M/rmp_platform_a7m.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ typedef rmp_s32_t rmp_ret_t;
#include "rmp_platform_a7m_conf.h"
/* End System macros *********************************************************/

/* Cortex-M specific macros **************************************************/
/* ARMv7-M specific macros ***************************************************/
/* MPU operation flag */
#define RMP_A7M_MPU_CLR (0)
#define RMP_A7M_MPU_UPD (1)
Expand Down Expand Up @@ -113,11 +113,6 @@ typedef rmp_s32_t rmp_ret_t;
#define RMP_A7M_EXC_RET_RET_PSP (1<<2)
/* Is this interrupt taken to a secured domain? 1 means yes, 0 means no */
#define RMP_A7M_EXC_INT_SECURE_DOMAIN (1<<0)
/* FPU type definitions */
#define RMP_A7M_FPU_NONE (0)
#define RMP_A7M_FPU_VFPV4 (1)
#define RMP_A7M_FPU_FPV5_SP (2)
#define RMP_A7M_FPU_FPV5_DP (3)

/* Some useful SCB definitions */
#define RMP_A7M_SHCSR_USGFAULTENA (1<<18)
Expand Down
105 changes: 105 additions & 0 deletions Include/Platform/C28X/Chip/TMS320F28335/rmp_platform_tms320f28335.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/******************************************************************************
Filename : rmp_platform_tms320f28335.h
Author : zr
Date : 27/04/2024
Licence : The Unlicense; see LICENSE for details.
Description: The configuration file for TMS320F28335.
******************************************************************************/

/* Define ********************************************************************/
/* The TI-supplied headers */
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"

/* Debugging */
#define RMP_ASSERT_CORRECT (0U)
/* The maximum number of preemption priority levels in the system.
* This parameter must be divisible by the word length - 16 is usually sufficient */
#define RMP_PREEMPT_PRIO_NUM (32U)
/* The maximum number of slices allowed */
#define RMP_SLICE_MAX (10000U)
/* The maximum number of semaphore counts allowed */
#define RMP_SEM_CNT_MAX (1000U)
/* Are we using custom hooks? */
#define RMP_HOOK_EXTRA (0U)
/* The stzck size of the init thread */
#define RMP_INIT_STACK_SIZE (128U)
/* The mask/unmask interrupt operations */
#define RMP_INT_MASK() RMP_Int_Disable()
#define RMP_INT_UNMASK() RMP_Int_Enable()

/* The tick timer value */
#define RMP_C28X_TICK_VAL (15000U)

/* FPU type */
#define RMP_C28X_COP_FPU32 (1U)
#define RMP_C28X_COP_FPU64 (0U)

/* Serial baud rate */
#define RMP_C28X_BAUD_RATE (115200U)
#define RMP_C28X_SCIA_BAUD (37500000U/(8U*RMP_C28X_BAUD_RATE)-1U)

/* Low-level initialization stuff - PIE table, clock and serial.
* This is the default initialization sequence. If you wish to supply
* your own, just redirect this macro to a custom function, or do your
* initialization stuff in the initialization hook (RMP_Start_Hook). */
#define RMP_C28X_LOWLVL_INIT() \
do \
{ \
/* Disable interrupts and PIE */ \
EDIS; \
PieCtrlRegs.PIECTRL.bit.ENPIE=0U; \
/* Configure system clock to 150MHz */ \
InitSysCtrl(); \
/* Initialize vector table and sources but not global interrupt yet */ \
InitPieVectTable(); \
IER=0xFFFFU; \
/* Initialize RAMFUNC */ \
MemCopy(&RamfuncsLoadStart,&RamfuncsLoadEnd,&RamfuncsRunStart); \
\
/* Initialize flash - need to run in RAM if you boot from Flash! */ \
FlashRegs.FOPT.bit.ENPIPE=1U; \
FlashRegs.FBANKWAIT.bit.PAGEWAIT=5U; \
FlashRegs.FBANKWAIT.bit.RANDWAIT=5U; \
FlashRegs.FOTPWAIT.bit.OTPWAIT=8U; \
FlashRegs.FSTDBYWAIT.bit.STDBYWAIT=0x01FFU; \
FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT=0x01FFU; \
\
/* Initialize timer 2 for RTOS use */ \
InitCpuTimers(); \
ConfigCpuTimer(&CpuTimer2,150U,1000U); \
CpuTimer2Regs.TCR.bit.TSS=0U; \
\
/* SCIA GPIO & FIFO - 115200-8-N-1 */ \
SysCtrlRegs.PCLKCR0.bit.SCIAENCLK=1U; \
InitSciaGpio(); \
SciaRegs.SCIFFTX.all=0xE040U; \
SciaRegs.SCIFFRX.all=0x204FU; \
SciaRegs.SCIFFCT.all=0U; \
SciaRegs.SCICCR.all=0x0007U; \
SciaRegs.SCICTL1.all=0x0003U; \
SciaRegs.SCICTL2.all=0x0003U; \
SciaRegs.SCICTL2.bit.TXINTENA=0U; \
SciaRegs.SCICTL2.bit.RXBKINTENA=0U; \
SciaRegs.SCIHBAUD=RMP_C28X_SCIA_BAUD>>8; \
SciaRegs.SCILBAUD=RMP_C28X_SCIA_BAUD&0xFFU; \
SciaRegs.SCICTL1.all=0x0023U; \
} \
while(0)

#define RMP_C28X_TIM_CLR() (CpuTimer2Regs.TCR.bit.TIF=1U)

/* This is for debugging output via SCI-A */
#define RMP_C28X_PUTCHAR(CHAR) \
do \
{ \
while(SciaRegs.SCIFFTX.bit.TXFFST!=0U); \
SciaRegs.SCITXBUF=(rmp_u8_t)(CHAR); \
} \
while (0)

/* End Define ****************************************************************/

/* End Of File ***************************************************************/

/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/
235 changes: 235 additions & 0 deletions Include/Platform/C28X/rmp_platform_c28x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/******************************************************************************
Filename : rmp_platform_c28x.h
Author : zr (ran zhang)
Date : 27/04/2024
Licence : The Unlicense; see LICENSE for details.
Description : The header of "rmp_platform_c28x.c".
******************************************************************************/

/* Define ********************************************************************/
#ifdef __HDR_DEF__
#ifndef __RMP_PLATFORM_C28X_DEF__
#define __RMP_PLATFORM_C28X_DEF__
/*****************************************************************************/
/* Basic Types ***************************************************************/
#ifndef __RMP_S32_T__
#define __RMP_S32_T__
typedef signed long rmp_s32_t;
#endif

#ifndef __RMP_S16_T__
#define __RMP_S16_T__
typedef signed int rmp_s16_t;
#endif

#ifndef __RMP_S8_T__
#define __RMP_S8_T__
typedef signed char rmp_s8_t;
#endif

#ifndef __RMP_U32_T__
#define __RMP_U32_T__
typedef unsigned long rmp_u32_t;
#endif

#ifndef __RMP_U16_T__
#define __RMP_U16_T__
typedef unsigned int rmp_u16_t;
#endif

#ifndef __RMP_U8_T__
#define __RMP_U8_T__
typedef unsigned char rmp_u8_t;
#endif
/* End Basic Types ***********************************************************/

/* Extended Types ************************************************************/
/* The CPU and application specific macros are here */
#include "rmp_platform_c28x_conf.h"

#ifndef __RMP_PTR_T__
#define __RMP_PTR_T__
/* The typedef for the pointers - This is the raw style. Pointers must be unsigned */
typedef rmp_u32_t rmp_ptr_t;
#endif

#ifndef __RMP_CNT_T__
#define __RMP_CNT_T__
/* The typedef for the count variables */
typedef rmp_s32_t rmp_cnt_t;
#endif

#ifndef __RMP_RET_T__
#define __RMP_RET_T__
/* The type for return value */
typedef rmp_s32_t rmp_ret_t;
#endif
/* End Extended Types ********************************************************/

/* System macros *************************************************************/
/* Compiler "extern" keyword setting */
#define EXTERN extern
/* The order of bits in one CPU machine word */
#define RMP_WORD_ORDER (5U)
/* The maximum length of char printing - no need to change this in most cases */
#define RMP_DEBUG_PRINT_MAX (128U)
/* Descending stack, 2-word alignment */
#define RMP_INIT_STACK RMP_INIT_STACK_ASCEND(1U)
/* MSB/LSB extraction */
#define RMP_MSB_GET(VAL) RMP_MSB_Generic(VAL)
#define RMP_LSB_GET(VAL) RMP_LSB_Generic(VAL)
/* End System macros *********************************************************/
/*****************************************************************************/
/* __RMP_PLATFORM_C28X_DEF__ */
#endif
/* __HDR_DEF__ */
#endif
/* End Define ****************************************************************/

/* Struct ********************************************************************/
#ifdef __HDR_STRUCT__
#ifndef __RMP_PLATFORM_C28X_STRUCT__
#define __RMP_PLATFORM_C28X_STRUCT__
/* We used structs in the header */

/* Use defines in these headers */
#define __HDR_DEF__
#undef __HDR_DEF__
/*****************************************************************************/
struct RMP_C28X_Stack
{
/* Hardware stacked */
rmp_ptr_t T_ST0;
rmp_ptr_t ACC;
rmp_ptr_t P;
rmp_ptr_t AR1_AR0;
rmp_ptr_t DP_ST1;
rmp_ptr_t DBGSTAT_IER;
rmp_ptr_t PC;
/* Software stacked */
rmp_ptr_t RPC;
rmp_ptr_t AR1H_AR0H;
rmp_ptr_t XAR2;
rmp_ptr_t XAR3;
rmp_ptr_t XAR4;
rmp_ptr_t XAR5;
rmp_ptr_t XAR6;
rmp_ptr_t XAR7;
rmp_ptr_t XT;
/* FPU registers */
#if(RMP_C28X_COP_FPU64!=0U)
rmp_ptr_t STF;
rmp_ptr_t RB;
rmp_ptr_t R0L;
rmp_ptr_t R0H;
rmp_ptr_t R1L;
rmp_ptr_t R1H;
rmp_ptr_t R2L;
rmp_ptr_t R2H;
rmp_ptr_t R3L;
rmp_ptr_t R3H;
rmp_ptr_t R4L;
rmp_ptr_t R4H;
rmp_ptr_t R5L;
rmp_ptr_t R5H;
rmp_ptr_t R6L;
rmp_ptr_t R6H;
rmp_ptr_t R7L;
rmp_ptr_t R7H;
#elif(RMP_C28X_COP_FPU32!=0U)
rmp_ptr_t STF;
rmp_ptr_t RB;
rmp_ptr_t R0H;
rmp_ptr_t R1H;
rmp_ptr_t R2H;
rmp_ptr_t R3H;
rmp_ptr_t R4H;
rmp_ptr_t R5H;
rmp_ptr_t R6H;
rmp_ptr_t R7H;
#endif
};

/*****************************************************************************/
/* __RMP_PLATFORM_C28X_STRUCT__ */
#endif
/* __HDR_STRUCT__ */
#endif
/* End Struct ****************************************************************/

/* Private Variable **********************************************************/
#if(!(defined __HDR_DEF__||defined __HDR_STRUCT__))
#ifndef __RMP_PLATFORM_C28X_MEMBER__
#define __RMP_PLATFORM_C28X_MEMBER__

/* In this way we can use the data structures and definitions in the headers */
#define __HDR_DEF__

#undef __HDR_DEF__

#define __HDR_STRUCT__

#undef __HDR_STRUCT__

/* If the header is not used in the public mode */
#ifndef __HDR_PUBLIC__
/*****************************************************************************/

/*****************************************************************************/
/* End Private Variable ******************************************************/

/* Private Function **********************************************************/
/*****************************************************************************/

/*****************************************************************************/
#define __EXTERN__
/* End Private Function ******************************************************/

/* Public Variable ***********************************************************/
/* __HDR_PUBLIC__ */
#else
#define __EXTERN__ EXTERN
/* __HDR_PUBLIC__ */
#endif

/*****************************************************************************/
__EXTERN__ rmp_u16_t _RMP_C28X_SP_Kern;

__EXTERN__ volatile rmp_u16_t RMP_C28X_Int_Act;
__EXTERN__ volatile rmp_u16_t _RMP_C28X_Yield_Pend;
/*****************************************************************************/

/* End Public Variable *******************************************************/

/* Public Function ***********************************************************/
/*****************************************************************************/
/* Interrupts */
EXTERN void RMP_Int_Disable(void);
EXTERN void RMP_Int_Enable(void);

EXTERN void _RMP_Start(rmp_ptr_t Entry, rmp_ptr_t Stack);
EXTERN void _RMP_C28X_Yield_NONE(void);
EXTERN void _RMP_C28X_Yield_FPU32(void);
EXTERN void _RMP_C28X_Yield_FPU64(void);
__EXTERN__ void _RMP_Yield(void);

/* Initialization */
__EXTERN__ rmp_ptr_t _RMP_Stack_Init(rmp_ptr_t Stack,
rmp_ptr_t Size,
rmp_ptr_t Entry,
rmp_ptr_t Param);
__EXTERN__ void _RMP_Lowlvl_Init(void);
__EXTERN__ void RMP_Putchar(char Char);
__EXTERN__ void _RMP_Plat_Hook(void);
/*****************************************************************************/
/* Undefine "__EXTERN__" to avoid redefinition */
#undef __EXTERN__
/* __RMP_PLATFORM_C28X_MEMBER__ */
#endif
/* !(defined __HDR_DEF__||defined __HDR_STRUCT__) */
#endif
/* End Public Function *******************************************************/

/* End Of File ***************************************************************/

/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/
Loading

0 comments on commit 8cd8762

Please sign in to comment.