?? dipled.c
字號:
/*
* Functions to access the CPLD controlled DIP and LED
*
* 31May07 .. initial version
*
* Note:
* - work for Large Memory Model only
* - to work in Small Memory Model, we need to use
* the far_peek & far_poke (to be supported)
* - ..
*/
#include "dipled.h"
#define CPLD_USER_REG (*((unsigned short *)0x300000))
// get the status of a DIP switch (0,1,2,3)
unsigned short DSK_DIP_read(unsigned short dip_num)
{
unsigned short reg;
reg = 1<<(dip_num+4); /* add 4 because DIP bits position are 4 to 7 */
reg &= CPLD_USER_REG;
if (reg)
return 1;
return 0;
}
/*Joshuatok*/
// get the status of all DIP switches
unsigned short DSK_DIP_read_all(void)
{
return (CPLD_USER_REG & 0x00f0)>>4;
}
// set the LED on (0,1,2,3)
void DSK_LED_on(unsigned short led_num)
{
CPLD_USER_REG = CPLD_USER_REG | (1<<(led_num));
}
// set the LED off (0,1,2,3)
void DSK_LED_off(unsigned short led_num)
{
CPLD_USER_REG = CPLD_USER_REG & ~(1<<(led_num));
}
// set the LED based on the given pattern
void DSK_LED_set(unsigned short led_pat)
{
unsigned short temp;
temp = CPLD_USER_REG;
temp &= ~0x000f; /* mask all LED bits */
temp |= (led_pat & 0x000f);
CPLD_USER_REG = temp;
}
/*Joshuatok*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -