📄 hpi_readwrite_example.c
字号:
/* ============================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006
*
* Use of this software is controlled by the terms and conditions found
* in the license agreement under which this software has been supplied.
* ============================================================================
*/
/** ============================================================================
*
* @file Hpi_example.c
*
* @path $(CSLPATH)\example\c6486\hpi\src
*
* @desc In this example, the HPI is used to read and wirte the data in
* fastmode.
*
* ============================================================================
* @n Target Platform: TCI6486 VDB
* ============================================================================
* @n <b> Example Description </b>
* @verbatim
This Example,
1. Enables the powersaver clock of HPI.
2. Initializes and Opens the HPI CSL module.
3. Takes HPI out of reset.
4. Sets up the HPI test bench register.
5. Sets up the HPI TB Fast Mode Address.
6. Sets up burst length in TB for the FAST mode.
7. Loads commands onto the SPM command buffer in the Normal Mode.
8. Starts TB in Normal Mode
9. Starts the FASTMODE HPI Burst Read (DSP to HPI) execution.
10.Starts the FASTMODE HPI Burst Write (HPI to DSP) execution.
11.Verifies the transmited and received data.
@endverbatim
*
* =============================================================================
*
* <b> Procedure to run the example </b>
* @verbatim
* 1. Configure the CCS setup to work with the emulator being used
* 2. Please refer CCS manual for setup configuration and loading
* proper GEL file
* 3. Launch CCS window
* 4. Open project Hpi_readWrite_example.pjt
* 5. Build the project and load the .out file of the project.
*
* @endverbatim
*
* =============================================================================
*/
/* =============================================================================
* Revision History
* ===============
* 30-Nov-2006 NG Updated documentation
* =============================================================================
*/
#include <stdio.h>
#include <csl.h>
#include "example_init.h"
#include <csl_gpio.h>
#include <csl_hpi.h>
#define GEM_ID 0
CSL_HpiObj hpiObj;
CSL_HpiHandle hHpi = (CSL_HpiHandle)NULL;
CSL_HpiHwSetup hwSetup;
CSL_GpioObj gpioObj;
extern CSL_GpioHandle hGpio;
void setup_gpio();
void init_gpio();
Uint32 hpi_readWrite (
void
)
{
Uint32 i, j;
Uint32 result = 0;
Uint32 *dsp_src_buff_g;
Uint32 *dsp_dst_buff_g;
CSL_Status status;
Uint32 response = 0;
if (GEM_ID == 0) {
hGpio = CSL_gpioOpen(&gpioObj, CSL_GPIO, NULL, &status);
dsp_src_buff_g = dsp_src_buff;
dsp_dst_buff_g = dsp_dst_buff;
/* Init Source and Destination Buffer */
for (i = 0 ; i < payLoad[0] ; i++) {
dsp_src_buff_g[i] = i;
dsp_dst_buff_g[i] = 0;
}
/* Initialize HPI */
status = CSL_hpiInit(NULL);
/* Open the HPI CSL module */
hHpi = CSL_hpiOpen(&hpiObj, CSL_HPI, NULL, &status);
/* Clearing HPI_RST in HPIC */
hwSetup.hpiCtrl = (CSL_HpiCtrl)0x00000000;
status = CSL_hpiHwSetup(hHpi, &hwSetup);
/* Sync Between DSP and TB */
setup_gpio();
/* Perform UHPI Transfers for various Payloads */
for (i = 0; i < NO_OF_PAYLOADS; i++) {
/* 1 For Sync */
setup_gpio();
for (j = 0; j < NO_OF_ITERATIONS; j++) {
/* Wait For Normal mode Init */
do {
CSL_hpiGetHwStatus(hHpi, CSL_HPI_QUERY_DSP_INT, &response);
} while (response != 0);
/* Clear Host Int Bit */
CSL_hpiHwControl(hHpi, CSL_HPI_CMD_RESET_DSPINT, NULL);
/* 2 Sync Before FAST MODE */
setup_gpio();
/* 3 Sync After FAST MODE READ */
setup_gpio();
/* 4 Sync AFter Fast Mode Write */
setup_gpio();
} /* loop for NO_OF_ITERATIONS */
/* Compare DSP reference and dst buffers for each payload */
result = Data_Compare_HPI(dsp_src_buff_g, dsp_dst_buff_g, 256);
} /* loop for NO_OF_PAYLOADS */
CSL_gpioClose(hGpio);
}
return (result);
}
/*
* =============================================================================
* @func main
*
* @desc
* This is the main routine for the file.
*
* =============================================================================
*/
void main (
void
)
{
Uint32 result = 0;
printf("HPI Read Write Example \n");
result = hpi_readWrite();
if (!result) {
printf("HPI Read Write Example Passed \n");
}
else {
printf("HPI Read Write Example Failed \n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -