Skip to content

Commit

Permalink
Builds chalandi rp2350 but not yet run
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Sep 10, 2024
1 parent d10b9f5 commit e173d7d
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 146 deletions.
4 changes: 4 additions & 0 deletions ref_app/ref_app.sln
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Global
target riscvfe310|x64 = target riscvfe310|x64
target rl78|x64 = target rl78|x64
target rpi_pico_rp2040|x64 = target rpi_pico_rp2040|x64
target rpi_pico2_rp2350|x64 = target rpi_pico2_rp2350|x64
target rx63n|x64 = target rx63n|x64
target stm32f100|x64 = target stm32f100|x64
target stm32f407|x64 = target stm32f407|x64
Expand Down Expand Up @@ -86,6 +87,7 @@ Global
{C8B59726-9319-45C3-8F11-F9F388FB6A2C}.target riscvfe310|x64.ActiveCfg = Release|x64
{C8B59726-9319-45C3-8F11-F9F388FB6A2C}.target rl78|x64.ActiveCfg = Release|x64
{C8B59726-9319-45C3-8F11-F9F388FB6A2C}.target rpi_pico_rp2040|x64.ActiveCfg = Release|x64
{C8B59726-9319-45C3-8F11-F9F388FB6A2C}.target rpi_pico2_rp2350|x64.ActiveCfg = Release|x64
{C8B59726-9319-45C3-8F11-F9F388FB6A2C}.target rx63n|x64.ActiveCfg = Release|x64
{C8B59726-9319-45C3-8F11-F9F388FB6A2C}.target stm32f100|x64.ActiveCfg = Release|x64
{C8B59726-9319-45C3-8F11-F9F388FB6A2C}.target stm32f407|x64.ActiveCfg = Release|x64
Expand Down Expand Up @@ -122,6 +124,8 @@ Global
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target rl78|x64.Build.0 = target rl78|x64
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target rpi_pico_rp2040|x64.ActiveCfg = target rpi_pico_rp2040|x64
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target rpi_pico_rp2040|x64.Build.0 = target rpi_pico_rp2040|x64
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target rpi_pico2_rp2350|x64.ActiveCfg = target rpi_pico2_rp2350|x64
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target rpi_pico2_rp2350|x64.Build.0 = target rpi_pico2_rp2350|x64
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target rx63n|x64.ActiveCfg = target rx63n|x64
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target rx63n|x64.Build.0 = target rx63n|x64
{30CE370B-40F3-4BCD-8986-64AAFF8971BD}.target stm32f100|x64.ActiveCfg = target stm32f100|x64
Expand Down
4 changes: 2 additions & 2 deletions ref_app/src/mcal/rpi_pico2_rp2350/Mcal/Cpu/Cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
//=============================================================================
// Includes
//=============================================================================
#include "Cpu.h"
#include "core_arch.h"
#include <Cpu.h>
#include <core_arch.h>

//=============================================================================
// Globals
Expand Down
77 changes: 53 additions & 24 deletions ref_app/target.vcxproj

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions ref_app/target.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@
<Filter Include="micros\rpi_pico2_rp2350\make">
<UniqueIdentifier>{451ca947-56ce-46cf-a4e8-036c75f8b86a}</UniqueIdentifier>
</Filter>
<Filter Include="micros\rpi_pico2_rp2350\Appli">
<UniqueIdentifier>{8f7c20e8-9cec-4cf8-b3b5-48ce200d6733}</UniqueIdentifier>
</Filter>
<Filter Include="micros\rpi_pico2_rp2350\Std">
<UniqueIdentifier>{6be8f2e8-8491-442a-9308-13667c843931}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="target\app\make\app_files.gmk">
Expand Down Expand Up @@ -902,6 +908,9 @@
<ClCompile Include="target\micros\rpi_pico2_rp2350\Startup\Core\ARM\image_definition_block.c">
<Filter>micros\rpi_pico2_rp2350\Startup\Core\ARM</Filter>
</ClCompile>
<ClCompile Include="target\micros\rpi_pico2_rp2350\Appli\main.c">
<Filter>micros\rpi_pico2_rp2350\Appli</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="target\micros\bcm2835_raspi_b\startup\SD_CARD\PiZero\config.txt">
Expand All @@ -912,5 +921,8 @@
<ClInclude Include="target\micros\rpi_pico2_rp2350\Startup\Core\ARM\core_arch.h">
<Filter>micros\rpi_pico2_rp2350\Startup\Core\ARM</Filter>
</ClInclude>
<ClInclude Include="target\micros\rpi_pico2_rp2350\Std\Platform_Types.h">
<Filter>micros\rpi_pico2_rp2350\Std</Filter>
</ClInclude>
</ItemGroup>
</Project>
182 changes: 182 additions & 0 deletions ref_app/target/micros/rpi_pico2_rp2350/Appli/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/******************************************************************************************
Filename : main.c
Core : ARM Cortex-M33 / RISC-V Hazard3
MCU : RP2350
Author : Chalandi Amine
Owner : Chalandi Amine
Date : 04.09.2024
Description : Application main function
******************************************************************************************/

//=============================================================================
// Includes
//=============================================================================
#include "Platform_Types.h"
#include "Cpu.h"
#include "Gpio.h"
#include "SysTickTimer.h"

//=============================================================================
// Macros
//=============================================================================

//=============================================================================
// Prototypes
//=============================================================================
void main_Core0(void);
void main_Core1(void);
void BlockingDelay(uint32 delay);

//=============================================================================
// Globals
//=============================================================================
#ifdef DEBUG
volatile boolean boHaltCore0 = TRUE;
volatile boolean boHaltCore1 = TRUE;
#endif

//-----------------------------------------------------------------------------------------
/// \brief main function
///
/// \param void
///
/// \return void
//-----------------------------------------------------------------------------------------
int main(void)
{
/* Run the main function of the core 0, it will start the core 1 */
main_Core0();

/* Synchronize with core 1 */
RP2350_MulticoreSync((uint32_t)HW_PER_SIO->CPUID.reg);

/* endless loop on the core 0 */
for(;;);

/* never reached */
return(0);
}

//-----------------------------------------------------------------------------------------
/// \brief main_Core0 function
///
/// \param void
///
/// \return void
//-----------------------------------------------------------------------------------------
void main_Core0(void)
{
#ifdef DEBUG
while(boHaltCore0);
#endif

#ifdef CORE_FAMILY_ARM
/* Disable interrupts on core 0 */
__asm volatile("CPSID i");
#endif

/* Output disable on pin 25 */
LED_GREEN_CFG();


/* Start the Core 1 and turn on the led to be sure that we passed successfully the core 1 initiaization */
if(TRUE == RP2350_StartCore1())
{
LED_GREEN_ON();
}
else
{
/* Loop forever in case of error */
while(1)
{
__asm volatile("NOP");
}
}

}

//-----------------------------------------------------------------------------------------
/// \brief main_Core1 function
///
/// \param void
///
/// \return void
//-----------------------------------------------------------------------------------------
volatile uint64_t* pMTIMECMP = (volatile uint64_t*)&(HW_PER_SIO->MTIMECMP.reg);
volatile uint64_t* pMTIME = (volatile uint64_t*)&(HW_PER_SIO->MTIME.reg);

void main_Core1(void)
{
#ifdef DEBUG
while(boHaltCore1);
#endif

/* Note: Core 1 is started with interrupt enabled by the BootRom */

/* Clear the stiky bits of the FIFO_ST on core 1 */
HW_PER_SIO->FIFO_ST.reg = 0xFFu;

#ifdef CORE_FAMILY_ARM
__asm volatile("DSB");

/* Clear all pending interrupts on core 1 */
NVIC->ICPR[0] = (uint32)-1;

#endif

/* Synchronize with core 0 */
RP2350_MulticoreSync((uint32_t)HW_PER_SIO->CPUID.reg);


#ifdef CORE_FAMILY_RISC_V

/* configure the machine timer for 1Hz interrupt window */
#include "riscv.h"

/* enable machine timer interrupt */
riscv_set_csr(RVCSR_MIE_OFFSET, 0x80ul);

/* enable global interrupt */
riscv_set_csr(RVCSR_MSTATUS_OFFSET, 0x08ul);

/* configure machine timer to use 150 MHz */
HW_PER_SIO->MTIME_CTRL.bit.FULLSPEED = 1;

/* set next timeout (machine timer is enabled by default) */
*pMTIMECMP = *pMTIME + 150000000ul; //1s

#endif

while(1)
{
#ifdef CORE_FAMILY_ARM
#define DELAY 15000000
LED_GREEN_TOGGLE();
#else
#define DELAY 10000000
#endif

BlockingDelay(DELAY);
}
}


#ifdef CORE_FAMILY_RISC_V
__attribute__((interrupt)) void Isr_MachineTimerInterrupt(void);

void Isr_MachineTimerInterrupt(void)
{
*pMTIMECMP = *pMTIME + 150000000ul;

LED_GREEN_TOGGLE();
}

#endif

42 changes: 42 additions & 0 deletions ref_app/target/micros/rpi_pico2_rp2350/Std/Platform_Types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/******************************************************************************************
Filename : Platform_Types.h
Core : ARM Cortex-M33 / RISC-V Hazard3
MCU : RP2350
Author : Chalandi Amine
Owner : Chalandi Amine
Date : 04.09.2024
Description : Platform types header file
******************************************************************************************/

#ifndef __PLATFORM_TYPES_H__
#define __PLATFORM_TYPES_H__

typedef unsigned char uint8;
typedef signed char sint8;
typedef unsigned short uint16;
typedef signed short sint16;
typedef unsigned long uint32;
typedef signed long sint32;
typedef unsigned long long uint64;
typedef signed long long sint64;

typedef void (*pFunc)(void);

typedef enum
{
FALSE = 0,
TRUE
}boolean;

#define NULL (void*)0

#define NULL_PTR (void*)0

#endif
Loading

0 comments on commit e173d7d

Please sign in to comment.