📄 bsp.c
字号:
p_buf = &LCD_Buffer[0];
for (j = 0; j < LCD_LINES_PER_PANEL; j++) { /* For each of the rows of pixels in the panel ... */
for (i = 0; i < LCD_PIXELS_PER_LINE; i++) { /* ... For each of the pixels in the row ... */
/* ... ... Display in the background color. */
#if LCD_BYTES_PER_PIXEL == 1
*p_buf++ = LCD_BGColor;
#elif LCD_BYTES_PER_PIXEL == 2
*p_buf++ = LCD_BGColor & 0xFF;
*p_buf++ = (LCD_BGColor >> 8) & 0xFF;
#endif
}
}
}
/*
*********************************************************************************************************
* WRITE HORIZONTAL BAR TO DISPLAY
*
* Description: This function displays a horizontal bar.
*
* Argument(s): line is the character line number.
* col is the character column number.
* bar_len is the length of the bar.
* tot_len is the total length reserved for the bar.
* color is the color to display the bar in.
*
* Returns : None
*
* Note(s) : (1) tot_len >= bar_len. The length 0 <= i <= bar_len will be shaded color; the length
* bar_len < i <= tot_len will be shaded LCD_BGColor.
*********************************************************************************************************
*/
void LCD_DispHorBar (CPU_INT08U line, CPU_INT08U col, CPU_INT08U bar_len, CPU_INT08U tot_len, CPU_INT16U color)
{
CPU_INT08U i;
CPU_INT08U j;
CPU_INT32U x;
CPU_INT32U y;
CPU_INT32U offset;
CPU_INT08U *p_buf;
x = col * 8;
y = line * 8;
offset = (y * LCD_PIXELS_PER_LINE + x) * LCD_BYTES_PER_PIXEL;
for (j = 0; j < 6; j++) { /* For the first 7 rows of pixels in the bar ... */
p_buf = &LCD_Buffer[offset];
for (i = 0; i < bar_len; i++) { /* ... For the pixels in the bar ... */
/* ... ... Display in color ... */
#if LCD_BYTES_PER_PIXEL == 1
*p_buf++ = color;
#elif LCD_BYTES_PER_PIXEL == 2
*p_buf++ = color & 0xFF;
*p_buf++ = (color >> 8) & 0xFF;
#endif
}
for (i = 0; i < tot_len - bar_len; i++) { /* ... For the pixels outside the bar .. */
/* ... ... Display in the background color ... */
#if LCD_BYTES_PER_PIXEL == 1
*p_buf++ = LCD_BGColor;
#elif LCD_BYTES_PER_PIXEL == 2
*p_buf++ = LCD_BGColor & 0xFF;
*p_buf++ = (LCD_BGColor >> 8) & 0xFF;
#endif
}
offset += LCD_PIXELS_PER_LINE * LCD_BYTES_PER_PIXEL; /* ... Move to next line */
}
}
/*
******************************************************************************************************************************
******************************************************************************************************************************
* uC/OS-VIEW FUNCTIONS
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
*********************************************************************************************************
* INITIALIZE TIMER FOR uC/OS-View
*
* Description : This function is called to by uC/OS-View to initialize the free running timer that is
* used to make time measurements.
*
* Arguments : none
*
* Returns ; none
*
* Note(s) : This function is EMPTY because the timer is initialized elsewhere.
*********************************************************************************************************
*/
#if OS_VIEW_MODULE > 0
void OSView_TmrInit (void)
{
TIMER2_CONTROL = 0; /* Clear TIMER2 control register */
TIMER2_INTCLR = 0; /* Clear TIMER2 interrupt */
TIMER2_LOAD = 0xFFFFFFFF;
/* Setup TIMER2 behavior ... */
TIMER2_CONTROL = TIMER_CONTROL_ENABLE /* ... Enable TIMER2 ... */
| TIMER_CONTROL_PERIODIC /* ... Make TIMER2 periodic ... */
| TIMER_CONTROL_PRESCALE_16 /* ... Use a prescale of 16 ... */
| TIMER_CONTROL_SIZE_32BIT /* ... Use 32-bit counter ... */
| TIMER_CONTROL_WRAPPING;
}
#endif
/*
*********************************************************************************************************
* READ TIMER FOR uC/OS-View
*
* Description : This function is called to read the current counts of a 32 bit free running timer.
*
* Timer #0 of the LPC2000 is used. This is an UP-timer.
*
* Arguments : none
*
* Returns ; The 32 bit counts of the timer assuming the timer (MUST be an UP counter).
*********************************************************************************************************
*/
#if OS_VIEW_MODULE > 0
CPU_INT32U OSView_TmrRd (void)
{
return (~TIMER2_VALUE);
}
#endif
/*
******************************************************************************************************************************
******************************************************************************************************************************
* uC/OS-II TICK TIMER
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
*********************************************************************************************************
* TICKER INITIALIZATION
*
* Description : This function is called to initialize uC/OS-II's tick source (typically a timer generating
* interrupts every 1 to 100 mS).
*
* Arguments : none
*
* Note(s) :
*********************************************************************************************************
*/
static void Tmr_TickInit (void)
{
CPU_INT32U reload;
reload = (CPU_CLK_FREQ >> 8) / OS_TICKS_PER_SEC;
BSP_VectSet(PIC_TIMERINT1, Tmr_TickISR_Handler); /* Assign handler to IRQ vector */
TIMER1_CONTROL = 0; /* Clear TIMER1 control register */
TIMER1_INTCLR = 0; /* Clear TIMER1 interrupt */
TIMER1_LOAD = reload; /* Assign reload value to LOAD register */
/* Setup TIMER1 behavior ... */
TIMER1_CONTROL = TIMER_CONTROL_ENABLE /* ... Enable TIMER1 ... */
| TIMER_CONTROL_PERIODIC /* ... Make TIMER1 periodic ... */
| TIMER_CONTROL_PRESCALE_256; /* ... Use largest prescaler ... */
PIC_IRQ_ENABLESET = PIC_IRQ_TIMERINT1; /* Enable interrupt in PIC */
}
/*
*********************************************************************************************************
* TIMER #0 IRQ HANDLER
*
* Description : This function handles the timer interrupt that is used to generate TICKs for uC/OS-II.
*
* Arguments : none
*
* Returns : none
*
* Note(s) :
*********************************************************************************************************
*/
void Tmr_TickISR_Handler (void)
{
OSTimeTick();
TIMER1_INTCLR = 0; /* Clear TIMER1 interrupt */
}
/*
******************************************************************************************************************************
******************************************************************************************************************************
* INTERRUPT INTERFACE FUNCTIONS
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
*********************************************************************************************************
* SET PIC IRQ VECTOR
*
* Description : This function assigns an ISR for the specified IRQ vector.
*
* Arguments : irq is the IRQ vector number
* isr is a pointer to the ISR.
*
* Returns : none
*
* Note(s) :
*********************************************************************************************************
*/
void BSP_VectSet (CPU_INT08U irq, BSP_PFNCT isr)
{
if (irq < 32) { /* If irq is acceptable value ... */
BSP_PICVectors[irq] = isr; /* ... Then assign isr to appropriate index in table. */
}
}
/*
*********************************************************************************************************
* SET PIC IRQ VECTOR
*
* Description : This function disables all interrupts.
*
* Arguments : none
*
* Returns : none
*
* Note(s) :
*********************************************************************************************************
*/
void BSP_IntDisAll (void)
{
PIC_IRQ_ENABLECLR = 0xFFFFFFFF;
}
/*
*********************************************************************************************************
* IRQ ISR HANDLER
*
* Description : This function is called by OS_CPU_IRQ_ISR() to determine the source of the
* interrupt and process it accordingly.
*
* Arguments : None.
*
* Returns : None.
*********************************************************************************************************
*/
void OS_CPU_IRQ_ISR_Handler (void)
{
CPU_INT32U status;
CPU_INT32U i;
BSP_PFNCT pfnct;
status = PIC_IRQ_STATUS; /* Read PIC_IRQ_STATUS register ... */
for (i = 0; i < 32; i++) { /* ... For each bit in register ... */
if ((status & (1 << i)) != 0) { /* ... ... If bit is set then ... */
pfnct = BSP_PICVectors[i]; /* ... ... Read contents of vector in table ... */
if (pfnct != (BSP_PFNCT)0) { /* ... ... If vector is not 0 ... */
pfnct(); /* ... ... Then execute ISR. */
}
}
}
}
/*
*********************************************************************************************************
* FIQ ISR HANDLER
*
* Description : This function is called by OS_CPU_FIQ_ISR_Handler() to determine the source of the
* interrupt and process it accordingly.
*
* Arguments : None.
*
* Returns : None.
*********************************************************************************************************
*/
void OS_CPU_FIQ_ISR_Handler (void)
{
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -