Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ifdef peripheral included #288

Merged
merged 3 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions sw/applications/example_external_peripheral/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

#define COPY_SIZE 10

#ifndef RV_PLIC_IS_INCLUDED
#error ( "This app does NOT work as the RV_PLIC peripheral is not included" )
#endif

#ifdef TARGET_PYNQ_Z2
#error ( "This app does NOT work on the FPGA as it relies on the simulator testbench" )
#endif

// Interrupt controller variables
plic_result_t plic_res;
Expand All @@ -25,10 +32,6 @@ plic_irq_id_t intr_num;
int main(int argc, char *argv[])
{

#ifdef TARGET_PYNQ_Z2
#pragma message ( "This app does NOT work on the Pynq-Z2 board as it relies on the testbench" )
return -1;
#else
printf("Init the PLIC...");
plic_res = plic_Init();

Expand Down Expand Up @@ -116,5 +119,4 @@ int main(int argc, char *argv[])
}

return EXIT_SUCCESS;
#endif
}
15 changes: 8 additions & 7 deletions sw/applications/example_gpio_cnt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
- Connect a cable between the two pins for the applicatio to work
*/



#ifndef RV_PLIC_IS_INCLUDED
#error ( "This app does NOT work as the RV_PLIC peripheral is not included" )
#endif


#ifdef TARGET_PYNQ_Z2
#define GPIO_TB_OUT 8
#define GPIO_TB_IN 9
Expand Down Expand Up @@ -54,6 +61,7 @@ plic_result_t plic_res;

int main(int argc, char *argv[])
{

pad_control_t pad_control;
pad_control.base_addr = mmio_region_from_addr((uintptr_t)PAD_CONTROL_START_ADDRESS);
// rv_plic_params.base_addr = mmio_region_from_addr((uintptr_t)RV_PLIC_START_ADDRESS);
Expand Down Expand Up @@ -131,12 +139,5 @@ int main(int argc, char *argv[])
}
printf("Success\n");

// plic_res = plic_irq_complete(&rv_plic, 0, &intr_num);
// if (plic_res != kPlicOk) {
// printf("Failed\n;");
// return -1;
// }
printf("Done...\n");

return EXIT_SUCCESS;
}
36 changes: 6 additions & 30 deletions sw/applications/example_pdm2pcm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@

#include "x-heep.h"

#ifdef TARGET_PYNQ_Z2
#pragma message ( "This app does NOT work on the Pynq-Z2 board!" )
#ifndef PDM2PCM_IS_INCLUDED
#error ( "This app does NOT work as the PDM2PCM peripheral is not included" )
#endif


int main(int argc, char *argv[])
{


printf("PDM2PCM DEMO\n");
printf(" > Start\n");

Expand All @@ -45,34 +48,6 @@ int main(int argc, char *argv[])
mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_DECIMCIC_REG_OFFSET, 15);
mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_DECIMHB1_REG_OFFSET, 31);
mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_DECIMHB2_REG_OFFSET, 63);

// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB1COEF00_REG_OFFSET , 32768);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB1COEF01_REG_OFFSET , 19618);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB1COEF02_REG_OFFSET ,-3899);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB1COEF03_REG_OFFSET , 684);

// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB2COEF00_REG_OFFSET , 32768);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB2COEF01_REG_OFFSET , 20716);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB2COEF02_REG_OFFSET ,-6529);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB2COEF03_REG_OFFSET , 3492);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB2COEF04_REG_OFFSET ,-2081);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB2COEF05_REG_OFFSET , 1250);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB2COEF06_REG_OFFSET ,-1013);

// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF00_REG_OFFSET , 60609);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF01_REG_OFFSET , 4854);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF02_REG_OFFSET ,-4640);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF03_REG_OFFSET , 4303);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF04_REG_OFFSET ,-3864);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF05_REG_OFFSET , 3353);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF06_REG_OFFSET ,-2805);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF07_REG_OFFSET , 2253);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF08_REG_OFFSET ,-1726);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF09_REG_OFFSET , 1252);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF10_REG_OFFSET ,-852);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF11_REG_OFFSET , 548);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF12_REG_OFFSET ,-385);
// mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_FIRCOEF13_REG_OFFSET ,-178);

mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB1COEF00_REG_OFFSET, 1);
mmio_region_write32(pdm2pcm_base_addr, PDM2PCM_HB1COEF01_REG_OFFSET, 0);
Expand Down Expand Up @@ -129,5 +104,6 @@ int main(int argc, char *argv[])
}
}
return EXIT_SUCCESS;

}

8 changes: 8 additions & 0 deletions sw/applications/example_power_gating_core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#include "pad_control_regs.h"
#include "x-heep.h"


#ifndef RV_PLIC_IS_INCLUDED
#error ( "This app does NOT work as the RV_PLIC peripheral is not included" )
#endif


static rv_timer_t timer_0_1;
static rv_timer_t timer_2_3;
static const uint64_t kTickFreqHz = 1000 * 1000; // 1 MHz
Expand All @@ -33,6 +39,7 @@ static gpio_t gpio;

int main(int argc, char *argv[])
{

// Setup power_manager
mmio_region_t power_manager_reg = mmio_region_from_addr(POWER_MANAGER_START_ADDRESS);
power_manager.base_addr = power_manager_reg;
Expand Down Expand Up @@ -157,4 +164,5 @@ int main(int argc, char *argv[])
/* write something to stdout */
printf("Success.\n");
return EXIT_SUCCESS;

}
5 changes: 5 additions & 0 deletions sw/device/lib/runtime/core_v_mini_mcu.h.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ extern "C" {
#define ${name.upper()}_START_ADDRESS (PERIPHERAL_START_ADDRESS + 0x${peripheral['offset']})
#define ${name.upper()}_SIZE 0x${peripheral['length']}
#define ${name.upper()}_END_ADDRESS (${name.upper()}_START_ADDRESS + ${name.upper()}_SIZE)
% if "yes" in peripheral['is_included']:
#define ${name.upper()}_IS_INCLUDED

%else:

% endif
%endfor

#define EXT_SLAVE_START_ADDRESS 0x${ext_slave_start_address}
Expand Down