📄 drawbox.c
字号:
//
// Project: Experiment 2.10.4 Configure EMIF - Chapter 2
// File name: drawBox.c
// Function(s): drawBox()
//
// Description: This function writes data in a block shape to SDRAM
//
// For the book "Real Time Digital Signal Processing:
// Implementation and Application, 2nd Ed"
// By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
// Publisher: John Wiley and Sons, Ltd
//
// Tools used: CCS v.2.12.07
// TMS320VC5510 DSK Rev-C
//
#define WIDTH 320 // Color checker image width
#define HEIGHT 240 // Color checker image height
#define BOXWIDTH 48 // Color box width
#define BOXHEIGHT 50 // Color box height
#define SDRAM_START 0x28000 // DSK SDRAM physical starting address
#define SDRAM_R SDRAM_START
#define SDRAM_G (SDRAM_R+0x9600) // The offset 0x9600 is for 320x240 bytes
#define SDRAM_B (SDRAM_G+0x9600) // The offset 0x9600 is for 320x240 bytes
#pragma CODE_SECTION(drawBox, ".text:example:drawBox");
void drawBox(unsigned long vOffset, unsigned long hOffset,
unsigned long r, unsigned long g, unsigned long b)
{
unsigned long mPtrR,mPtrR2;
unsigned long mPtrG,mPtrG2;
unsigned long mPtrB,mPtrB2;
short width,height,i,j;
if ((vOffset == 0)&&(hOffset==0)) // Paint black background
{
width = WIDTH>>2;
height = HEIGHT;
}
else // Paint the RGB color block
{
width = BOXWIDTH>>2;
height = BOXHEIGHT;
}
// Set up the pointers to SDRAM
mPtrR = SDRAM_R+(WIDTH*vOffset)+hOffset;
mPtrG = SDRAM_G+(WIDTH*vOffset)+hOffset;
mPtrB = SDRAM_B+(WIDTH*vOffset)+hOffset;
mPtrR2 = mPtrR;
mPtrG2 = mPtrG;
mPtrB2 = mPtrB;
// Paint a box of widthxheight
for (i=0; i<height; i++) // Total height of the drawing
{
for (j=0; j<width; j++) // Draw one line a time
{
*((unsigned long*)mPtrR) = r;
*((unsigned long*)mPtrG) = g;
*((unsigned long*)mPtrB) = b;
mPtrR += 2;
mPtrG += 2;
mPtrB += 2;
}
// Adjust SDRAM address pointers for next line
mPtrR2 += WIDTH>>1;
mPtrG2 += WIDTH>>1;
mPtrB2 += WIDTH>>1;
mPtrR = mPtrR2;
mPtrG = mPtrG2;
mPtrB = mPtrB2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -