📄 bsp.c
字号:
*/void LED_Init (void){ LED_Off(0); /* Turn ON all the LEDs. */}/*********************************************************************************************************** LED OFF** Description : This function is used to control any or all the LEDs on the board.** Arguments : led is the number of the LED to turn OFF* 0 indicates that you want ALL the LEDs to be OFF* 1 turns OFF User LED0 on the board* .* .* 3 turns OFF User LED2 on the board**********************************************************************************************************/void LED_Off (CPU_INT08U led){#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register. */ OS_CPU_SR cpu_sr;#endif OS_ENTER_CRITICAL(); switch (led) { case 0: LED_Image = 0x00; break; case 1: LED_Image &= ~0x04; break; case 2: LED_Image &= ~0x02; break; case 3: LED_Image &= ~0x01; break; } *AT91C_PIOB_SODR = ~LED_Image; *AT91C_PIOB_CODR = LED_Image; OS_EXIT_CRITICAL();}/*********************************************************************************************************** LED ON** Description : This function is used to control any or all the LEDs on the board.** Arguments : led is the number of the LED to control* 0 indicates that you want ALL the LEDs to be ON* 1 turns ON User LED 0 on the board* .* .* 3 turns ON User LED 2 on the board**********************************************************************************************************/void LED_On (CPU_INT08U led){#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register. */ OS_CPU_SR cpu_sr;#endif OS_ENTER_CRITICAL(); switch (led) { case 0: LED_Image = 0x00; break; case 1: LED_Image |= 0x04; break; case 2: LED_Image |= 0x02; break; case 3: LED_Image |= 0x01; break; } *AT91C_PIOB_SODR = LED_Image; *AT91C_PIOB_CODR = ~LED_Image; OS_EXIT_CRITICAL();}/*********************************************************************************************************** LED TOGGLE** Description : This function is used to alternate the state of any LED** Arguments : led is the number of the LED to control* 0 indicates that you want ALL the LEDs to toggle* 1 toggle User LED 0 on the board* .* .* 3 toggle User LED 2 on the board**********************************************************************************************************/void LED_Toggle (CPU_INT08U led){#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register. */ OS_CPU_SR cpu_sr;#endif OS_ENTER_CRITICAL(); switch (led) { case 0: LED_Image ^= 0xFF; break; case 1: LED_Image ^= 0x04; break; case 2: LED_Image ^= 0x02; break; case 3: LED_Image ^= 0x01; break; } *AT91C_PIOB_SODR = LED_Image; *AT91C_PIOB_CODR = ~LED_Image; OS_EXIT_CRITICAL();}/*********************************************************************************************************** GET 'PUSH BUTTON' STATUS** Description : This function is used to get the status of any push button on the board.** Arguments : push_button is the number of the push button to probe* 1 probe the push button 0* .* .* 3 probe the push button 2**********************************************************************************************************/CPU_BOOLEAN PB_GetStatus (CPU_INT08U push_button){ CPU_BOOLEAN status; switch (push_button) { case 1: status = ((*AT91C_PIOB_PDSR & BIT29) == 0); break; case 2: status = ((*AT91C_PIOB_PDSR & BIT28) == 0); break; case 3: status = ((*AT91C_PIOA_PDSR & BIT21) == 0); break; default: status = FALSE; break; } return (status);}
/*
*********************************************************************************************************
* Set_Bit() IN A REGISTER
*
* Description : This function sets a bit postion.
*
* Arguments : Bit position
*********************************************************************************************************
*/
#ifdef uC_GUI_MODULE
long Set_Bit (int n)
{
return (1 << n);
}
#endif
/*
*********************************************************************************************************
* LCD_HW_Init()
*
* Description : Initialises the LCD-controller.
*
* Arguments : None
*********************************************************************************************************
*/
#ifdef uC_GUI_MODULE
int LCD_HW_Init (void)
{
RCPC_CTRL |= Set_Bit(9); /* Allow writing to RCPC registers */
RCPC_HCLKPrescale = 0x00000003; /* Divinding by 6 */
RCPC_PeriphClkCtrl2 &= ~Set_Bit(0); /* Enabling CLCD clock */
RCPC_PeriphClkSel2 &= ~Set_Bit(0); /* Select HCLK as LCD Clock Source */
IOCON_LCDMux = LQ64_IOCON_LCDMUX; /* Set the IOCON LCDMux to HRTFT Setting */
CLCDC_TIMING0 = LQ64_CLCDC_TIMING0;
CLCDC_TIMING1 = LQ64_CLCDC_TIMING1;
CLCDC_TIMING2 = LQ64_CLCDC_TIMING2;
CLCDC_CONTROL = LQ_CLCDC_CONTROL&(~Set_Bit(11))&(Set_Bit(0)); /* Power OFF and LCD disable */
HRTFTC_SETUP = LQ64_HRTFTC_SETUP;
HRTFTC_CONTROL = LQ64_HRTFTC_CONTROL;
HRTFTC_TIMING1 = LQ64_HRTFTC_TIMING1;
HRTFTC_TIMING2 = LQ64_HRTFTC_TIMING2;
CLCDC_UPBASE = (long) LH79520_FB_ADRS;
GUI_Delay(2); /* 2 ms delay */
CLCDC_CONTROL |= Set_Bit(11); /* Power ON */
GUI_Delay(2); /* 2 ms delay */
CLCDC_CONTROL |= Set_Bit(0); /* LCD Enable */
CLCDC_CONTROL = LQ_CLCDC_CONTROL; /* LCD On */
return (0);
}
#endif
/*
*********************************************************************************************************
* LCD_HW_SetLUTEntry
*
* Description : Initialises the Look-Up_table entries.
*
* Arguments : Postion in the LUT and Color
*********************************************************************************************************
*/
#ifdef uC_GUI_MODULE
void LCD_HW_SetLUTEntry (U8 pos, LCD_COLOR color)
{
long palword;
U8 palidx;
U8 high;
char r;
char g;
char b;
long rgb;
long *pal;
pal = (long *)(LCD_BASE_ADDR + 0x0200);
LUT_0[pos] = (long)color; /* Save the 24 bit value into a look up table */
/* Convert the 24 bit value into the 16 bit LCD Controller look up table format and save it */
palidx = (pos >> 1); /* Calculate the palette index in the LCD Controller palette register */
high = (pos & 0x0001); /* Determine is it is the Low Word or High Word that is being modified */
if (high == 1) {
palword = (pal[palidx] & 0xFFFF); /* Retreive current palette stored in the LCD controller palette register and get Low Word */
r = color >> 16; /* Convert the data to 16 bit format */
g = color >> 8;
b = color >> 0;
/* Convert to LH79520 LCD Controller palette high word format */
rgb = (((r >> 3) << 10) | ((g >> 3) << 5) | ((b >> 3) << 0)); /* Inverting RGB for the LCD Controller */
pal[palidx] = (rgb << 16) + palword; /* Save the data to the controller */
} else {
palword = (pal[palidx] & 0xFFFF0000);
r = color >> 16; /* Convert the data to 16 bit format */
g = color >> 8;
b = color >> 0;
/* Convert to LH79520 LCD Controller palette high word format */
rgb = (((r >> 3) << 10) | ((g >> 3) << 5) | ((b >> 3) << 0)); /* Inverting RGB for the LCD Controller */
pal[palidx] = palword + rgb; /* Save the data to the controller */
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -